JBoss Portal SVN: r9467 - in modules/common/trunk/common: src/main/java/org/jboss/portal/common/i18n and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 12:17:49 -0500 (Wed, 09 Jan 2008)
New Revision: 9467
Added:
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleClassLoader.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameParserTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ComplexResourceBundleFactoryTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/DescriptionTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocalizedStringTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ParentChildResourceBundleTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/SimpleResourceBundleTestCase.java
Removed:
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
Modified:
modules/common/trunk/common/pom.xml
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
Log:
move i18n tests in their own package and fix the implementation of SimpleResourceBundleFactory with now test cases
Modified: modules/common/trunk/common/pom.xml
===================================================================
--- modules/common/trunk/common/pom.xml 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/pom.xml 2008-01-09 17:17:49 UTC (rev 9467)
@@ -126,7 +126,7 @@
<argLine>-enableassertions</argLine>
-->
<excludes>
- <exclude>org/jboss/portal/test/common/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/i18n/BundleNameParserTestCase*.java</exclude>
<exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
</excludes>
</configuration>
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -24,6 +24,7 @@
import java.util.Locale;
import java.util.ResourceBundle;
+import java.util.MissingResourceException;
/**
* An implementation that delegates bundle loading to <code>ResourceBundle.getBundle(String,Locale,ClassLoader)</code>.
@@ -40,6 +41,12 @@
/** The classloader to load resource from. */
private ClassLoader classLoader;
+ /**
+ *
+ * @param baseName the base name for loading
+ * @param classLoader the classloader for loading
+ * @throws IllegalArgumentException if any argument is null
+ */
public SimpleResourceBundleFactory(String baseName, ClassLoader classLoader) throws IllegalArgumentException
{
if (baseName == null)
@@ -56,6 +63,17 @@
public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
{
- return ResourceBundle.getBundle(baseName, locale, classLoader);
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("No null locale accepted");
+ }
+ try
+ {
+ return ResourceBundle.getBundle(baseName, locale, classLoader);
+ }
+ catch (MissingResourceException e)
+ {
+ return null;
+ }
}
}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,206 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import junit.framework.TestCase;
-
-import java.util.Locale;
-import java.util.NoSuchElementException;
-
-import org.jboss.portal.common.i18n.BundleName;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class BundleNameIteratorTestCase extends TestCase
-{
-
- private final String A = new Locale("a", "b", "c").getLanguage();
- private final String B = new Locale("a", "b", "c").getCountry();
- private final String C = new Locale("a", "b", "c").getVariant();
-
- public void testNameLookup1()
- {
- Locale l = new Locale("a", "b", "c");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B + "_" + C, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup2()
- {
- Locale l = new Locale("a", "b");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup4()
- {
- Locale l = new Locale("a", "b", "");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "_" + B, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup3()
- {
- Locale l = new Locale("a");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup5()
- {
- Locale l = new Locale("a", "", "");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup6()
- {
- Locale l = new Locale("a", "", "c");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A + "__" + C, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base_" + A, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup7()
- {
- Locale l = new Locale("", "b", "c");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base__" + B + "_" + C, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base__" + B, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-
- public void testNameLookup8()
- {
- Locale l = new Locale("", "", "c");
- BundleName.Iterator iterator = new BundleName.Iterator("base", l);
- assertTrue(iterator.hasNext());
- assertEquals("base___" + C, iterator.next());
- assertTrue(iterator.hasNext());
- assertEquals("base", iterator.next());
- assertFalse(iterator.hasNext());
- try
- {
- iterator.next();
- fail("Was expecting NoSuchElementException");
- }
- catch (NoSuchElementException expected)
- {
- }
- }
-}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,102 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import junit.framework.TestCase;
-import org.jboss.portal.common.i18n.BundleName;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class BundleNameParserTestCase extends TestCase
-{
-
- /** . */
- private final BundleName.Parser parser = new BundleName.Parser();
-
-
- private static final Test[] tests = {
- new Test("_", null),
- new Test("__", null),
- new Test("___", null),
-
- //
- new Test("a", new BundleName("a")),
- new Test("a_b", new BundleName("a", "b")),
- new Test("a_b_c", new BundleName("a", "b", "c")),
- new Test("a__b", new BundleName("a", "", "b")),
- new Test("a___b", new BundleName("a", "", "", "b")),
- new Test("a__b_c", new BundleName("a", "", "b", "c")),
- new Test("a_b__c", new BundleName("a", "b", "", "c")),
- new Test("a_b_c_d", new BundleName("a", "b", "c", "d")),
-
- //
- new Test("", new BundleName("")),
- new Test("_b", new BundleName("", "b")),
- new Test("_b_c", new BundleName("", "b", "c")),
- new Test("__b", new BundleName("", "", "b")),
- new Test("___b", new BundleName("", "", "", "b")),
- new Test("__b_c", new BundleName("", "", "b", "c")),
- new Test("_b__c", new BundleName("", "b", "", "c")),
- new Test("_b_c_d", new BundleName("", "b", "c", "d")),
- };
-
- public void testA()
- {
- for (int i = 0; i < tests.length; i++)
- {
- Test test = tests[i];
- BundleName name = parser.parse(test.input, 0, test.input.length());
- if (name == null)
- {
- assertNull(test.input, test.expectedName);
- }
- else
- {
- assertNotNull(test.input, test.expectedName);
- assertEquals(test.input, test.expectedName.getBaseName(), name.getBaseName());
- assertEquals(test.input, test.expectedName.getLanguage(), name.getLanguage());
- assertEquals(test.input, test.expectedName.getCountry(), name.getCountry());
- assertEquals(test.input, test.expectedName.getVariant(), name.getVariant());
- }
- }
- }
-
-
- private static class Test
- {
-
- /** . */
- private String input;
-
- /** . */
- private BundleName expectedName;
-
- public Test(String input, BundleName expectedName)
- {
- this.input = input;
- this.expectedName = expectedName;
- }
- }
-}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,303 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.net.URLClassLoader;
-import java.net.URL;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.jboss.portal.common.i18n.ComplexResourceBundleFactory;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ComplexResourceBundleFactoryTestCase extends TestCase
-{
-
- /** . */
- private ClassLoader cl;
-
- protected void setUp() throws Exception
- {
- URL bundleURL = Thread.currentThread().getContextClassLoader().getResource("bundle");
- assertNotNull(bundleURL);
- File f = new File(bundleURL.getFile());
- assertTrue(f.exists());
- assertTrue(f.isDirectory());
- cl = new URLClassLoader(new URL[]{f.toURL()}, ClassLoader.getSystemClassLoader());
- }
-
- public void testExactMatch() throws Exception
- {
- Locale.setDefault(new Locale("ja"));
-
- //
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
-
- //
- ResourceBundle a_de_DE = factory.getBundle(new Locale("de", "DE"));
- assertNotNull(a_de_DE);
- assertEquals("a_de_DE", a_de_DE.getString("value"));
-
- //
- ResourceBundle a_fr = factory.getBundle(new Locale("fr"));
- assertNotNull(a_fr);
- assertEquals("a_fr", a_fr.getString("value"));
-
- //
- ResourceBundle a_fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(a_fr_FR);
- assertEquals("a_fr_FR", a_fr_FR.getString("value"));
-
- //
- ResourceBundle a_it = factory.getBundle(new Locale("it"));
- assertNotNull(a_it);
- assertEquals("a_it", a_it.getString("value"));
- }
-
- public void testNoMatch() throws Exception
- {
- Locale.setDefault(new Locale("ja"));
-
- //
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
-
- //
- ResourceBundle a_de = factory.getBundle(new Locale("de"));
- assertNull(a_de);
-
- //
- ResourceBundle a_en = factory.getBundle(new Locale("en"));
- assertNull(a_en);
-
- //
- ResourceBundle a_en_EN = factory.getBundle(new Locale("en", "EN"));
- assertNull(a_en_EN);
- }
-
- public void testFallbackOnDefaultLocale1() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "b");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("b", de.getString("value"));
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("b", fr.getString("value"));
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("b", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("b", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("b", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("b", fr_FR.getString("value"));
- }
-
- public void testFallbackOnDefaultLocale2() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "c");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("c_fr", de.getString("value"));
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("c_fr", fr.getString("value"));
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("c_fr", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("c_fr", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("c_fr", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("c_fr", fr_FR.getString("value"));
- }
-
- public void testFallbackOnDefaultLocale3() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "d");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNull(de);
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNull(fr);
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("d_fr_FR", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("d_fr_FR", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("d_fr_FR", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("d_fr_FR", fr_FR.getString("value"));
- }
-
- public void testFallbackOnDefaultLocale4() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "e");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("e_fr", de.getString("value"));
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("e_fr", fr.getString("value"));
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("e_fr", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("e_fr", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("e_fr", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("e_fr", fr_FR.getString("value"));
- }
-
- public void testFallbackOnDefaultLocale5() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "f");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("f", de.getString("value"));
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("f", fr.getString("value"));
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("f_fr_FR", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("f_fr_FR", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("f_fr_FR", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("f_fr_FR", fr_FR.getString("value"));
- }
-
- public void testFallbackOnDefaultLocale6() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "g");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("g_fr", de.getString("value"));
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("g_fr", fr.getString("value"));
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("g_fr_FR", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("g_fr_FR", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("g_fr", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("g_fr_FR", fr_FR.getString("value"));
- }
-
- public void testFallbackOnDefaultLocale7() throws Exception
- {
- ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "h");
-
- //
- Locale.setDefault(new Locale("fr"));
- ResourceBundle de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("h_fr", de.getString("value"));
- ResourceBundle fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("h_fr", fr.getString("value"));
- ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("h_fr_FR", fr_FR.getString("value"));
-
- //
- Locale.setDefault(new Locale("fr", "FR"));
- de = factory.getBundle(new Locale("de"));
- assertNotNull(de);
- assertEquals("h_fr_FR", de.getString("value"));
- fr = factory.getBundle(new Locale("fr"));
- assertNotNull(fr);
- assertEquals("h_fr", fr.getString("value"));
- fr_FR = factory.getBundle(new Locale("fr", "FR"));
- assertNotNull(fr_FR);
- assertEquals("h_fr_FR", fr_FR.getString("value"));
- }
-}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,105 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import junit.framework.TestCase;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Locale;
-
-import org.jboss.portal.common.i18n.LocalizedString;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 6818 $
- */
-public class DescriptionTestCase extends TestCase
-{
-
- public DescriptionTestCase(String name)
- {
- super(name);
- }
-
- private Locale deflt = Locale.ENGLISH;
- private Locale abc = new Locale("a", "b", "c");
- private Locale ab = new Locale("a", "b");
- private Locale a = new Locale("a");
-
- public void testA()
- {
- Map map = new HashMap();
- map.put(abc, "abc");
- map.put(ab, "ab");
- map.put(a, "a");
- map.put(deflt, "deflt");
- LocalizedString desc = new LocalizedString(map, deflt);
- assertEquals("abc", desc.getString(abc, true));
- assertEquals("ab", desc.getString(ab, true));
- assertEquals("a", desc.getString(a, true));
- }
-
- public void testB()
- {
- Map map = new HashMap();
- map.put(abc, "abc");
- map.put(deflt, "deflt");
- LocalizedString desc = new LocalizedString(map, deflt);
- assertEquals("abc", desc.getString(abc, true));
- assertEquals("deflt", desc.getString(ab, true));
- assertEquals("deflt", desc.getString(a, true));
- }
-
- public void testC()
- {
- Map map = new HashMap();
- map.put(ab, "ab");
- map.put(deflt, "deflt");
- LocalizedString desc = new LocalizedString(map, deflt);
- assertEquals("ab", desc.getString(abc, true));
- assertEquals("ab", desc.getString(ab, true));
- assertEquals("deflt", desc.getString(a, true));
- }
-
- public void testD()
- {
- Map map = new HashMap();
- map.put(a, "a");
- map.put(deflt, "deflt");
- LocalizedString desc = new LocalizedString(map, deflt);
- assertEquals("a", desc.getString(abc, true));
- assertEquals("a", desc.getString(ab, true));
- assertEquals("a", desc.getString(a, true));
- }
-
- public void testE()
- {
- Map map = new HashMap();
- map.put(deflt, "deflt");
- LocalizedString desc = new LocalizedString(map, deflt);
- assertEquals("deflt", desc.getString(abc, true));
- assertEquals("deflt", desc.getString(ab, true));
- assertEquals("deflt", desc.getString(a, true));
- }
-}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,217 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import junit.framework.TestCase;
-
-import java.util.Locale;
-import java.util.Map;
-import java.util.HashMap;
-import java.io.Writer;
-import java.io.IOException;
-
-import org.jboss.portal.common.i18n.LocaleFormat;
-import org.jboss.portal.common.i18n.CachingLocaleFormat;
-import org.jboss.portal.common.i18n.AbstractLocaleFormat;
-import org.jboss.portal.common.util.FormatConversionException;
-import org.jboss.portal.common.util.ConversionException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class LocaleFormatTestCase extends TestCase
-{
-
- public void testgetLocaleFromDefaultFormat() throws ConversionException
- {
- assertEquals(new Locale("a"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a"));
- assertEquals(new Locale("a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b"));
- assertEquals(new Locale("", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_b"));
- assertEquals(new Locale("a", "b", "c"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b_c"));
- assertEquals(new Locale("a", "", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a__b"));
- assertEquals(new Locale("", "a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_a_b"));
- assertEquals(new Locale(""), LocaleFormat.DEFAULT_NO_CACHE.getLocale(""));
-
- //
- try
- {
- assertEquals(new Locale("", "", "a"), LocaleFormat.DEFAULT.getLocale("__a"));
- fail();
- }
- catch (ConversionException expected)
- {
- }
- try
- {
- assertEquals(new Locale("", "", ""), LocaleFormat.DEFAULT_NO_CACHE.getLocale("__"));
- fail();
- }
- catch (ConversionException expected)
- {
- }
- try
- {
- LocaleFormat.DEFAULT.getLocale("_");
- fail();
- }
- catch (ConversionException expected)
- {
- }
- }
-
- public void testToStringFromDefaultFormat() throws ConversionException
- {
- assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a")));
- assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("")));
-
- //
- assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "")));
- assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b")));
- assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "")));
- assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a")));
-
- //
- assertEquals("a_B_c", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "c")));
- assertEquals("_A_b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "b")));
- assertEquals("a__b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "b")));
- assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "")));
- assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "a")));
- assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "")));
- assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "")));
- assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "")));
- }
-
- public void testGetLocaleFromRFC3066LanguageTag() throws ConversionException
- {
- assertEquals(new Locale("en"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en"));
- assertEquals(new Locale("en", "US"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en-US"));
-
- try
- {
- LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("wrong");
- fail("Should have failed since an invalid String was passed.");
- }
- catch (FormatConversionException e)
- {
- //expected
- }
-
- try
- {
- LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("zz");
- fail("Should have failed since an invalid language code was passed.");
- }
- catch (FormatConversionException e)
- {
- //expected
- }
-
- try
- {
- LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-ZZ");
- fail("Should have failed since an invalid country code was passed.");
- }
- catch (FormatConversionException e)
- {
- //expected
- }
-
- // weird combination should work as well
- LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-US");
- }
-
- public void testGetRFC3066LanguageTagFromLocale() throws ConversionException
- {
- assertEquals("en", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en")));
- assertEquals("en-US", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en", "US")));
- }
-
- public void testCachingLocaleFormat() throws ConversionException
- {
- TestLocaleFormat delegate = new TestLocaleFormat();
- delegate.put(new Locale("abc"), "abc");
- CachingLocaleFormat format = new CachingLocaleFormat(delegate);
-
- //
- assertEquals(new Locale("abc"), format.getLocale("abc"));
- assertEquals("abc", format.toString(new Locale("abc")));
-
- //
- try
- {
- format.getLocale("def");
- fail();
- }
- catch (ConversionException e)
- {
- }
-
- //
- try
- {
- format.toString(new Locale("def"));
- fail();
- }
- catch (ConversionException e)
- {
- }
- }
-
- private static class TestLocaleFormat extends AbstractLocaleFormat
- {
-
- /** . */
- private final Map localeToString = new HashMap();
-
- /** . */
- private final Map stringToLocale = new HashMap();
-
- private void put(Locale locale, String string)
- {
- localeToString.put(locale, string);
- stringToLocale.put(string, locale);
- }
-
- protected Locale internalGetLocale(String value) throws ConversionException
- {
- Locale locale = (Locale)stringToLocale.get(value);
- if (locale == null)
- {
- throw new ConversionException();
- }
- return locale;
- }
-
- protected void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException
- {
- String string = (String)localeToString.get(locale);
- if (string == null)
- {
- throw new ConversionException();
- }
- writer.write(string);
- }
- }
-
-}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,89 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import junit.framework.TestCase;
-import org.jboss.portal.common.i18n.LocalizedString;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision: 6818 $
- */
-public class LocalizedStringTestCase extends TestCase
-{
- private Map<Locale, String> values = new HashMap<Locale, String>();
- private LocalizedString localizedString;
-
- protected void setUp() throws Exception
- {
- values.put(Locale.ENGLISH, "labour");
- values.put(Locale.FRENCH, "travail");
- values.put(Locale.US, "labor");
- localizedString = new LocalizedString(values, Locale.US);
- }
-
- public void testLocalizedStringValuesAreNotModifiable()
- {
- try
- {
- localizedString.getValues().clear();
- }
- catch (Exception expected)
- {
- assertTrue(localizedString.hasValues());
- }
- }
-
- public void testPreferredOrBestLocalizedMappingFor()
- {
- try
- {
- localizedString.getPreferredOrBestLocalizedMappingFor(null);
- fail("LocalizedString get most appropriate value for should have thrown an IllegalArgumentException with a null argument");
- }
- catch (IllegalArgumentException expected)
- {
- }
-
- // no desired locales: should return default
- checkValueAndLocale(Locale.US, new String[]{});
-
- checkValueAndLocale(Locale.ENGLISH, new String[]{"en", "en-US", "aa"});
- checkValueAndLocale(Locale.US, new String[]{"en-US", "en", "aa"});
- checkValueAndLocale(Locale.FRENCH, new String[]{"fr-CA"});
- }
-
- private void checkValueAndLocale(Locale locale, String[] desiredLocales)
- {
- LocalizedString.Value mapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
-
- Locale foundLocale = mapping.getLocale();
- assertEquals(locale, foundLocale);
- assertEquals(values.get(foundLocale), mapping.getString());
- assertEquals(mapping.getString(), localizedString.getMostAppropriateValueFor(desiredLocales));
- }
-}
Deleted: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2008-01-09 16:17:51 UTC (rev 9466)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -1,115 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.test.common;
-
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.jboss.portal.common.i18n.ParentChildResourceBundle;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 6818 $
- */
-public class ParentChildResourceBundleTestCase extends TestCase
-{
- public ParentChildResourceBundleTestCase(String name)
- {
- super(name);
- }
-
- public void testBasic()
- {
- ResourceBundle parent = new ResourceBundle()
- {
- protected Object handleGetObject(String key)
- {
- if ("key-a".equals(key))
- {
- return "parent-a";
- }
- if ("key-b".equals(key))
- {
- return "parent-b";
- }
- return null;
- }
- public Enumeration getKeys()
- {
- Vector keys = new Vector();
- keys.add("key-a");
- keys.add("key-b");
- return keys.elements();
- }
- public Locale getLocale()
- {
- return Locale.CHINA;
- }
- };
- ResourceBundle child = new ResourceBundle()
- {
- protected Object handleGetObject(String key)
- {
- if ("key-a".equals(key))
- {
- return "child-a";
- }
- if ("key-c".equals(key))
- {
- return "child-c";
- }
- return null;
- }
- public Enumeration getKeys()
- {
- Vector keys = new Vector();
- keys.add("key-a");
- keys.add("key-c");
- return keys.elements();
- }
- public Locale getLocale()
- {
- return Locale.GERMAN;
- }
- };
- ResourceBundle bundle = new ParentChildResourceBundle(parent, child);
- assertEquals(Locale.GERMAN, bundle.getLocale());
- assertEquals("child-a", bundle.getString("key-a"));
- assertEquals("parent-b", bundle.getString("key-b"));
- assertEquals("child-c", bundle.getString("key-c"));
- Set keys = new HashSet(Arrays.asList(new Object[]{"key-a","key-b","key-c"}));
- for (Enumeration e = bundle.getKeys();e.hasMoreElements();)
- {
- assertTrue(keys.remove(e.nextElement()));
- }
- assertTrue(keys.isEmpty());
- }
-
-}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleClassLoader.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleClassLoader.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleClassLoader.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.Assert;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class BundleClassLoader
+{
+
+ private static ClassLoader instance;
+
+ public synchronized static ClassLoader assertExists()
+ {
+ if (instance == null)
+ {
+ URL bundleURL = Thread.currentThread().getContextClassLoader().getResource("bundle");
+ Assert.assertNotNull(bundleURL);
+ File f = new File(bundleURL.getFile());
+ Assert.assertTrue(f.exists());
+ Assert.assertTrue(f.isDirectory());
+
+ //
+ try
+ {
+ URL url = f.toURL();
+ instance = new URLClassLoader(new URL[]{url}, ClassLoader.getSystemClassLoader());
+ }
+ catch (MalformedURLException e)
+ {
+ Assert.fail("Cannot get URL value " + e.getMessage());
+ }
+ }
+
+ //
+ return instance;
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameIteratorTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameIteratorTestCase extends TestCase
+{
+
+ private final String A = new Locale("a", "b", "c").getLanguage();
+ private final String B = new Locale("a", "b", "c").getCountry();
+ private final String C = new Locale("a", "b", "c").getVariant();
+
+ public void testNameLookup1()
+ {
+ Locale l = new Locale("a", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup2()
+ {
+ Locale l = new Locale("a", "b");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup4()
+ {
+ Locale l = new Locale("a", "b", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup3()
+ {
+ Locale l = new Locale("a");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup5()
+ {
+ Locale l = new Locale("a", "", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup6()
+ {
+ Locale l = new Locale("a", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "__" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup7()
+ {
+ Locale l = new Locale("", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup8()
+ {
+ Locale l = new Locale("", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base___" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameParserTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameParserTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/BundleNameParserTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameParserTestCase extends TestCase
+{
+
+ /** . */
+ private final BundleName.Parser parser = new BundleName.Parser();
+
+
+ private static final Test[] tests = {
+ new Test("_", null),
+ new Test("__", null),
+ new Test("___", null),
+
+ //
+ new Test("a", new BundleName("a")),
+ new Test("a_b", new BundleName("a", "b")),
+ new Test("a_b_c", new BundleName("a", "b", "c")),
+ new Test("a__b", new BundleName("a", "", "b")),
+ new Test("a___b", new BundleName("a", "", "", "b")),
+ new Test("a__b_c", new BundleName("a", "", "b", "c")),
+ new Test("a_b__c", new BundleName("a", "b", "", "c")),
+ new Test("a_b_c_d", new BundleName("a", "b", "c", "d")),
+
+ //
+ new Test("", new BundleName("")),
+ new Test("_b", new BundleName("", "b")),
+ new Test("_b_c", new BundleName("", "b", "c")),
+ new Test("__b", new BundleName("", "", "b")),
+ new Test("___b", new BundleName("", "", "", "b")),
+ new Test("__b_c", new BundleName("", "", "b", "c")),
+ new Test("_b__c", new BundleName("", "b", "", "c")),
+ new Test("_b_c_d", new BundleName("", "b", "c", "d")),
+ };
+
+ public void testA()
+ {
+ for (int i = 0; i < tests.length; i++)
+ {
+ Test test = tests[i];
+ BundleName name = parser.parse(test.input, 0, test.input.length());
+ if (name == null)
+ {
+ assertNull(test.input, test.expectedName);
+ }
+ else
+ {
+ assertNotNull(test.input, test.expectedName);
+ assertEquals(test.input, test.expectedName.getBaseName(), name.getBaseName());
+ assertEquals(test.input, test.expectedName.getLanguage(), name.getLanguage());
+ assertEquals(test.input, test.expectedName.getCountry(), name.getCountry());
+ assertEquals(test.input, test.expectedName.getVariant(), name.getVariant());
+ }
+ }
+ }
+
+
+ private static class Test
+ {
+
+ /** . */
+ private String input;
+
+ /** . */
+ private BundleName expectedName;
+
+ public Test(String input, BundleName expectedName)
+ {
+ this.input = input;
+ this.expectedName = expectedName;
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ComplexResourceBundleFactoryTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ComplexResourceBundleFactoryTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ComplexResourceBundleFactoryTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,287 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.portal.common.i18n.ComplexResourceBundleFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexResourceBundleFactoryTestCase extends TestCase
+{
+
+ public void testExactMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "a");
+
+ //
+ ResourceBundle a_de_DE = factory.getBundle(new Locale("de", "DE"));
+ assertNotNull(a_de_DE);
+ assertEquals("a_de_DE", a_de_DE.getString("value"));
+
+ //
+ ResourceBundle a_fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(a_fr);
+ assertEquals("a_fr", a_fr.getString("value"));
+
+ //
+ ResourceBundle a_fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(a_fr_FR);
+ assertEquals("a_fr_FR", a_fr_FR.getString("value"));
+
+ //
+ ResourceBundle a_it = factory.getBundle(new Locale("it"));
+ assertNotNull(a_it);
+ assertEquals("a_it", a_it.getString("value"));
+ }
+
+ public void testNoMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "a");
+
+ //
+ ResourceBundle a_de = factory.getBundle(new Locale("de"));
+ assertNull(a_de);
+
+ //
+ ResourceBundle a_en = factory.getBundle(new Locale("en"));
+ assertNull(a_en);
+
+ //
+ ResourceBundle a_en_EN = factory.getBundle(new Locale("en", "EN"));
+ assertNull(a_en_EN);
+ }
+
+ public void testFallbackOnDefaultLocale1() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "b");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale2() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "c");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale3() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "d");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNull(de);
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNull(fr);
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("d_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("d_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale4() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "e");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale5() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "f");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale6() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "g");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale7() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(BundleClassLoader.assertExists(), "h");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/DescriptionTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/DescriptionTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/DescriptionTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class DescriptionTestCase extends TestCase
+{
+
+ public DescriptionTestCase(String name)
+ {
+ super(name);
+ }
+
+ private Locale deflt = Locale.ENGLISH;
+ private Locale abc = new Locale("a", "b", "c");
+ private Locale ab = new Locale("a", "b");
+ private Locale a = new Locale("a");
+
+ public void testA()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(ab, "ab");
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testB()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testC()
+ {
+ Map map = new HashMap();
+ map.put(ab, "ab");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("ab", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testD()
+ {
+ Map map = new HashMap();
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("a", desc.getString(abc, true));
+ assertEquals("a", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testE()
+ {
+ Map map = new HashMap();
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("deflt", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocaleFormatTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,217 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Writer;
+import java.io.IOException;
+
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.i18n.CachingLocaleFormat;
+import org.jboss.portal.common.i18n.AbstractLocaleFormat;
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.ConversionException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LocaleFormatTestCase extends TestCase
+{
+
+ public void testgetLocaleFromDefaultFormat() throws ConversionException
+ {
+ assertEquals(new Locale("a"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a"));
+ assertEquals(new Locale("a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b"));
+ assertEquals(new Locale("", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_b"));
+ assertEquals(new Locale("a", "b", "c"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b_c"));
+ assertEquals(new Locale("a", "", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a__b"));
+ assertEquals(new Locale("", "a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_a_b"));
+ assertEquals(new Locale(""), LocaleFormat.DEFAULT_NO_CACHE.getLocale(""));
+
+ //
+ try
+ {
+ assertEquals(new Locale("", "", "a"), LocaleFormat.DEFAULT.getLocale("__a"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ assertEquals(new Locale("", "", ""), LocaleFormat.DEFAULT_NO_CACHE.getLocale("__"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ LocaleFormat.DEFAULT.getLocale("_");
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ }
+
+ public void testToStringFromDefaultFormat() throws ConversionException
+ {
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("")));
+
+ //
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a")));
+
+ //
+ assertEquals("a_B_c", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "c")));
+ assertEquals("_A_b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "b")));
+ assertEquals("a__b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "b")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "a")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "")));
+ }
+
+ public void testGetLocaleFromRFC3066LanguageTag() throws ConversionException
+ {
+ assertEquals(new Locale("en"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en"));
+ assertEquals(new Locale("en", "US"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en-US"));
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("wrong");
+ fail("Should have failed since an invalid String was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("zz");
+ fail("Should have failed since an invalid language code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-ZZ");
+ fail("Should have failed since an invalid country code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ // weird combination should work as well
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-US");
+ }
+
+ public void testGetRFC3066LanguageTagFromLocale() throws ConversionException
+ {
+ assertEquals("en", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en")));
+ assertEquals("en-US", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en", "US")));
+ }
+
+ public void testCachingLocaleFormat() throws ConversionException
+ {
+ TestLocaleFormat delegate = new TestLocaleFormat();
+ delegate.put(new Locale("abc"), "abc");
+ CachingLocaleFormat format = new CachingLocaleFormat(delegate);
+
+ //
+ assertEquals(new Locale("abc"), format.getLocale("abc"));
+ assertEquals("abc", format.toString(new Locale("abc")));
+
+ //
+ try
+ {
+ format.getLocale("def");
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+
+ //
+ try
+ {
+ format.toString(new Locale("def"));
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+ }
+
+ private static class TestLocaleFormat extends AbstractLocaleFormat
+ {
+
+ /** . */
+ private final Map localeToString = new HashMap();
+
+ /** . */
+ private final Map stringToLocale = new HashMap();
+
+ private void put(Locale locale, String string)
+ {
+ localeToString.put(locale, string);
+ stringToLocale.put(string, locale);
+ }
+
+ protected Locale internalGetLocale(String value) throws ConversionException
+ {
+ Locale locale = (Locale)stringToLocale.get(value);
+ if (locale == null)
+ {
+ throw new ConversionException();
+ }
+ return locale;
+ }
+
+ protected void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ String string = (String)localeToString.get(locale);
+ if (string == null)
+ {
+ throw new ConversionException();
+ }
+ writer.write(string);
+ }
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocalizedStringTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocalizedStringTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/LocalizedStringTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6818 $
+ */
+public class LocalizedStringTestCase extends TestCase
+{
+ private Map<Locale, String> values = new HashMap<Locale, String>();
+ private LocalizedString localizedString;
+
+ protected void setUp() throws Exception
+ {
+ values.put(Locale.ENGLISH, "labour");
+ values.put(Locale.FRENCH, "travail");
+ values.put(Locale.US, "labor");
+ localizedString = new LocalizedString(values, Locale.US);
+ }
+
+ public void testLocalizedStringValuesAreNotModifiable()
+ {
+ try
+ {
+ localizedString.getValues().clear();
+ }
+ catch (Exception expected)
+ {
+ assertTrue(localizedString.hasValues());
+ }
+ }
+
+ public void testPreferredOrBestLocalizedMappingFor()
+ {
+ try
+ {
+ localizedString.getPreferredOrBestLocalizedMappingFor(null);
+ fail("LocalizedString get most appropriate value for should have thrown an IllegalArgumentException with a null argument");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ // no desired locales: should return default
+ checkValueAndLocale(Locale.US, new String[]{});
+
+ checkValueAndLocale(Locale.ENGLISH, new String[]{"en", "en-US", "aa"});
+ checkValueAndLocale(Locale.US, new String[]{"en-US", "en", "aa"});
+ checkValueAndLocale(Locale.FRENCH, new String[]{"fr-CA"});
+ }
+
+ private void checkValueAndLocale(Locale locale, String[] desiredLocales)
+ {
+ LocalizedString.Value mapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
+
+ Locale foundLocale = mapping.getLocale();
+ assertEquals(locale, foundLocale);
+ assertEquals(values.get(foundLocale), mapping.getString());
+ assertEquals(mapping.getString(), localizedString.getMostAppropriateValueFor(desiredLocales));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ParentChildResourceBundleTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ParentChildResourceBundleTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/ParentChildResourceBundleTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.i18n.ParentChildResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class ParentChildResourceBundleTestCase extends TestCase
+{
+ public ParentChildResourceBundleTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBasic()
+ {
+ ResourceBundle parent = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "parent-a";
+ }
+ if ("key-b".equals(key))
+ {
+ return "parent-b";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-b");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.CHINA;
+ }
+ };
+ ResourceBundle child = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "child-a";
+ }
+ if ("key-c".equals(key))
+ {
+ return "child-c";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-c");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.GERMAN;
+ }
+ };
+ ResourceBundle bundle = new ParentChildResourceBundle(parent, child);
+ assertEquals(Locale.GERMAN, bundle.getLocale());
+ assertEquals("child-a", bundle.getString("key-a"));
+ assertEquals("parent-b", bundle.getString("key-b"));
+ assertEquals("child-c", bundle.getString("key-c"));
+ Set keys = new HashSet(Arrays.asList(new Object[]{"key-a","key-b","key-c"}));
+ for (Enumeration e = bundle.getKeys();e.hasMoreElements();)
+ {
+ assertTrue(keys.remove(e.nextElement()));
+ }
+ assertTrue(keys.isEmpty());
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/SimpleResourceBundleTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/SimpleResourceBundleTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/i18n/SimpleResourceBundleTestCase.java 2008-01-09 17:17:49 UTC (rev 9467)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.test.common.i18n;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SimpleResourceBundleTestCase extends TestCase
+{
+
+ public SimpleResourceBundleTestCase()
+ {
+ }
+
+ public SimpleResourceBundleTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNormal()
+ {
+ SimpleResourceBundleFactory factory = new SimpleResourceBundleFactory("a", BundleClassLoader.assertExists());
+ assertNull(factory.getBundle(Locale.UK));
+ ResourceBundle bundle = factory.getBundle(new Locale("fr", "FR", "ab"));
+ assertNotNull(bundle);
+ assertEquals(Locale.FRANCE, bundle.getLocale());
+ bundle = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(bundle);
+ assertEquals(Locale.FRANCE, bundle.getLocale());
+ bundle = factory.getBundle(new Locale("fr"));
+ assertNotNull(bundle);
+ assertEquals(Locale.FRENCH, bundle.getLocale());
+ }
+
+ public void testCtorThrowsIAE()
+ {
+ try
+ {
+ new SimpleResourceBundleFactory(null, BundleClassLoader.assertExists());
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ new SimpleResourceBundleFactory("a", null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testGetBundleWithNullLocaleThrowsIAE()
+ {
+ SimpleResourceBundleFactory factory = new SimpleResourceBundleFactory("a", BundleClassLoader.assertExists());
+ try
+ {
+ factory.getBundle(null);
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+}
18 years, 3 months
JBoss Portal SVN: r9466 - modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 11:17:51 -0500 (Wed, 09 Jan 2008)
New Revision: 9466
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java
Log:
update ContainerPortletInfoBuilder to cope with Mucki's change
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java 2008-01-09 15:46:12 UTC (rev 9465)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java 2008-01-09 16:17:51 UTC (rev 9466)
@@ -46,7 +46,6 @@
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import java.util.ArrayList;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -228,7 +227,7 @@
// Then process each mode
for (PortletModeMetaData modeMD : supportsMD.getPortletModes())
{
- capabilities.add(mimeType, Mode.create(modeMD.getPortletMode()));
+ capabilities.add(mimeType, modeMD.getPortletMode());
}
}
18 years, 3 months
JBoss Portal SVN: r9465 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 10:46:12 -0500 (Wed, 09 Jan 2008)
New Revision: 9465
Added:
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/impl/ValueTrimmingFilter.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/metadata/
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/AbstractMetaDataTestCase.java
Log:
- remove old meta data classes
- added back ValueTrimmingFilter which should not have been removed in previous commit
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java 2008-01-09 15:28:51 UTC (rev 9464)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java 2008-01-09 15:46:12 UTC (rev 9465)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
import org.jboss.portal.common.i18n.ResourceBundleManager;
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java 2008-01-09 15:28:51 UTC (rev 9464)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java 2008-01-09 15:46:12 UTC (rev 9465)
@@ -24,8 +24,6 @@
package org.jboss.portal.test.portlet;
import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypeMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypesMetaData;
import org.jboss.portal.portlet.impl.info.ContainerCapabilitiesInfo;
import java.util.Collection;
@@ -46,15 +44,17 @@
public ContentTypesTestCase()
{
contentTypes = new ContainerCapabilitiesInfo();
- ContentTypesMetaData md = new ContentTypesMetaData();
- md.addContentType(new ContentTypeMetaData("text/html", new Mode[]{Mode.EDIT, Mode.HELP, Mode.VIEW}));
- md.addContentType(new ContentTypeMetaData("text/xml", new Mode[]{Mode.VIEW}));
- md.addContentType(new ContentTypeMetaData("*", new Mode[]{Mode.VIEW}));
- md.addContentType(new ContentTypeMetaData("*/*", new Mode[]{}));
- md.addContentType(new ContentTypeMetaData("text/*", new Mode[]{}));
+ ContainerCapabilitiesInfo md = new ContainerCapabilitiesInfo();
+ md.add("text/html", Mode.EDIT);
+ md.add("text/html", Mode.HELP );
+ md.add("text/html", Mode.VIEW);
+ md.add("text/xml", Mode.VIEW);
+ md.add("*", Mode.VIEW);
+// md.add("*/*", new Mode[]{});
+// md.add("text/*", new Mode[]{});
// should this be allowed?
- md.addContentType(new ContentTypeMetaData("pipo/pipo", new Mode[]{}));
+// md.add(new ContentTypeMetaData("pipo/pipo", new Mode[]{}));
}
@Test
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-09 15:28:51 UTC (rev 9464)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-09 15:46:12 UTC (rev 9465)
@@ -32,8 +32,8 @@
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication20MetaData;
import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication10MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.ValueTrimmingFilter;
import org.jboss.portal.portlet.test.metadata.factory.PortletApplicationModelFactory;
-import org.jboss.portal.portlet.test.deployment.ValueTrimmingFilter;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.PortletApplicationRegistry;
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/AbstractMetaDataTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/AbstractMetaDataTestCase.java 2008-01-09 15:28:51 UTC (rev 9464)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/AbstractMetaDataTestCase.java 2008-01-09 15:46:12 UTC (rev 9465)
@@ -26,10 +26,10 @@
import java.io.InputStream;
import java.net.URL;
-import org.jboss.portal.portlet.test.deployment.ValueTrimmingFilter;
import org.jboss.portal.portlet.test.metadata.factory.PortletApplicationModelFactory;
import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication10MetaData;
import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication20MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.ValueTrimmingFilter;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
Added: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/impl/ValueTrimmingFilter.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/impl/ValueTrimmingFilter.java (rev 0)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/impl/ValueTrimmingFilter.java 2008-01-09 15:46:12 UTC (rev 9465)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.portlet.test.metadata.impl;
+
+import org.jboss.xb.binding.GenericObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * Filter <code>setValue</code> method by doing a trimming before calling the next model.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ValueTrimmingFilter implements GenericObjectModelFactory
+{
+
+ private final GenericObjectModelFactory next;
+
+ public ValueTrimmingFilter(GenericObjectModelFactory next) throws IllegalArgumentException
+ {
+ if (next == null)
+ {
+ throw new IllegalArgumentException("Cannot be null");
+ }
+ this.next = next;
+ }
+
+ public Object newChild(Object object, UnmarshallingContext nav, String nsURI, String localName, Attributes attrs)
+ {
+ return next.newChild(object, nav, nsURI, localName, attrs);
+ }
+
+ public void addChild(Object parent, Object child, UnmarshallingContext nav, String nsURI, String localName)
+ {
+ next.addChild(parent, child, nav, nsURI, localName);
+ }
+
+ public void setValue(Object object, UnmarshallingContext nav, String nsURI, String localName, String value)
+ {
+ value = value.trim();
+ next.setValue(object, nav, nsURI, localName, value);
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext nav, String nsURI, String localName, Attributes attrs)
+ {
+ return next.newRoot(root, nav, nsURI, localName, attrs);
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext nav, String nsURI, String localName)
+ {
+ return next.completeRoot(root, nav, nsURI, localName);
+ }
+
+}
\ No newline at end of file
18 years, 3 months
JBoss Portal SVN: r9464 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/container and 12 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 10:28:51 -0500 (Wed, 09 Jan 2008)
New Revision: 9464
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/InlineBundle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/SimpleResourceBundleFactory.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/PortletInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletInfoFactoryImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/info/
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/deployment/
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationContextImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerMetaInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPreferencesInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerSecurityInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/info/CacheInfoSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java
modules/portlet/trunk/test/pom.xml
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml
Log:
update portlet container to use new metadata with runtime info rewrite (for more flexiblity)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -31,9 +31,9 @@
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferenceInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationContextImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationContextImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/container/PortletApplicationContextImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -28,12 +28,17 @@
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletInfoFactory;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfoBuilder;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+import org.jboss.portal.common.i18n.ResourceBundleFactory;
+import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import javax.servlet.ServletContext;
@@ -48,12 +53,9 @@
private final PortletAPIFactory portletAPIFactory;
/** . */
- private final PortletInfoFactory portletInfoFactory;
+ private final PortletApplication10MetaData portletAppMD;
/** . */
- private final PortletApplicationMetaData portletAppMD;
-
- /** . */
private final JBossApplicationMetaData jbossAppMD;
/** . */
@@ -78,7 +80,7 @@
PortletApplicationRegistry registry,
PortletAPIFactory portletAPIFactory,
PortletInfoFactory portletInfoFactory,
- PortletApplicationMetaData portletAppMD,
+ PortletApplication10MetaData portletAppMD,
JBossApplicationMetaData jbossAppMD,
ServletContext servletContext,
ClassLoader classLoader,
@@ -86,7 +88,6 @@
{
this.registry = registry;
this.portletAPIFactory = portletAPIFactory;
- this.portletInfoFactory = portletInfoFactory;
this.portletAppMD = portletAppMD;
this.jbossAppMD = jbossAppMD;
this.servletContext = servletContext;
@@ -103,23 +104,31 @@
public void startPortletApplication() throws Exception
{
- portletApp = new PortletApplicationImpl(portletAppMD, jbossAppMD, this, portletAPIFactory, portletInfoFactory);
+ portletApp = new PortletApplicationImpl(portletAppMD, jbossAppMD, this, portletAPIFactory);
portletApp.start();
//
registrationContext = registry.registerPortletApplication(portletApp);
//
- for (PortletMetaData portletMD : portletAppMD.getPortlets())
+ for (PortletMetaData portletMD : portletAppMD.getPortlets().values())
{
- JBossPortletMetaData jBossPortletMD = null;
- if (jbossAppMD != null)
- {
- jBossPortletMD = (JBossPortletMetaData)jbossAppMD.getPortlets().get(portletMD.getName());
- }
+// JBossPortletMetaData jBossPortletMD = null;
+// if (jbossAppMD != null)
+// {
+// jBossPortletMD = (JBossPortletMetaData)jbossAppMD.getPortlets().get(portletMD.getName());
+// }
+ // Create resource bundle manager
+ String baseName = portletMD.getResourceBundle();
+ ResourceBundleFactory rbf = new SimpleResourceBundleFactory(baseName, classLoader);
+ ResourceBundleManager bundleMgr = new ResourceBundleManager(null, rbf);
+
+ // Build container info
+ ContainerPortletInfo containerInfo = new ContainerPortletInfoBuilder(portletMD, bundleMgr).build();
+
//
- PortletContainerImpl container = new PortletContainerImpl(portletMD, jBossPortletMD);
+ PortletContainerImpl container = new PortletContainerImpl(containerInfo, bundleMgr);
//
container.setApplication(portletApp);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerMetaInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerMetaInfo.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerMetaInfo.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -27,6 +27,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Locale;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,6 +50,14 @@
values.put(key, value);
}
+ public String getDefaultMetaValue(String key)
+ {
+ LocalizedString meta = getMetaValue(key);
+
+ //
+ return meta != null ? meta.getDefaultString() : null;
+ }
+
public LocalizedString getMetaValue(String key)
{
return values.get(key);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -22,14 +22,12 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.info;
-import org.jboss.portal.portlet.info.CacheInfo;
-import org.jboss.portal.portlet.info.CapabilitiesInfo;
-import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.PreferencesInfo;
-import org.jboss.portal.portlet.info.SecurityInfo;
-import org.jboss.portal.portlet.info.SessionInfo;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
/**
* For now implementation that use the portlet container directly.
*
@@ -59,6 +57,15 @@
private ContainerSessionInfo session;
/** . */
+ private String name;
+
+ /** . */
+ private String className;
+
+ /** . */
+ private Map<String, String> initParameters;
+
+ /** . */
private Boolean remotable;
public ContainerPortletInfo(
@@ -68,6 +75,8 @@
ContainerSecurityInfo security,
ContainerCacheInfo cache,
ContainerSessionInfo session,
+ String name,
+ String className,
Boolean remotable)
{
this.capabilities = capabilities;
@@ -76,35 +85,63 @@
this.security = security;
this.cache = cache;
this.session = session;
+ this.name = name;
+ this.className = className;
+ this.initParameters = new HashMap<String, String>();
this.remotable = remotable;
}
- public CapabilitiesInfo getCapabilities()
+ public String getName()
{
+ return name;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void addInitParameter(String parameterName, String parameterValue)
+ {
+ initParameters.put(parameterName, parameterValue);
+ }
+
+ public Set<String> getInitParameterNames()
+ {
+ return initParameters.keySet();
+ }
+
+ public String getInitParameter(String name)
+ {
+ return initParameters.get(name);
+ }
+
+ public ContainerCapabilitiesInfo getCapabilities()
+ {
return capabilities;
}
- public PreferencesInfo getPreferences()
+ public ContainerPreferencesInfo getPreferences()
{
return preferences;
}
- public MetaInfo getMeta()
+ public ContainerMetaInfo getMeta()
{
return meta;
}
- public SecurityInfo getSecurity()
+ public ContainerSecurityInfo getSecurity()
{
return security;
}
- public CacheInfo getCache()
+ public ContainerCacheInfo getCache()
{
return cache;
}
- public SessionInfo getSession()
+ public ContainerSessionInfo getSession()
{
return session;
}
Copied: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java (from rev 9457, modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/PortletInfoBuilder.java)
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfoBuilder.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -0,0 +1,328 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.portlet.impl.info;
+
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletPreferenceMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.SupportedLocaleMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.SupportsMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletModeMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.SecurityRoleRefMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletPreferencesMetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.WindowStateMetaData;
+import org.jboss.portal.portlet.impl.metadata.security.SecurityConstraintMetaData;
+import org.jboss.portal.portlet.impl.metadata.common.InitParamMetaData;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
+import org.jboss.portal.Mode;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContainerPortletInfoBuilder
+{
+
+ /** . */
+ private static final String[] KEYS = {MetaInfo.TITLE, MetaInfo.SHORT_TITLE, MetaInfo.KEYWORDS};
+
+ /** . */
+ private static final String JAVAX_PORTLET = "javax.portlet.";
+
+ /** . */
+ private static final String[] BUNDLE_KEYS = {JAVAX_PORTLET + MetaInfo.TITLE, JAVAX_PORTLET + MetaInfo.SHORT_TITLE, JAVAX_PORTLET + MetaInfo.KEYWORDS};
+
+ /** . */
+ private PortletMetaData portletMD;
+
+ /** . */
+ private ResourceBundleManager bundleMgr;
+
+ public ContainerPortletInfoBuilder(PortletMetaData portletMD, ResourceBundleManager bundleMgr)
+ {
+ this.portletMD = portletMD;
+ this.bundleMgr = bundleMgr;
+ }
+
+ public ContainerPortletInfo build()
+ {
+ fixMetaData();
+
+ //
+ ContainerCapabilitiesInfo containerCapabilities = buildContainerCapabilities();
+ ContainerPreferencesInfo containerPreferences = buildContainerPreferences();
+ ContainerMetaInfo containerMeta = buildContainerMeta();
+ ContainerSecurityInfo containerSecurity = buildContainerSecurityInfo();
+ ContainerCacheInfo containerCache = buildContainerCache();
+ ContainerSessionInfo containerSession = buildContainerSession();
+
+ //
+ ContainerPortletInfo containerPortletInfo = new ContainerPortletInfo(
+ containerCapabilities,
+ containerPreferences,
+ containerMeta,
+ containerSecurity,
+ containerCache,
+ containerSession,
+ portletMD.getPortletName(),
+ portletMD.getPortletClass(),
+ false
+ );
+
+ //
+ for (InitParamMetaData initParamMD : portletMD.getInitParams())
+ {
+ containerPortletInfo.addInitParameter(initParamMD.getName(), initParamMD.getValue());
+ }
+
+ //
+ return containerPortletInfo;
+ }
+
+ private void fixMetaData()
+ {
+ if (portletMD.getSecurityRoleRef() == null)
+ {
+ portletMD.setSecurityRoleRef(new ArrayList<SecurityRoleRefMetaData>());
+ }
+ if (portletMD.getPortletApplication().getSecurityConstraints() == null)
+ {
+ portletMD.getPortletApplication().setSecurityConstraints(new ArrayList<SecurityConstraintMetaData>());
+ }
+ if (portletMD.getSupportedLocale() == null)
+ {
+ portletMD.setSupportedLocale(new ArrayList<SupportedLocaleMetaData>());
+ }
+ for (SupportsMetaData supportsMD : portletMD.getSupports())
+ {
+ if (supportsMD.getPortletModes() == null)
+ {
+ supportsMD.setPortletModes(new ArrayList<PortletModeMetaData>());
+ }
+ if (supportsMD.getWindowStates() == null)
+ {
+ supportsMD.setWindowStates(new ArrayList<WindowStateMetaData>());
+ }
+ }
+ if (portletMD.getPortletPreferences() == null)
+ {
+ portletMD.setPortletPreferences(new PortletPreferencesMetaData());
+ }
+ if (portletMD.getPortletPreferences().getPortletPreferences() == null)
+ {
+ portletMD.getPortletPreferences().setPortletPreferences(new HashMap<String, PortletPreferenceMetaData>());
+ }
+ if (portletMD.getInitParams() == null)
+ {
+ portletMD.setInitParams(new ArrayList<InitParamMetaData>());
+ }
+ for (PortletPreferenceMetaData portletPreferenceMD : portletMD.getPortletPreferences().getPortletPreferences().values())
+ {
+ if (portletPreferenceMD.getValue() == null)
+ {
+ portletPreferenceMD.setValue(new ArrayList<String>());
+ }
+ }
+ }
+
+ private List<Locale> getSupportedLocales()
+ {
+ List<Locale> locales = new ArrayList<Locale>();
+ for (SupportedLocaleMetaData supportedLocaleMD : portletMD.getSupportedLocale())
+ {
+ Locale locale = supportedLocaleMD.getLocale();
+ locales.add(locale);
+ }
+ return locales;
+ }
+
+ private ContainerSecurityInfo buildContainerSecurityInfo()
+ {
+ ContainerSecurityInfo containerSecurity = new ContainerSecurityInfo();
+
+ // Security role ref
+ for (SecurityRoleRefMetaData securityRoleRefMD : portletMD.getSecurityRoleRef())
+ {
+ containerSecurity.addRoleRef(securityRoleRefMD.getRoleName(), securityRoleRefMD.getRoleLink());
+ }
+
+ //
+ for (SecurityConstraintMetaData securityConstraintMD : portletMD.getPortletApplication().getSecurityConstraints())
+ {
+ if (securityConstraintMD.getPortletList().getPortletNames().contains(portletMD.getPortletName()))
+ {
+ containerSecurity.addTransportGuarantee(securityConstraintMD.getUserDataConstraint().getTransportQuarantee());
+ }
+ }
+
+ //
+ return containerSecurity;
+ }
+
+ private ContainerSessionInfo buildContainerSession()
+ {
+ return new ContainerSessionInfo(false);
+ }
+
+ private ContainerCacheInfo buildContainerCache()
+ {
+ int expirationCache = portletMD.getExpirationCache();
+
+ //
+ if (expirationCache < 0 && expirationCache != -1)
+ {
+ // log.warn("Seen bad caching expiration value " + expirationTimeSecs + " disable caching instead");
+ expirationCache = 0;
+ }
+
+ //
+ return new ContainerCacheInfo(expirationCache);
+ }
+
+ private ContainerCapabilitiesInfo buildContainerCapabilities()
+ {
+ ContainerCapabilitiesInfo capabilities = new ContainerCapabilitiesInfo();
+
+ //
+ for (SupportsMetaData supportsMD : portletMD.getSupports())
+ {
+ // Get the mime type
+ String mimeType = supportsMD.getMimeType().toLowerCase();
+
+ // Add the content type to the view mode
+ // because each content type must handle this view
+ capabilities.add(mimeType, Mode.VIEW);
+
+ // Then process each mode
+ for (PortletModeMetaData modeMD : supportsMD.getPortletModes())
+ {
+ capabilities.add(mimeType, Mode.create(modeMD.getPortletMode()));
+ }
+ }
+
+ //
+ return capabilities;
+ }
+
+ private ContainerMetaInfo buildContainerMeta()
+ {
+ ContainerMetaInfo containerMeta = new ContainerMetaInfo();
+
+ // Capture inline values
+ String[] inlines = {
+ portletMD.getPortletInfo().getTitle(),
+ portletMD.getPortletInfo().getShortTitle(),
+ portletMD.getPortletInfo().getKeywords()
+ };
+
+ // Construct info from resource bundle manager
+ for (int i = 0; i < KEYS.length; i++)
+ {
+ String key = KEYS[i];
+
+ //
+ Map<Locale, String> tmp = new HashMap<Locale, String>();
+
+ //
+ List<Locale> locales = getSupportedLocales();
+
+ // Add english locale
+ locales.add(Locale.ENGLISH);
+
+ // Feed with the known locales (perhaps should try more locales)
+ for (Locale locale : locales)
+ {
+ ResourceBundle bundle = bundleMgr.getResourceBundle(locale);
+
+ //
+ if (bundle != null)
+ {
+ try
+ {
+ String value = bundle.getString(BUNDLE_KEYS[i]);
+ tmp.put(locale, value);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+ }
+
+ // Add the inline value if it is present
+ if (inlines[i] != null)
+ {
+ tmp.put(Locale.ENGLISH, inlines[i]);
+ }
+
+ //
+ LocalizedString ls = new LocalizedString(tmp, Locale.ENGLISH);
+ containerMeta.addMetaValue(key, ls);
+ }
+
+ // Add stuff coming from deployment descriptor
+ containerMeta.addMetaValue(MetaInfo.DESCRIPTION, portletMD.getDescription());
+ containerMeta.addMetaValue(MetaInfo.DISPLAY_NAME, portletMD.getDisplayName());
+
+ //
+ return containerMeta;
+ }
+
+ private ContainerPreferencesInfo buildContainerPreferences()
+ {
+ PortletPreferencesMetaData preferencesMD = portletMD.getPortletPreferences();
+
+ //
+ String validatorClassName = null;
+ if (preferencesMD != null)
+ {
+ validatorClassName = preferencesMD.getPreferenceValidator();
+ }
+
+ //
+ ContainerPreferencesInfo containerPreferences = new ContainerPreferencesInfo(validatorClassName);
+
+ //
+ for (PortletPreferenceMetaData portletPreferenceMD : preferencesMD.getPortletPreferences().values())
+ {
+ Value value = new StringValue(portletPreferenceMD.getValue());
+ LocalizedString displayName = bundleMgr.getLocalizedValue("javax.portlet.preference.name." + portletPreferenceMD.getName(), portletPreferenceMD.getName());
+ LocalizedString description = bundleMgr.getLocalizedValue("javax.portlet.preference.description." + portletPreferenceMD.getName(), portletPreferenceMD.getName());
+ containerPreferences.addContainerPreference(portletPreferenceMD.getName(), value, portletPreferenceMD.isReadOnly(), displayName, description);
+ }
+
+ //
+ return containerPreferences;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPreferencesInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPreferencesInfo.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPreferencesInfo.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -46,12 +46,21 @@
/** . */
private final Set<String> keys;
- public ContainerPreferencesInfo()
+ /** . */
+ private final String validatorClassName;
+
+ public ContainerPreferencesInfo(String validatorClassName)
{
- content = new HashMap<String, PreferenceInfo>();
- keys = Collections.unmodifiableSet(content.keySet());
+ this.content = new HashMap<String, PreferenceInfo>();
+ this.keys = Collections.unmodifiableSet(content.keySet());
+ this.validatorClassName = validatorClassName;
}
+ public String getValidatorClassName()
+ {
+ return validatorClassName;
+ }
+
public ContainerPreferenceInfo getContainerPreference(String key)
{
if (key == null)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerSecurityInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerSecurityInfo.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerSecurityInfo.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -28,6 +28,8 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -42,15 +44,41 @@
/** . */
private final Set<TransportGuarantee> rotgs;
+ /** . */
+ private final Map<String, String> roleRefs;
+
public ContainerSecurityInfo()
{
- tgs = new HashSet<TransportGuarantee>();
+ Set<TransportGuarantee> tgs = new HashSet<TransportGuarantee>();
tgs.add(TransportGuarantee.NONE);
//
- rotgs = Collections.unmodifiableSet(tgs);
+ this.tgs= tgs;
+ this.roleRefs = new HashMap<String, String>();
+ this.rotgs = Collections.unmodifiableSet(tgs);
}
+ public String getRoleRef(String roleName)
+ {
+ return roleRefs.get(roleName);
+ }
+
+ public boolean containsRoleRef(String roleName)
+ {
+ return roleRefs.containsKey(roleName);
+ }
+
+ public void addRoleRef(String roleName, String roleLink)
+ {
+ if (roleName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ roleRefs.put(roleName, roleLink);
+ }
+
public void addTransportGuarantee(TransportGuarantee transportGuarantee)
{
tgs.add(transportGuarantee);
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/PortletInfoBuilder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/PortletInfoBuilder.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/PortletInfoBuilder.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -1,228 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.portlet.impl.info;
-
-import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
-import org.jboss.portal.portlet.impl.metadata.portlet.PortletPreferenceMetaData;
-import org.jboss.portal.portlet.impl.metadata.portlet.SupportedLocaleMetaData;
-import org.jboss.portal.portlet.impl.metadata.portlet.SupportsMetaData;
-import org.jboss.portal.portlet.impl.metadata.portlet.PortletModeMetaData;
-import org.jboss.portal.portlet.impl.metadata.security.SecurityConstraintMetaData;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.MetaInfo;
-import org.jboss.portal.common.value.Value;
-import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.i18n.ResourceBundleManager;
-import org.jboss.portal.Mode;
-
-import java.util.Locale;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.MissingResourceException;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PortletInfoBuilder
-{
-
- /** . */
- private static final String[] KEYS = {MetaInfo.TITLE, MetaInfo.SHORT_TITLE, MetaInfo.KEYWORDS};
-
- /** . */
- private static final String JAVAX_PORTLET = "javax.portlet.";
-
- /** . */
- private static final String[] BUNDLE_KEYS = {JAVAX_PORTLET + MetaInfo.TITLE, JAVAX_PORTLET + MetaInfo.SHORT_TITLE, JAVAX_PORTLET + MetaInfo.KEYWORDS};
-
- /** . */
- private PortletMetaData portletMD;
-
- /** . */
- private ResourceBundleManager bundleMgr;
-
- public PortletInfoBuilder(PortletMetaData portletMD, ResourceBundleManager bundleMgr)
- {
- this.portletMD = portletMD;
- this.bundleMgr = bundleMgr;
- }
-
- public PortletInfo build()
- {
- ContainerCapabilitiesInfo containerCapabilities = buildContainerCapabilities();
- ContainerPreferencesInfo containerPreferences = buildContainerPreferences();
- ContainerMetaInfo containerMeta = buildContainerMeta();
- ContainerSecurityInfo containerSecurity = buildContainerSecurityInfo();
- ContainerCacheInfo containerCache = buildContainerCache();
- ContainerSessionInfo containerSession = buildContainerSession();
-
- //
- return new ContainerPortletInfo(
- containerCapabilities,
- containerPreferences,
- containerMeta,
- containerSecurity,
- containerCache,
- containerSession,
- false
- );
- }
-
- private List<Locale> getSupportedLocales()
- {
- List<Locale> locales = new ArrayList<Locale>();
- for (SupportedLocaleMetaData supportedLocaleMD : portletMD.getSupportedLocale())
- {
- Locale locale = supportedLocaleMD.getLocale();
- locales.add(locale);
- }
- return locales;
- }
-
- private ContainerSecurityInfo buildContainerSecurityInfo()
- {
- ContainerSecurityInfo containerSecurity = new ContainerSecurityInfo();
-
- //
- for (SecurityConstraintMetaData securityConstraintMD : portletMD.getPortletApplication().getSecurityConstraints())
- {
- if (securityConstraintMD.getPortletList().getPortletNames().contains(portletMD.getPortletName()))
- {
- containerSecurity.addTransportGuarantee(securityConstraintMD.getUserDataConstraint().getTransportQuarantee());
- }
- }
-
- //
- return containerSecurity;
- }
-
- private ContainerSessionInfo buildContainerSession()
- {
- return new ContainerSessionInfo(false);
- }
-
- private ContainerCacheInfo buildContainerCache()
- {
- int expirationCache = portletMD.getExpirationCache();
-
- //
- if (expirationCache < 0 && expirationCache != -1)
- {
- // log.warn("Seen bad caching expiration value " + expirationTimeSecs + " disable caching instead");
- expirationCache = 0;
- }
-
- //
- return new ContainerCacheInfo(expirationCache);
- }
-
- private ContainerCapabilitiesInfo buildContainerCapabilities()
- {
- ContainerCapabilitiesInfo capabilities = new ContainerCapabilitiesInfo();
-
- //
- for (SupportsMetaData supportsMD : portletMD.getSupports())
- {
- // Get the mime type
- String mimeType = supportsMD.getMimeType().toLowerCase();
-
- // Add the content type to the view mode
- // because each content type must handle this view
- capabilities.add(mimeType, Mode.VIEW);
-
- // Then process each mode
- for (PortletModeMetaData modeMD : supportsMD.getPortletModes())
- {
- capabilities.add(mimeType, Mode.create(modeMD.getPortletMode()));
- }
- }
-
- //
- return capabilities;
- }
-
- private ContainerMetaInfo buildContainerMeta()
- {
- ContainerMetaInfo containerMeta = new ContainerMetaInfo();
-
- // Construct info from resource bundle manager
- if (bundleMgr != null)
- {
- for (int i = 0; i < KEYS.length; i++)
- {
- String key = KEYS[i];
- Map<Locale, String> tmp = new HashMap<Locale, String>();
-
- //
- List<Locale> locales = getSupportedLocales();
-
- // Add english locale
- locales.add(Locale.ENGLISH);
-
- for (Locale locale : locales)
- {
- ResourceBundle bundle = bundleMgr.getResourceBundle(locale);
- try
- {
- String value = bundle.getString(BUNDLE_KEYS[i]);
- tmp.put(locale, value);
- }
- catch (MissingResourceException ignore)
- {
- }
- }
- LocalizedString ls = new LocalizedString(tmp, Locale.ENGLISH);
- containerMeta.addMetaValue(key, ls);
- }
- }
-
- // Add stuff coming from meta data
- containerMeta.addMetaValue(MetaInfo.DESCRIPTION, portletMD.getDescription());
- containerMeta.addMetaValue(MetaInfo.DISPLAY_NAME, portletMD.getDisplayName());
-
- //
- return containerMeta;
- }
-
- private ContainerPreferencesInfo buildContainerPreferences()
- {
- ContainerPreferencesInfo containerPreferences = new ContainerPreferencesInfo();
-
- //
- for (PortletPreferenceMetaData portletPreferenceMD : portletMD.getPortletPreferences().getPortletPreferences().values())
- {
- Value value = new StringValue(portletPreferenceMD.getValue().toArray(new String[portletPreferenceMD.getValue().size()]));
- LocalizedString displayName = bundleMgr.getLocalizedValue("javax.portlet.preference.name." + portletPreferenceMD.getName(), portletPreferenceMD.getName());
- LocalizedString description = bundleMgr.getLocalizedValue("javax.portlet.preference.description." + portletPreferenceMD.getName(), portletPreferenceMD.getName());
- containerPreferences.addContainerPreference(portletPreferenceMD.getName(), value, portletPreferenceMD.isReadOnly(), displayName, description);
- }
-
- //
- return containerPreferences;
- }
-}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/InlineBundle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/InlineBundle.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/InlineBundle.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.portlet.impl.jsr168;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.info.MetaInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListResourceBundle;
+import java.util.Locale;
+
+/**
+ * A resource bundle that contains the inline information defined by the portlet specification.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6697 $
+ */
+public class InlineBundle extends ListResourceBundle
+{
+
+ private static final Logger log = Logger.getLogger(InlineBundle.class);
+
+ /** . */
+ private final Object[][] content;
+
+ public InlineBundle(ContainerPortletInfo portletInfo)
+ {
+ log.debug("Creates the parent bundle");
+
+ //
+ List<Object> list = new ArrayList<Object>(3);
+
+ //
+ String title = portletInfo.getMeta().getDefaultMetaValue(MetaInfo.TITLE);
+ if (title != null)
+ {
+ list.add(new Object[]{APIConstants.JAVAX_PORTLET_TITLE, title});
+ }
+
+ //
+ String shortTitle = portletInfo.getMeta().getDefaultMetaValue(MetaInfo.SHORT_TITLE);
+ if (shortTitle != null)
+ {
+ list.add(new Object[]{APIConstants.JAVAX_PORTLET_SHORT_TITLE, shortTitle});
+ }
+
+ //
+ String keywords = portletInfo.getMeta().getDefaultMetaValue(MetaInfo.KEYWORDS);
+ if (keywords != null)
+ {
+ list.add(new Object[]{APIConstants.JAVAX_PORTLET_KEYWORDS, keywords});
+ }
+
+ //
+ content = (Object[][])list.toArray(new Object[list.size()][]);
+ }
+
+ protected Object[][] getContents()
+ {
+ return content;
+ }
+
+ /**
+ * This is the english locale.
+ *
+ * @return the english locale
+ */
+ public Locale getLocale()
+ {
+ return Locale.ENGLISH;
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -23,9 +23,8 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletInfoFactory;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletApplicationContext;
@@ -34,7 +33,6 @@
import javax.portlet.PortletContext;
import java.util.HashSet;
import java.util.LinkedHashMap;
-import java.util.Map;
import java.util.Set;
/**
@@ -45,7 +43,7 @@
{
/** . */
- protected final PortletApplicationMetaData metaData;
+ protected final PortletApplication10MetaData metaData;
/** . */
protected final JBossApplicationMetaData jbossMetaData;
@@ -57,9 +55,6 @@
protected final PortletAPIFactory portletAPIFactory;
/** . */
- protected final PortletInfoFactory portletInfoFactory;
-
- /** . */
protected LinkedHashMap<String, PortletContainer> portlets;
/** . */
@@ -68,23 +63,15 @@
/** . */
protected String version;
- /** . */
- protected Map portletModes;
-
- /** . */
- protected Map windowStates;
-
public PortletApplicationImpl(
- PortletApplicationMetaData metaData,
+ PortletApplication10MetaData metaData,
JBossApplicationMetaData jbossMetaData,
PortletApplicationContext context,
- PortletAPIFactory portletAPIFactory,
- PortletInfoFactory portletInfoFactory)
+ PortletAPIFactory portletAPIFactory)
{
this.metaData = metaData;
this.jbossMetaData = jbossMetaData;
this.portletAPIFactory = portletAPIFactory;
- this.portletInfoFactory = portletInfoFactory;
this.portlets = new LinkedHashMap<String, PortletContainer>();
this.context = context;
}
@@ -99,13 +86,8 @@
return portletAPIFactory;
}
- public PortletInfoFactory getPortletInfoFactory()
+ public PortletApplication10MetaData getMetaData()
{
- return portletInfoFactory;
- }
-
- public PortletApplicationMetaData getMetaData()
- {
return metaData;
}
@@ -129,16 +111,12 @@
public void start() throws Exception
{
version = metaData.getVersion();
- portletModes = metaData.getPortletModes();
- windowStates = metaData.getWindowStates();
portletContext = new PortletContextImpl(context.getServletContext());
}
public void stop()
{
version = null;
- portletModes = null;
- windowStates = null;
portletContext = null;
}
@@ -152,16 +130,6 @@
return portletContext;
}
- public Map getPortletModes()
- {
- return portletModes;
- }
-
- public Map getWindowStates()
- {
- return windowStates;
- }
-
// WebApp implementation ********************************************************************************************
public Set<PortletContainer> getPortletContainers()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -35,11 +35,9 @@
import org.jboss.portal.portlet.impl.jsr168.api.PortletConfigImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ParameterMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletPreferencesMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.SecurityRoleRefMetaData;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -48,7 +46,6 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.SecurityErrorResponse;
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
import org.apache.log4j.Logger;
import javax.portlet.Portlet;
@@ -59,10 +56,6 @@
import javax.portlet.UnavailableException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
/**
@@ -78,12 +71,6 @@
/** . */
protected PortletApplicationImpl application;
- /** . */
- protected PortletMetaData metaData;
-
- /** . */
- protected JBossPortletMetaData jbossMetaData;
-
/** The portlet implementation class name. */
protected String className;
@@ -96,17 +83,17 @@
/** The invocation valve. */
protected final Valve valve;
- /** Give the correspondance between role name and role link. */
- protected Map securityRoleRefsMap;
-
/** Are we started or not. */
protected boolean started;
/** User data constraint. */
protected Set userDataConstraints;
+ /** . */
+ protected ResourceBundleManager internalBundleManager;
+
/** Return info. */
- protected PortletInfo info;
+ protected ContainerPortletInfo info;
/**
* The preference validator, this is not exposed as runtime meta data as it is only used by the JSR 168 portlet
@@ -114,16 +101,16 @@
*/
protected PreferencesValidator preferencesValidator;
- public PortletContainerImpl(PortletMetaData metaData, JBossPortletMetaData jbossMetaData)
+ public PortletContainerImpl(ContainerPortletInfo info, ResourceBundleManager internalBundleManager)
{
- this.metaData = metaData;
- this.jbossMetaData = jbossMetaData;
+ this.info = info;
+ this.internalBundleManager = internalBundleManager;
this.valve = new Valve();
- this.log = Logger.getLogger("org.jboss.portal.portlet.container." + metaData.getClassName().replace('.', '_'));
+ this.log = Logger.getLogger("org.jboss.portal.portlet.container." + info.getClassName().replace('.', '_'));
this.started = false;
}
- public PortletInfo getInfo()
+ public ContainerPortletInfo getInfo()
{
if (started)
{
@@ -131,24 +118,14 @@
}
//
- throw new IllegalStateException("Portlet " + metaData.getName() + " is not started");
+ throw new IllegalStateException("Portlet " + info.getName() + " is not started");
}
public String getId()
{
- return metaData.getName();
+ return info.getName();
}
- public PortletMetaData getMetaData()
- {
- return metaData;
- }
-
- public JBossPortletMetaData getJBossMetaData()
- {
- return jbossMetaData;
- }
-
public boolean isStarted()
{
return valve.getState() == Valve.OPEN;
@@ -157,13 +134,13 @@
public void start() throws PortletInitializationException
{
// Set class name
- this.className = metaData.getClassName();
+ this.className = info.getClassName();
//
- PortletPreferencesMetaData preferences = metaData.getPreferences();
+ ContainerPreferencesInfo preferences = info.getPreferences();
if (preferences != null)
{
- String validatorClassName = preferences.getValidator();
+ String validatorClassName = preferences.getValidatorClassName();
if (validatorClassName != null)
{
try
@@ -193,35 +170,12 @@
}
}
- // Security role ref
- Map securityRoleRefsMap = new HashMap();
- for (Iterator i = metaData.getSecurityRoleRefs().iterator(); i.hasNext();)
- {
- SecurityRoleRefMetaData securityRoleRefMD = (SecurityRoleRefMetaData)i.next();
- securityRoleRefsMap.put(securityRoleRefMD.getRoleName(), securityRoleRefMD.getRoleLink());
- }
+ //
+ ResourceBundleManager bundleManager = PortletResourceBundleFactory.createResourceBundleManager(internalBundleManager, info);
- // Init parameters
- Map initParameters = new HashMap();
- for (Iterator i = metaData.getParameters().values().iterator(); i.hasNext();)
- {
- ParameterMetaData parameterMD = (ParameterMetaData)i.next();
- initParameters.put(parameterMD.getName(), parameterMD.getValue());
- }
-
- // Resource bundle manager
- ResourceBundleManager bundleMgr = PortletResourceBundleFactory.createResourceBundleManager(application.getContext().getClassLoader(), metaData.getLanguages());
-
// Portlet config object
- PortletConfig config = new PortletConfigImpl(
- metaData.getName(),
- application.getPortletContext(),
- initParameters,
- bundleMgr);
+ PortletConfig config = new PortletConfigImpl(application.getPortletContext(), info, bundleManager);
- // Create meta data
- PortletInfo info = application.getPortletInfoFactory().createPortletInfo(application.getContext(), metaData, jbossMetaData, bundleMgr);
-
// Finally initialize the porlet instance
try
{
@@ -236,8 +190,6 @@
// We are safe, update state
this.portlet = portlet;
this.config = config;
- this.securityRoleRefsMap = Collections.unmodifiableMap(securityRoleRefsMap);
- this.info = info;
this.started = true;
// Let invocation flow in
@@ -295,7 +247,6 @@
preferencesValidator = null;
className = null;
portlet = null;
- securityRoleRefsMap = null;
config = null;
userDataConstraints = null;
info = null;
@@ -312,11 +263,6 @@
return portlet;
}
- public Map getSecurityRoleRefsMap()
- {
- return securityRoleRefsMap;
- }
-
public PortletApplication getApplication()
{
return application;
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletInfoFactoryImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletInfoFactoryImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletInfoFactoryImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.container.PortletApplicationContext;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletInfoFactory;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-import org.jboss.portal.common.i18n.ResourceBundleManager;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletInfoFactoryImpl implements PortletInfoFactory
-{
- public PortletInfo createPortletInfo(PortletApplicationContext portletApplicationContext, PortletMetaData portletMD, JBossPortletMetaData jbossPortletMD, ResourceBundleManager resourceBundleManager)
- {
- return new ContainerPortletInfo(portletApplicationContext, portletMD, jbossPortletMD, resourceBundleManager);
- }
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.impl.metadata.UserAttributeMetaData;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.container.PortletContainer;
@@ -77,18 +77,18 @@
}
if (PortletRequest.USER_INFO.equals(name))
{
- Map infos = userContext.getInformations();
+ Map<String, String> infos = userContext.getInformations();
//
if (infos != null)
{
// Get portlet application metadata
PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getApplication();
- PortletApplicationMetaData pamd = portletApp.getMetaData();
- Map uaMD = pamd.getUserAttributes();
+ PortletApplication10MetaData pamd = portletApp.getMetaData();
+ Map<String, UserAttributeMetaData> uaMD = pamd.getUserAttributes();
// Clone the map
- infos = new HashMap(infos);
+ infos = new HashMap<String, String>(infos);
// Keep only what is of interest with respect to what the portlet app defines
infos.keySet().retainAll(uaMD.keySet());
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -26,12 +26,9 @@
import org.jboss.portal.common.i18n.ParentChildResourceBundle;
import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.common.i18n.ResourceBundleFactory;
-import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
-import org.jboss.portal.portlet.impl.jsr168.info.InfoBundle;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
-import java.util.Iterator;
import java.util.Locale;
-import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
@@ -44,66 +41,53 @@
public class PortletResourceBundleFactory implements ResourceBundleFactory
{
- public static ResourceBundleManager createResourceBundleManager(ClassLoader classLoader, LanguagesMetaData metaData)
+ public static ResourceBundleManager createResourceBundleManager(ResourceBundleManager bundleMgr, ContainerPortletInfo containerInfo)
{
- if (classLoader == null)
+ if (bundleMgr == null)
{
throw new IllegalArgumentException("Need a non null classloader");
}
- if (metaData == null)
+ if (containerInfo == null)
{
throw new IllegalArgumentException("Need non null meta data");
}
// Create factory
- PortletResourceBundleFactory factory = new PortletResourceBundleFactory(classLoader, metaData);
+ PortletResourceBundleFactory factory = new PortletResourceBundleFactory(bundleMgr, containerInfo);
// Create manager
ResourceBundleManager manager = new ResourceBundleManager(EmptyResourceBundle.INSTANCE, factory);
// Preload declared locales
- for (Iterator i = metaData.getSupportedLocales().iterator();i.hasNext();)
- {
- Locale locale = (Locale)i.next();
- manager.getResourceBundle(locale);
- }
+// for (Iterator i = metaData.getSupportedLocales().iterator();i.hasNext();)
+// {
+// Locale locale = (Locale)i.next();
+// manager.getResourceBundle(locale);
+// }
//
return manager;
}
/** The class loader to load resource bundle from. */
- private final ClassLoader classLoader;
+ private final ResourceBundleManager bundleMgr;
- /** The base name of the resource bundle. */
- private final String baseName;
+ private final ResourceBundle infoBundle;
- /** */
- private ResourceBundle infoBundle;
-
- public PortletResourceBundleFactory(ClassLoader classLoader, LanguagesMetaData metaData)
+ public PortletResourceBundleFactory(ResourceBundleManager bundleMgr, ContainerPortletInfo containerInfo)
{
- if (classLoader == null)
+ if (bundleMgr == null)
{
throw new IllegalArgumentException("Need a non null classloader");
}
- if (metaData == null)
+ if (containerInfo == null)
{
throw new IllegalArgumentException("Need non null meta data");
}
- this.classLoader = classLoader;
- this.baseName = metaData.getResourceBundle();
- // Get the resource bundle containing the portlet info
- LanguagesMetaData.InfoMetaData infoMD = metaData.getInfo();
- if (infoMD != null)
- {
- infoBundle = new InfoBundle(infoMD);
- }
- else
- {
- infoBundle = EmptyResourceBundle.INSTANCE;
- }
+ //
+ this.bundleMgr = bundleMgr;
+ this.infoBundle = new InlineBundle(containerInfo);
}
public ResourceBundle getBundle(Locale locale)
@@ -114,29 +98,17 @@
}
//
- ResourceBundle bundle;
+ ResourceBundle bundle = bundleMgr.getResourceBundle(locale);
- //
- if (baseName == null)
+ if (bundle == null)
{
bundle = infoBundle;
+ // log.warn("Bundle " + baseName + " for locale " + locale + " not found");
}
else
{
- try
- {
- bundle = ResourceBundle.getBundle(baseName, locale, classLoader);
- if (infoBundle != null)
- {
- bundle = new ParentChildResourceBundle(infoBundle, bundle);
- }
- // log.debug("Created bundle " + baseName + " for locale " + locale);
- }
- catch (MissingResourceException e)
- {
- // log.warn("Bundle " + baseName + " for locale " + locale + " not found");
- bundle = infoBundle;
- }
+ bundle = new ParentChildResourceBundle(infoBundle, bundle);
+ // log.debug("Created bundle " + baseName + " for locale " + locale);
}
//
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/SimpleResourceBundleFactory.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/SimpleResourceBundleFactory.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/SimpleResourceBundleFactory.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.common.i18n.ResourceBundleFactory;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SimpleResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** . */
+ private final ClassLoader classLoader;
+
+ /** . */
+ private final String baseName;
+
+ public SimpleResourceBundleFactory(ClassLoader classLoader, String baseName)
+ {
+ this.classLoader = classLoader;
+ this.baseName = baseName;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (baseName != null)
+ {
+ try
+ {
+ return ResourceBundle.getBundle(baseName, locale, classLoader);
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -23,13 +23,13 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.common.i18n.ResourceBundleManager;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Locale;
-import java.util.Map;
import java.util.ResourceBundle;
/**
@@ -39,25 +39,20 @@
public class PortletConfigImpl implements PortletConfig
{
- private String portletName;
private PortletContext portletContext;
- private Map initParameters;
+ private ContainerPortletInfo info;
private ResourceBundleManager bundleMgr;
- public PortletConfigImpl(String portletName,
- PortletContext portletContext,
- Map initParameters,
- ResourceBundleManager bundleMgr)
+ public PortletConfigImpl(PortletContext portletContext, ContainerPortletInfo info, ResourceBundleManager bundleMgr)
{
- this.portletName = portletName;
this.portletContext = portletContext;
- this.initParameters = initParameters;
+ this.info = info;
this.bundleMgr = bundleMgr;
}
public String getPortletName()
{
- return portletName;
+ return info.getName();
}
public PortletContext getPortletContext()
@@ -77,11 +72,11 @@
{
throw new IllegalArgumentException("name must not be null");
}
- return (String)initParameters.get(s);
+ return info.getInitParameter(s);
}
public Enumeration getInitParameterNames()
{
- return Collections.enumeration(initParameters.keySet());
+ return Collections.enumeration(info.getInitParameterNames());
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -27,9 +27,9 @@
import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyContext;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferenceInfo;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.info.PreferenceInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferenceInfo;
import javax.portlet.PortletPreferences;
import javax.portlet.PreferencesValidator;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -30,7 +30,8 @@
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.impl.jsr168.PortletRequestAttributes;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.info.ContainerSecurityInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.spi.RequestContext;
import org.jboss.portal.portlet.spi.SecurityContext;
@@ -107,7 +108,7 @@
int mode = this instanceof RenderRequest ? PortletPreferencesImpl.RENDER : PortletPreferencesImpl.ACTION;
PropertyContext prefs = (PropertyContext)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, PropertyContext.PREFERENCES_ATTRIBUTE);
PreferencesValidator validator = container.getPreferencesValidator();
- ContainerPreferencesInfo containerPrefs = (ContainerPreferencesInfo)container.getInfo().getPreferences();
+ ContainerPreferencesInfo containerPrefs = container.getInfo().getPreferences();
this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator, mode);
}
@@ -301,13 +302,15 @@
public boolean isUserInRole(String roleName)
{
// Get the map role name to role link
- Map securityRoleRefsMap = container.getSecurityRoleRefsMap();
+ ContainerSecurityInfo securityRoleRefsMap = container.getInfo().getSecurity();
// Process the role link
- String roleLink = (String)securityRoleRefsMap.get(roleName);
+ String roleLink = securityRoleRefsMap.getRoleRef(roleName);
+
+ //
if (roleLink == null)
{
- if (securityRoleRefsMap.containsKey(roleName))
+ if (securityRoleRefsMap.containsRoleRef(roleName))
{
// The role name exist without a role link value
return securityContext.isUserInRole(roleName);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletInfoFactory.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -26,7 +26,6 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.common.i18n.ResourceBundleManager;
/**
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/info/CacheInfoSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/info/CacheInfoSupport.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/info/CacheInfoSupport.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.support.info;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerCacheInfo;
import org.jboss.portal.portlet.info.CacheInfo;
/**
@@ -35,18 +34,14 @@
/** . */
private int expirationTimeMillis;
- /** . */
- private int referenceType;
-
- public CacheInfoSupport(int expirationTimeMillis, int referenceType)
+ public CacheInfoSupport(int expirationTimeMillis)
{
this.expirationTimeMillis = expirationTimeMillis;
- this.referenceType = referenceType;
}
public CacheInfoSupport()
{
- this(0, ContainerCacheInfo.REF_STRONG);
+ this(0);
}
public int getExpirationSecs()
@@ -58,14 +53,4 @@
{
this.expirationTimeMillis = expirationTimeMillis;
}
-
- public int getReferenceType()
- {
- return referenceType;
- }
-
- public void setReferenceType(int referenceType)
- {
- this.referenceType = referenceType;
- }
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -24,9 +24,9 @@
package org.jboss.portal.test.portlet;
import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.impl.jsr168.info.ContentTypes;
import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypeMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypesMetaData;
+import org.jboss.portal.portlet.impl.info.ContainerCapabilitiesInfo;
import java.util.Collection;
@@ -38,14 +38,14 @@
* @version $Revision: 6720 $
* @since 2.4
*/
-@Test
+// @Test
public class ContentTypesTestCase
{
- private ContentTypes contentTypes;
+ private ContainerCapabilitiesInfo contentTypes;
public ContentTypesTestCase()
{
- contentTypes = new ContentTypes();
+ contentTypes = new ContainerCapabilitiesInfo();
ContentTypesMetaData md = new ContentTypesMetaData();
md.addContentType(new ContentTypeMetaData("text/html", new Mode[]{Mode.EDIT, Mode.HELP, Mode.VIEW}));
md.addContentType(new ContentTypeMetaData("text/xml", new Mode[]{Mode.VIEW}));
@@ -55,8 +55,6 @@
// should this be allowed?
md.addContentType(new ContentTypeMetaData("pipo/pipo", new Mode[]{}));
-
- contentTypes.setMetadata(md);
}
@Test
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -23,8 +23,8 @@
package org.jboss.portal.test.portlet.info;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
-import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import static org.jboss.unit.api.Assert.*;
Modified: modules/portlet/trunk/test/pom.xml
===================================================================
--- modules/portlet/trunk/test/pom.xml 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/test/pom.xml 2008-01-09 15:28:51 UTC (rev 9464)
@@ -338,9 +338,8 @@
<property name="dependency.portal-portlet-tests.test-jar" value="${maven.dependency.org.jboss.portal.portlet.portlet.tests.test-jar.path}"/>
<property name="dependency.cargo-core-uberjar.jar" value="${maven.dependency.cargo.cargo-core-uberjar.jar.path}"/>
<property name="dependency.cargo-ant.jar" value="${maven.dependency.cargo.cargo-ant.jar.path}"/>
+ <property name="dependency.jaxb-api.jar" value="${maven.dependency.javax.xml.bind.jaxb-api.jar.path}"/>
- <echo message="common: ${dependency.portal-portlet-tests.test-jar}"/>
-
<ant antfile="${basedir}/src/test/build.xml">
<target name="tests"/>
</ant>
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-09 15:28:51 UTC (rev 9464)
@@ -324,9 +324,10 @@
<path id="mc.portal-portlet">
<pathelement path="${dependency.portal-portlet.jar}"/>
</path>
+ <path id="mc.jaxb-api">
+ <pathelement path="${dependency.jaxb-api.jar}"/>
+ </path>
-
-
<!-- JBoss 4.2 portlet-test.war -->
<copy todir="${target}/test-classes/jboss-4.2/portlet-test-war/WEB-INF/lib" flatten="true">
@@ -383,6 +384,7 @@
<path refid="mc.jboss_xb"/>
<path refid="mc.jboss_aop"/>
<path refid="mc.jboss_microcontainer"/>
+ <path refid="mc.jaxb-api"/>
</copy>
<mkdir dir="${test.temp.lib}/tomcat-6.0"/>
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployer.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -27,8 +27,12 @@
import org.jboss.portal.web.WebAppLifeCycleEvent;
import org.jboss.portal.web.WebApp;
import org.jboss.portal.web.ServletContainer;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
-import org.jboss.portal.portlet.test.deployment.PortletApplicationMetaDataFactory;
+import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_168_NS;
+import static org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants.PORTLET_JSR_286_NS;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication20MetaData;
+import org.jboss.portal.portlet.test.metadata.impl.AnnotationPortletApplication10MetaData;
+import org.jboss.portal.portlet.test.metadata.factory.PortletApplicationModelFactory;
import org.jboss.portal.portlet.test.deployment.ValueTrimmingFilter;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletContainer;
@@ -41,6 +45,8 @@
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
import org.apache.log4j.Logger;
import java.util.Map;
@@ -56,6 +62,31 @@
public class PortletApplicationDeployer implements WebAppListener, KernelControllerContextAware
{
+ /** The schema resolver factory. */
+ private static SingletonSchemaResolverFactory factory;
+
+ /** The schema resolver. */
+ private static DefaultSchemaResolver resolver;
+
+ static
+ {
+ try
+ {
+ factory = SingletonSchemaResolverFactory.getInstance();
+ resolver = (DefaultSchemaResolver) factory.getSchemaBindingResolver();
+
+ /** SchemaResolver */
+ resolver.addSchemaLocation(PORTLET_JSR_168_NS, "portlet-app_1_0.xsd");
+ resolver.addSchemaLocation(PORTLET_JSR_286_NS, "portlet-app_2_0.xsd");
+ resolver.addClassBinding(PORTLET_JSR_286_NS, AnnotationPortletApplication20MetaData.class);
+ resolver.addClassBinding(PORTLET_JSR_168_NS, AnnotationPortletApplication10MetaData.class);
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+
/** . */
private Logger log = Logger.getLogger(PortletApplicationDeployer.class);
@@ -115,13 +146,25 @@
if (event instanceof WebAppLifeCycleEvent)
{
WebAppLifeCycleEvent lifeCycleEvent = (WebAppLifeCycleEvent)event;
+ String cp = event.getWebApp().getContextPath();
switch(lifeCycleEvent.getType())
{
case WebAppLifeCycleEvent.ADDED:
+ log.debug("Going to install war file" + cp);
add(event.getWebApp());
+ log.debug("Installed war file" + cp);
break;
case WebAppLifeCycleEvent.REMOVED:
- remove(event.getWebApp());
+ try
+ {
+ log.debug("Going to uninstall war file" + cp);
+ remove(event.getWebApp());
+ log.debug("Uninstalled war file" + cp);
+ }
+ catch (Throwable e)
+ {
+ log.error("Uninstalled war file " + cp + " with an error", e);
+ }
break;
}
}
@@ -133,7 +176,7 @@
webApp.getServletContext().setAttribute("TestDriverServer", driver);
//
- PortletApplicationMetaData metaData = buildPortletApplicationMetaData(webApp);
+ PortletApplication10MetaData metaData = buildPortletApplicationMetaData(webApp);
if (metaData != null)
{
ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
@@ -202,7 +245,7 @@
classLoader = null;
}
- private PortletApplicationMetaData buildPortletApplicationMetaData(WebApp webApp)
+ private PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
{
try
{
@@ -213,11 +256,22 @@
try
{
in = IOTools.safeBufferedWrapper(url.openStream());
- PortletApplicationMetaDataFactory factory = new PortletApplicationMetaDataFactory();
+
+ // Validate
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- PortletApplicationMetaData portletAppMD = (PortletApplicationMetaData)unmarshaller.unmarshal(in, new ValueTrimmingFilter(factory), null);
- portletAppMD.setId(webApp.getContextPath());
- return portletAppMD;
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(false);
+ unmarshaller.setValidation(false);
+
+ //
+ PortletApplicationModelFactory factory = new PortletApplicationModelFactory();
+
+ // Unmarshal
+ PortletApplication10MetaData portletApplicationMD = (PortletApplication10MetaData)unmarshaller.unmarshal(in, new ValueTrimmingFilter(factory), null);
+ portletApplicationMD.setId(webApp.getContextPath());
+
+ //
+ return portletApplicationMD;
}
finally
{
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-01-09 15:28:51 UTC (rev 9464)
@@ -25,15 +25,18 @@
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.impl.jsr168.SimpleResourceBundleFactory;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
-import org.jboss.portal.portlet.impl.jsr168.spi.PortletInfoFactory;
+import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
+import org.jboss.portal.portlet.impl.metadata.portlet.PortletMetaData;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.info.ContainerPortletInfoBuilder;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
import org.jboss.portal.web.WebApp;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.i18n.ResourceBundleFactory;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
@@ -53,8 +56,9 @@
import javax.servlet.ServletContext;
import java.util.List;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
import java.util.Iterator;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -73,49 +77,65 @@
private final WebApp webApp;
/** . */
- private final PortletApplicationMetaData metaData;
+ private final PortletApplication10MetaData metaData;
/** . */
+ private final LinkedList<String> installed;
+
+ /** . */
private KernelControllerContext portletApplicationControllerContext;
/** . */
- private List portletContainerControllerContexts = new ArrayList();
+ private List<KernelControllerContext> portletContainerControllerContexts = new ArrayList<KernelControllerContext>();
- public PortletApplicationDeployment(Kernel kernel, WebApp webApp, PortletApplicationMetaData metaData)
+ public PortletApplicationDeployment(Kernel kernel, WebApp webApp, PortletApplication10MetaData metaData)
{
this.kernel = kernel;
this.webApp = webApp;
this.metaData = metaData;
this.log = Logger.getLogger(PortletApplicationDeployment.class + "." + webApp.getContextPath().replace('.', '_'));
+ this.installed = new LinkedList<String>();
}
void start()
{
- String id = "PortletApplication[" + webApp.getContextPath() + "]";
log.debug("Starting installation");
//
KernelController controller = kernel.getController();
//
- for (Iterator i = metaData.getPortlets().iterator(); i.hasNext();)
+ String portletApplicationId = "PortletApplication[" + webApp.getContextPath() + "]";
+
+ //
+ for (PortletMetaData portletMetaData : metaData.getPortlets().values())
{
- PortletMetaData portletMetaData = (PortletMetaData)i.next();
- String portletContainerId = "PortletContainer[" + webApp.getContextPath() + "," + portletMetaData.getName() + "]";
+ // Create resource bundle manager
+ String baseName = portletMetaData.getResourceBundle();
+ ResourceBundleFactory rbf = new SimpleResourceBundleFactory(webApp.getClassLoader(), baseName);
+ ResourceBundleManager bundleMgr = new ResourceBundleManager(null, rbf);
+
+ // Build container info
+ ContainerPortletInfo containerInfo = new ContainerPortletInfoBuilder(portletMetaData, bundleMgr).build();
+
+ //
+ String portletContainerId = "PortletContainer[" + webApp.getContextPath() + "," + portletMetaData.getPortletName() + "]";
+
+ //
AbstractBeanMetaData bmd = new AbstractBeanMetaData(portletContainerId, PortletContainerImpl.class.getName());
AbstractConstructorMetaData ctormd = new AbstractConstructorMetaData();
- ctormd.setParameters(Tools.toList((ParameterMetaData)new AbstractParameterMetaData(PortletMetaData.class.getName(), portletMetaData), new AbstractParameterMetaData(JBossPortletMetaData.class.getName(), (Object)null)));
+ ctormd.setParameters(Tools.toList((ParameterMetaData)new AbstractParameterMetaData(ContainerPortletInfo.class.getName(), containerInfo), new AbstractParameterMetaData(ResourceBundleManager.class.getName(), bundleMgr)));
bmd.setConstructor(ctormd);
bmd.setStart(new AbstractLifecycleMetaData("start"));
bmd.setStop(new AbstractLifecycleMetaData("stop"));
- bmd.setProperties(Collections.singleton((PropertyMetaData)new AbstractPropertyMetaData("application", new AbstractDependencyValueMetaData(id))));
+ bmd.setProperties(Collections.singleton((PropertyMetaData)new AbstractPropertyMetaData("application", new AbstractDependencyValueMetaData(portletApplicationId))));
AbstractInstallMetaData deployerinstallmd = new AbstractInstallMetaData();
deployerinstallmd.setBean("PortletApplicationDeployer");
deployerinstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
deployerinstallmd.setMethodName("installPortletContainer");
AbstractInstallMetaData applicationinstallmd = new AbstractInstallMetaData();
- applicationinstallmd.setBean(id);
+ applicationinstallmd.setBean(portletApplicationId);
applicationinstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
applicationinstallmd.setMethodName("addContainer");
bmd.setInstalls(Tools.toList((InstallMetaData)deployerinstallmd, applicationinstallmd));
@@ -124,30 +144,30 @@
deployeruninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
deployeruninstallmd.setMethodName("uninstallPortletContainer");
AbstractInstallMetaData applicationuninstallmd = new AbstractInstallMetaData();
- applicationuninstallmd.setBean(id);
+ applicationuninstallmd.setBean(portletApplicationId);
applicationuninstallmd.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(new ThisValueMetaData())));
applicationuninstallmd.setMethodName("removeContainer");
bmd.setUninstalls(Tools.toList((InstallMetaData)deployeruninstallmd, applicationuninstallmd));
try
{
+ installed.addFirst(portletContainerId);
KernelControllerContext portletContainerControllerContext = kernel.getController().install(bmd);
portletContainerControllerContexts.add(portletContainerControllerContext);
}
catch (Throwable t)
{
- log.debug("Cannot install portlet container " + portletMetaData.getName() + " produced an error", t);
+ log.debug("Cannot install portlet container " + portletMetaData.getPortletName() + " produced an error", t);
}
}
//
- AbstractBeanMetaData bmd = new AbstractBeanMetaData(id, PortletApplicationImpl.class.getName());
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(portletApplicationId, PortletApplicationImpl.class.getName());
AbstractConstructorMetaData ctormd = new AbstractConstructorMetaData();
ctormd.setParameters(Tools.toList(
- (ParameterMetaData)new AbstractParameterMetaData(PortletApplicationMetaData.class.getName(), metaData),
+ (ParameterMetaData)new AbstractParameterMetaData(PortletApplication10MetaData.class.getName(), metaData),
new AbstractParameterMetaData(JBossApplicationMetaData.class.getName(), (Object)null),
new AbstractParameterMetaData(PortletApplicationContext.class.getName(), this),
- new AbstractParameterMetaData(PortletAPIFactory.class.getName(), new AbstractDependencyValueMetaData("PortletAPIFactory")),
- new AbstractParameterMetaData(PortletInfoFactory.class.getName(), new AbstractDependencyValueMetaData("PortletInfoFactory"))));
+ new AbstractParameterMetaData(PortletAPIFactory.class.getName(), new AbstractDependencyValueMetaData("PortletAPIFactory"))));
bmd.setConstructor(ctormd);
bmd.setStart(new AbstractLifecycleMetaData("start"));
bmd.setStop(new AbstractLifecycleMetaData("stop"));
@@ -165,6 +185,7 @@
//
try
{
+ installed.addFirst(portletApplicationId);
portletApplicationControllerContext = controller.install(bmd);
}
catch (Throwable throwable)
@@ -173,9 +194,8 @@
}
logBeanFailure(portletApplicationControllerContext);
- for (Iterator i = portletContainerControllerContexts.iterator(); i.hasNext();)
+ for (KernelControllerContext portletContainerControllerContext : portletContainerControllerContexts)
{
- KernelControllerContext portletContainerControllerContext = (KernelControllerContext)i.next();
logBeanFailure(portletContainerControllerContext);
}
}
@@ -192,17 +212,28 @@
void stop()
{
log.debug("Stopping installation");
- if (portletApplicationControllerContext != null)
+
+ KernelController controller = kernel.getController();
+
+ for (Iterator<String> i = installed.iterator();i.hasNext();)
{
- KernelController controller = kernel.getController();
- controller.uninstall(portletApplicationControllerContext.getName());
- portletApplicationControllerContext = null;
- for (Iterator i = portletContainerControllerContexts.iterator(); i.hasNext();)
+ String beanName = i.next();
+ i.remove();
+ try
{
- KernelControllerContext portletContainerControllerContext = (KernelControllerContext)i.next();
- controller.uninstall(portletContainerControllerContext.getName());
+ controller.uninstall(beanName);
}
+ catch (Throwable t)
+ {
+ // MC throws Error .... need to catch them here
+
+ log.error("Bean " + beanName + " undeployment threw something", t);
+ }
}
+
+ //
+ portletApplicationControllerContext = null;
+ portletContainerControllerContexts = null;
}
public ServletContext getServletContext()
Modified: modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-01-09 15:28:51 UTC (rev 9464)
@@ -49,9 +49,6 @@
<bean name="PortletAPIFactory" class="org.jboss.portal.portlet.impl.jsr168.PortletAPIFactoryImpl">
</bean>
- <bean name="PortletInfoFactory" class="org.jboss.portal.portlet.impl.jsr168.PortletInfoFactoryImpl">
- </bean>
-
<!-- The ServletContainerFactory -->
<bean name="ServletContainerFactory" class="org.jboss.portal.web.impl.DefaultServletContainerFactory">
<constructor factoryClass="org.jboss.portal.web.impl.DefaultServletContainerFactory" factoryMethod="getInstance"/>
Modified: modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml 2008-01-09 15:09:53 UTC (rev 9463)
+++ modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml 2008-01-09 15:28:51 UTC (rev 9464)
@@ -5,9 +5,6 @@
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
<test>
- <class name="org.jboss.portal.portlet.test.deployment.UnmarshallerTestCase"/>
- </test>
- <test>
<class name="org.jboss.portal.portlet.test.url.DecoderTestCase">
</class>
</test>
18 years, 3 months
JBoss Portal SVN: r9463 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-09 10:09:53 -0500 (Wed, 09 Jan 2008)
New Revision: 9463
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/value/StringValue.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
Log:
added List<String> constructor in StringValue
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/value/StringValue.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/value/StringValue.java 2008-01-09 01:17:25 UTC (rev 9462)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/value/StringValue.java 2008-01-09 15:09:53 UTC (rev 9463)
@@ -22,7 +22,9 @@
******************************************************************************/
package org.jboss.portal.common.value;
+import java.util.List;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5451 $
@@ -55,6 +57,15 @@
this.values = values;
}
+ public StringValue(List<String> values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values.toArray(new String[values.size()]);
+ }
+
public boolean isInstanceOf(Class clazz)
{
return clazz != null && clazz.isAssignableFrom(String.class);
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java 2008-01-09 01:17:25 UTC (rev 9462)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java 2008-01-09 15:09:53 UTC (rev 9463)
@@ -27,7 +27,11 @@
import org.jboss.portal.common.value.Value;
import org.jboss.portal.common.value.IntegerValue;
import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.util.Tools;
+import java.util.ArrayList;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5451 $
@@ -192,6 +196,16 @@
assertEquals(d, f);
}
+ public void testStringValueConstructor()
+ {
+ ExtendedAssert.assertEquals(new String[0], new StringValue(new ArrayList<String>()).asStringArray());
+ ExtendedAssert.assertEquals(new String[]{null}, new StringValue(Tools.toList((String)null)).asStringArray());
+ ExtendedAssert.assertEquals(new String[]{"foo"}, new StringValue(Tools.toList("foo")).asStringArray());
+ ExtendedAssert.assertEquals(new String[]{"foo","bar"}, new StringValue(Tools.toList("foo","bar")).asStringArray());
+ ExtendedAssert.assertEquals(new String[]{"foo",null}, new StringValue(Tools.toList("foo",null)).asStringArray());
+ ExtendedAssert.assertEquals(new String[]{null,"bar"}, new StringValue(Tools.toList(null,"bar")).asStringArray());
+ }
+
public void testEqualsOnStringValues()
{
assertEquals(new StringValue(), new StringValue());
18 years, 3 months
JBoss Portal SVN: r9462 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-08 20:17:25 -0500 (Tue, 08 Jan 2008)
New Revision: 9462
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/wsrp.xml
Log:
- JBPORTAL-1835: Updated documentation with references to XML Schemas.
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/wsrp.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/wsrp.xml 2008-01-09 01:10:54 UTC (rev 9461)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/wsrp.xml 2008-01-09 01:17:25 UTC (rev 9462)
@@ -325,7 +325,7 @@
<title>Using a WSRP Producer XML descriptor</title>
<para>We will create a <filename>public-bea-wsrp.xml</filename> descriptor. Note that the actual name does not
- matter as long as it ends with<filename>-wsrp.xml</filename>:
+ matter as long as it ends with <filename>-wsrp.xml</filename>:
<example>
<programlisting><![CDATA[
<?xml version='1.0' encoding='UTF-8' ?>
@@ -351,6 +351,10 @@
different elements later. Note for now the <literal>producer-id</literal> element with a
"<literal>bea</literal>" value. Put this file in the deploy directory and start the server (with JBoss
Portal and its WSRP service deployed).
+ <note>A DTD and an XML Schema for WSRP Producer XML descriptors are available in
+ <filename>jboss-portal.sar/portal-wsrp.sar/dtd/jboss-wsrp-consumer_2_6.dtd</filename> and
+ <filename>jboss-portal.sar/portal-wsrp.sar/xsd/jboss-wsrp-consumer_2_6.xsd</filename>
+ </note>
</para>
</sect3>
@@ -407,11 +411,10 @@
A WSRP Producer descriptor is an XML file which name ends in <filename>-wsrp.xml</filename> and
which can be dropped in the deploy directory of the JBoss application server or nested in .sar files. It is
possible to configure access to several different producers within a single descriptor or use one file per
- producer, depending on your needs. The DTD for the WSRP Producer descriptor format can be found at
- <filename>portal-wsrp.sar/dtd/jboss-wsrp-consumer_2_6.dtd</filename>.
+ producer, depending on your needs. An XML Schema for the WSRP Producer descriptor format can be found at
+ <filename>jboss-portal.sar/portal-wsrp.sar/xsd/jboss-wsrp-consumer_2_6.xsd</filename>, while a (legacy) DTD
+ can be found at <filename>jboss-portal.sar/portal-wsrp.sar/dtd/jboss-wsrp-consumer_2_6.dtd</filename>.
- <!--TODO: REPLACE WITH REFERENCE TO SCHEMA INSTEAD.-->
-
<note>It is important to note how WSRP Producer descriptors are processed. They are read the first time the
WSRP service starts and the associated information is then put in the Portal database. Subsequent launch
of the WSRP service will use the database-stored information for all producers which identifier is
@@ -828,7 +831,10 @@
You can configure the behavior of Portal's WSRP Producer by using the WSRP administration interface, which
is the preferred way, or by editing the <filename>conf/config.xml</filename> file found in
<filename>portal-wsrp.sar</filename>. Several aspects can be modified with respects to whether
- registration is required for consumers to access the Producer's services.
+ registration is required for consumers to access the Producer's services. An XML Schema for the configuration
+ format is available at <filename>jboss-portal.sar/portal-wsrp.sar/xsd/jboss-wsrp-producer_2_6.xsd</filename>,
+ while a (legacy) DTD is available at
+ <filename>jboss-portal.sar/portal-wsrp.sar/dtd/jboss-wsrp-producer_2_6.dtd</filename>
</para>
</sect2>
<sect2>
18 years, 3 months
JBoss Portal SVN: r9461 - in branches/JBoss_Portal_Branch_2_6/wsrp/src: resources/portal-wsrp-sar and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-08 20:10:54 -0500 (Tue, 08 Jan 2008)
New Revision: 9461
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml
Log:
- JBPORTAL-1835:
+ Added XSD to resolver.
+ Added schemaLocation to default files.
+ Fixed addition of schemaLocation attribute via marshaller in ProducerConfigurationServiceImpl (though at this point in time, the method doesn't do anything in XB).
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2008-01-08 23:59:27 UTC (rev 9460)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2008-01-09 01:10:54 UTC (rev 9461)
@@ -194,7 +194,8 @@
// add schema location by declaring xsi namespace and adding xsi:schemaLocation attribute
marshaller.declareNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
- marshaller.addAttribute("xsi", "schemaLocation", "string", "urn:jboss:portal:wsrp:producer:v2_6");
+ marshaller.addAttribute("xsi", "schemaLocation", "string",
+ "urn:jboss:portal:wsrp:producer:v2_6 http://www.jboss.org/portal/xsd/jboss-wsrp-producer_2_6.xsd");
// create an instance of Object Model Provider
ObjectModelProvider provider = new ProducerConfigurationProvider();
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2008-01-08 23:59:27 UTC (rev 9460)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2008-01-09 01:10:54 UTC (rev 9461)
@@ -81,6 +81,8 @@
<entry
key="-//JBoss Portal//DTD WSRP Local Producer Configuration 2.6//EN">dtd/jboss-wsrp-producer_2_6.dtd
</entry>
+ <entry key="urn:jboss:portal:wsrp:consumer:v2_6">/xsd/jboss-wsrp-consumer_2_6.xsd</entry>
+ <entry key="urn:jboss:portal:wsrp:producer:v2_6">/xsd/jboss-wsrp-consumer_2_6.xsd</entry>
</properties>
</attribute>
</mbean>
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml 2008-01-08 23:59:27 UTC (rev 9460)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml 2008-01-09 01:10:54 UTC (rev 9461)
@@ -27,7 +27,9 @@
-->
<!-- Configuration using registration with default registration property validator. -->
-<producer-configuration xmlns="urn:jboss:portal:wsrp:producer:v2_6">
+<producer-configuration xmlns="urn:jboss:portal:wsrp:producer:v2_6"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:portal:wsrp:producer:v2_6 http://www.jboss.org/portal/xsd/jboss-wsrp-producer_2_6.xsd">
<registration-configuration fullServiceDescriptionRequiresRegistration="true">
<registration-property-validator>org.jboss.portal.registration.policies.DefaultRegistrationPropertyValidator
</registration-property-validator>
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml 2008-01-08 23:59:27 UTC (rev 9460)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml 2008-01-09 01:10:54 UTC (rev 9461)
@@ -26,7 +26,8 @@
<!--<!DOCTYPE deployments PUBLIC "-//JBoss Portal//DTD WSRP Remote Producer Configuration 2.6//EN"
"http://www.jboss.org/portal/dtd/jboss-wsrp-consumer_2_6.dtd">-->
-<deployments xmlns="urn:jboss:portal:wsrp:consumer:v2_6">
+<deployments xmlns="urn:jboss:portal:wsrp:consumer:v2_6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:portal:wsrp:consumer:v2_6 http://www.jboss.org/portal/xsd/jboss-wsrp-consumer_2_6.xsd">
<deployment>
<wsrp-producer id="self" expiration-cache="300">
<!--
18 years, 3 months
JBoss Portal SVN: r9460 - in branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar: conf/producer and 1 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-08 18:59:27 -0500 (Tue, 08 Jan 2008)
New Revision: 9460
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-consumer_2_6.xsd
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-producer_2_6.xsd
Log:
- JBPORTAL-1835: Created XML schema for -wsrp.xml format.
- Use elementFormDefault="qualified" for easier use in instance documents (the only thing that is needed is an anonymous namespace and the schema location).
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml 2008-01-08 16:07:37 UTC (rev 9459)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/conf/producer/config.xml 2008-01-08 23:59:27 UTC (rev 9460)
@@ -21,11 +21,13 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<!--
<!DOCTYPE producer-configuration PUBLIC "-//JBoss Portal//DTD WSRP Local Producer Configuration 2.6//EN"
"http://www.jboss.org/portal/dtd/jboss-wsrp-producer_2_6.dtd">
+-->
<!-- Configuration using registration with default registration property validator. -->
-<producer-configuration>
+<producer-configuration xmlns="urn:jboss:portal:wsrp:producer:v2_6">
<registration-configuration fullServiceDescriptionRequiresRegistration="true">
<registration-property-validator>org.jboss.portal.registration.policies.DefaultRegistrationPropertyValidator
</registration-property-validator>
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml 2008-01-08 16:07:37 UTC (rev 9459)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/default-wsrp.xml 2008-01-08 23:59:27 UTC (rev 9460)
@@ -23,10 +23,10 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-<!DOCTYPE deployments PUBLIC "-//JBoss Portal//DTD WSRP Remote Producer Configuration 2.6//EN"
- "http://www.jboss.org/portal/dtd/jboss-wsrp-consumer_2_6.dtd">
+<!--<!DOCTYPE deployments PUBLIC "-//JBoss Portal//DTD WSRP Remote Producer Configuration 2.6//EN"
+ "http://www.jboss.org/portal/dtd/jboss-wsrp-consumer_2_6.dtd">-->
-<deployments>
+<deployments xmlns="urn:jboss:portal:wsrp:consumer:v2_6">
<deployment>
<wsrp-producer id="self" expiration-cache="300">
<!--
Added: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-consumer_2_6.xsd
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-consumer_2_6.xsd (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-consumer_2_6.xsd 2008-01-08 23:59:27 UTC (rev 9460)
@@ -0,0 +1,194 @@
+<?xml version="1.0"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2007, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:portal:wsrp:consumer:v2_6"
+ xmlns="urn:jboss:portal:wsrp:consumer:v2_6"
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
+ xmlns:wcc="urn:jboss:portal:wsrp:consumer:v2_6"
+ elementFormDefault="qualified">
+
+ <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
+
+ <xs:element name="deployments">
+ <xs:annotation>
+ <xs:documentation>Root element. Contains deployment elements.</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="deployment" type="wcc:Deployment" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="Deployment">
+ <xs:annotation>
+ <xs:documentation>Deployment related information. As of Portal 2.6, the only deployment information relates to
+ WSRP remote producers.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="wsrp-producer" type="wcc:WSRPProducer" maxOccurs="1" minOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="WSRPProducer">
+ <xs:annotation>
+ <xs:documentation>Information on a remote WSRP producer identified by the mandatory id attribute.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:choice>
+ <xs:element name="endpoint-config" type="wcc:EndpointConfig">
+ <xs:annotation>
+ <xs:documentation>
+ WSRP endpoints configuration information by interface URL. Mutually exclusive with endpoint-wsdl-url.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="endpoint-wsdl-url" type="xs:anyURI">
+ <xs:annotation>
+ <xs:documentation>
+ The URL of the WSDL description of the producer's WSRP services. Mutally exclusive with endpoint-config.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:choice>
+ <xs:element name="registration-data" type="wcc:RegistrationData" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>
+ Container for registration information.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The producer identifier. This should be unique for a given Portal deployment. The identifier is used to
+ identify the portlet provider in the management interface.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="expiration-cache" type="wcc:cacheValue" use="required">
+ <xs:annotation>
+ <xs:documentation>The period of producer information (such as list of offered portlets) cache refreshing in seconds.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:simpleType name="cacheValue" id="cacheValue">
+ <xs:annotation>
+ <xs:documentation>
+ Type for cache information. Positive or null integer, allowing -1 as a value to indicate that cache should not
+ be used.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:integer">
+ <xs:minInclusive value="-1"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="EndpointConfig">
+ <xs:sequence>
+ <xs:element name="service-description-url" type="xs:anyURI">
+ <xs:annotation>
+ <xs:documentation>
+ The mandatory URL for the service description interface endpoint on the remote producer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="markup-url" type="xs:anyURI">
+ <xs:annotation>
+ <xs:documentation>
+ The madatory URL for the markup interface endpoint on the remote producer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="registration-url" type="xs:anyURI" minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ The optional URL for the registration interface endpoint on the remote producer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="portlet-management-url" type="xs:anyURI" minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ The optional URL for the portlet management interface endpoint on the remote producer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="RegistrationData">
+ <xs:sequence>
+ <xs:element name="consumer-name" type="xs:string" minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ An optional name (preferably unique) that identifies the Consumer. An example of such a name would be
+ the Consumer's URL. If no consumer-name is provided, one will be automatically generated by JBoss Portal.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="property" type="wcc:Property" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>
+ Optional registration properties required by the remote producer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Property">
+ <xs:annotation>
+ <xs:documentation>
+ Registration property.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="name" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Name of the property.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="lang" type="xs:language">
+ <xs:annotation>
+ <xs:documentation>
+ Language the property is in.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="value" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Value of the property.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-producer_2_6.xsd
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-producer_2_6.xsd 2008-01-08 16:07:37 UTC (rev 9459)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/portal-wsrp-sar/xsd/jboss-wsrp-producer_2_6.xsd 2008-01-08 23:59:27 UTC (rev 9460)
@@ -26,7 +26,7 @@
targetNamespace="urn:jboss:portal:wsrp:producer:v2_6"
xmlns="urn:jboss:portal:wsrp:producer:v2_6"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
- xmlns:wpc="urn:jboss:portal:wsrp:producer:v2_6">
+ xmlns:wpc="urn:jboss:portal:wsrp:producer:v2_6" elementFormDefault="qualified">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
18 years, 3 months
JBoss Portal SVN: r9459 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet and 2 other directories.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2008-01-08 11:07:37 -0500 (Tue, 08 Jan 2008)
New Revision: 9459
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/PortletModeAdapter.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/WindowStateAdapter.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/PortletModeMetaData.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/WindowStateMetaData.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/PortletTestEverythingTestCase.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java
Log:
- use Mode and WindowState instead of String
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/PortletModeAdapter.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/PortletModeAdapter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/PortletModeAdapter.java 2008-01-08 16:07:37 UTC (rev 9459)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.portlet.impl.metadata.adapter;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.jboss.portal.Mode;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PortletModeAdapter extends XmlAdapter<String, Mode>
+{
+
+ @Override
+ public String marshal(Mode mode) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Mode unmarshal(String name) throws Exception
+ {
+ return Mode.create(name);
+ }
+
+}
+
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/WindowStateAdapter.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/WindowStateAdapter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/adapter/WindowStateAdapter.java 2008-01-08 16:07:37 UTC (rev 9459)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.portlet.impl.metadata.adapter;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.jboss.portal.WindowState;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class WindowStateAdapter extends XmlAdapter<String, WindowState>
+{
+
+ @Override
+ public String marshal(WindowState arg0) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public WindowState unmarshal(String name) throws Exception
+ {
+ return WindowState.create(name);
+ }
+
+}
+
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/PortletModeMetaData.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/PortletModeMetaData.java 2008-01-08 16:06:39 UTC (rev 9458)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/PortletModeMetaData.java 2008-01-08 16:07:37 UTC (rev 9459)
@@ -24,7 +24,11 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.impl.metadata.adapter.PortletModeAdapter;
+
/**
* @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -35,15 +39,16 @@
{
/** The portlet mode */
- private String portletMode;
+ private Mode portletMode;
@XmlValue
- public String getPortletMode()
+ @XmlJavaTypeAdapter(PortletModeAdapter.class)
+ public Mode getPortletMode()
{
return portletMode;
}
- public void setPortletMode(String portletMode)
+ public void setPortletMode(Mode portletMode)
{
this.portletMode = portletMode;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/WindowStateMetaData.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/WindowStateMetaData.java 2008-01-08 16:06:39 UTC (rev 9458)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/portlet/WindowStateMetaData.java 2008-01-08 16:07:37 UTC (rev 9459)
@@ -24,7 +24,11 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.impl.metadata.adapter.WindowStateAdapter;
+
/**
* @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -34,15 +38,16 @@
{
/** The window state */
- private String windowState;
+ private WindowState windowState;
@XmlValue
- public String getWindowState()
+ @XmlJavaTypeAdapter(WindowStateAdapter.class)
+ public WindowState getWindowState()
{
return windowState;
}
- public void setWindowState(String windowState)
+ public void setWindowState(WindowState windowState)
{
this.windowState = windowState;
}
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/PortletTestEverythingTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/PortletTestEverythingTestCase.java 2008-01-08 16:06:39 UTC (rev 9458)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/PortletTestEverythingTestCase.java 2008-01-08 16:07:37 UTC (rev 9459)
@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Locale;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
import org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants;
@@ -94,14 +96,14 @@
SupportsMetaData smd1 = p1.getSupports().get(0);
assertEquals("text/html", smd1.getMimeType());
- assertEquals("VIEW", smd1.getPortletModes().get(0).getPortletMode());
- assertEquals("EDIT", smd1.getPortletModes().get(1).getPortletMode());
- assertEquals("HELP", smd1.getPortletModes().get(2).getPortletMode());
+ assertEquals(Mode.create("VIEW"), smd1.getPortletModes().get(0).getPortletMode());
+ assertEquals(Mode.create("EDIT"), smd1.getPortletModes().get(1).getPortletMode());
+ assertEquals(Mode.create("HELP"), smd1.getPortletModes().get(2).getPortletMode());
SupportsMetaData smd2 = p1.getSupports().get(1);
assertEquals("text/wml", smd2.getMimeType());
- assertEquals("VIEW", smd2.getPortletModes().get(0).getPortletMode());
- assertEquals("HELP", smd2.getPortletModes().get(1).getPortletMode());
+ assertEquals(Mode.create("VIEW"), smd2.getPortletModes().get(0).getPortletMode());
+ assertEquals(Mode.create("HELP"), smd2.getPortletModes().get(1).getPortletMode());
assertEquals("MyResourceBundle", p1.getResourceBundle());
@@ -150,6 +152,9 @@
assertEquals("text/html", p2.getSupports().get(0).getMimeType());
assertEquals("test the portlet session", p2.getPortletInfo().getTitle());
+ // default value should be 0
+ assertEquals(0, p2.getExpirationCache());
+
PortletMetaData p3 = md.getPortlet("Portlet3");
assertNotNull(p3);
assertEquals(md, p3.getPortletApplication());
@@ -257,14 +262,14 @@
SupportsMetaData smd1 = p1.getSupports().get(0);
assertEquals("text/html", smd1.getMimeType());
- assertEquals("VIEW", smd1.getPortletModes().get(0).getPortletMode());
- assertEquals("EDIT", smd1.getPortletModes().get(1).getPortletMode());
- assertEquals("HELP", smd1.getPortletModes().get(2).getPortletMode());
+ assertEquals(Mode.create("VIEW"), smd1.getPortletModes().get(0).getPortletMode());
+ assertEquals(Mode.create("EDIT"), smd1.getPortletModes().get(1).getPortletMode());
+ assertEquals(Mode.create("HELP"), smd1.getPortletModes().get(2).getPortletMode());
SupportsMetaData smd2 = p1.getSupports().get(1);
assertEquals("text/wml", smd2.getMimeType());
- assertEquals("VIEW", smd2.getPortletModes().get(0).getPortletMode());
- assertEquals("HELP", smd2.getPortletModes().get(1).getPortletMode());
+ assertEquals(Mode.create("VIEW"), smd2.getPortletModes().get(0).getPortletMode());
+ assertEquals(Mode.create("HELP"), smd2.getPortletModes().get(1).getPortletMode());
List<SupportedLocaleMetaData> localeList = p1.getSupportedLocale();
assertEquals(new Locale("en"), localeList.get(0).getLocale());
@@ -410,21 +415,21 @@
SupportsMetaData smd1 = p1.getSupports().get(0);
assertEquals("text/html", smd1.getMimeType());
- assertEquals("VIEW", smd1.getPortletModes().get(0).getPortletMode());
- assertEquals("EDIT", smd1.getPortletModes().get(1).getPortletMode());
- assertEquals("HELP", smd1.getPortletModes().get(2).getPortletMode());
+ assertEquals(Mode.create("VIEW"), smd1.getPortletModes().get(0).getPortletMode());
+ assertEquals(Mode.create("EDIT"), smd1.getPortletModes().get(1).getPortletMode());
+ assertEquals(Mode.create("HELP"), smd1.getPortletModes().get(2).getPortletMode());
// window state jsr 286
- assertEquals("MAXIMIZED", smd1.getWindowStates().get(0).getWindowState());
- assertEquals("NORMAL", smd1.getWindowStates().get(1).getWindowState());
+ assertEquals(WindowState.create("MAXIMIZED"), smd1.getWindowStates().get(0).getWindowState());
+ assertEquals(WindowState.create("NORMAL"), smd1.getWindowStates().get(1).getWindowState());
SupportsMetaData smd2 = p1.getSupports().get(1);
assertEquals("foo", smd2.getId());
assertEquals("text/wml", smd2.getMimeType());
- assertEquals("VIEW", smd2.getPortletModes().get(0).getPortletMode());
- assertEquals("HELP", smd2.getPortletModes().get(1).getPortletMode());
+ assertEquals(Mode.create("VIEW"), smd2.getPortletModes().get(0).getPortletMode());
+ assertEquals(Mode.create("HELP"), smd2.getPortletModes().get(1).getPortletMode());
// window state jsr 286
- assertEquals("NORMAL", smd2.getWindowStates().get(0).getWindowState());
- assertEquals("CUSTOM", smd2.getWindowStates().get(1).getWindowState());
+ assertEquals(WindowState.create("NORMAL"), smd2.getWindowStates().get(0).getWindowState());
+ assertEquals(WindowState.create("CUSTOM"), smd2.getWindowStates().get(1).getWindowState());
List<SupportedLocaleMetaData> localeList = p1.getSupportedLocale();
assertEquals(new Locale("en"), localeList.get(0).getLocale());
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java 2008-01-08 16:06:39 UTC (rev 9458)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java 2008-01-08 16:07:37 UTC (rev 9459)
@@ -27,6 +27,8 @@
import java.util.Locale;
import org.apache.log4j.Logger;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.TransportGuarantee;
import org.jboss.portal.portlet.impl.metadata.CustomPortletModeMetaData;
@@ -583,7 +585,7 @@
PortletModeMetaData md = (PortletModeMetaData) object;
if ("portlet-mode".equals(localName))
{
- md.setPortletMode(value);
+ md.setPortletMode(Mode.create(value));
}
}
@@ -593,7 +595,7 @@
WindowStateMetaData md = (WindowStateMetaData) object;
if ("window-state".equals(localName))
{
- md.setWindowState(value);
+ md.setWindowState(WindowState.create(value));
}
}
18 years, 3 months
JBoss Portal SVN: r9458 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-08 11:06:39 -0500 (Tue, 08 Jan 2008)
New Revision: 9458
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml
Log:
Doh !
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml 2008-01-08 15:57:56 UTC (rev 9457)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml 2008-01-08 16:06:39 UTC (rev 9458)
@@ -231,7 +231,7 @@
</listitem>
</itemizedlist>
<note><para>Several parts have been extracted from the code above. Those modules have a different lifecycle and
- a different versioning. Here is the list of modules used in JBoss Portal 2.6.2 and the location of the source code.
+ a different versioning. Here is the list of modules used in JBoss Portal 2.6.3 and the location of the source code.
<itemizedlist>
<listitem><para>JBoss Portal Common 1.1.0:</para> <para>http://anonsvn.jboss.org/repos/portal/modules/common/tags/JBP_COMMON_1_1_0</para></listitem>
<listitem>JBoss Portal Web 1.1: http://anonsvn.jboss.org/repos/portal/modules/web/tags/JBP_WEB_1_1_0</listitem>
18 years, 3 months