r2158 - in trunk/nuiton-utils: . src/main/java/org/nuiton/util/decorator src/test/java/org/nuiton/util/decorator
Author: tchemit Date: 2011-08-01 17:14:33 +0200 (Mon, 01 Aug 2011) New Revision: 2158 Url: http://nuiton.org/repositories/revision/nuiton-utils/2158 Log: add a multi i18n decorator api + test it fix dependencies Added: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java Modified: trunk/nuiton-utils/pom.xml trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java Modified: trunk/nuiton-utils/pom.xml =================================================================== --- trunk/nuiton-utils/pom.xml 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/pom.xml 2011-08-01 15:14:33 UTC (rev 2158) @@ -61,6 +61,11 @@ </dependency> <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> </dependency> Added: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java (rev 0) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -0,0 +1,319 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit + * %% + * This program 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 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.decorator; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * A decorator provider for multi-i18n locale. + * <p/> + * Implements the method {@link #loadDecorators(Locale)} to fill the decorators + * availables. + * <p/> + * Then can obtain decorator via the methods {@code getDecorator(...)} + * <p/> + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2.1 + */ +public abstract class DecoratorMulti18nProvider { + + /** Logger */ + private static final Log log = LogFactory.getLog(DecoratorProvider.class); + + /** + * Loaded decorators. + * <p/> + * This map will be lazy loaded as needed via the method + * {@link #getDecoratorContexts(Locale, boolean)}. + */ + protected Map<Locale, Collection<DecoratorContext<?>>> decoratorContexts; + + + /** + * Load all decorators of the provider for the given {@code locale}. + * + * @param locale the locale to use to load decorators. + */ + protected abstract void loadDecorators(Locale locale); + + + /** + * Obtain a decorator for the given object using the given {@code locale}. + * + * @param locale user locale + * @param object object of decorated object + * @param <O> object of decorated object + * @return the decorator or {@code null} if not found + */ + @SuppressWarnings({"unchecked"}) + public <O> Decorator<O> getDecorator(Locale locale, O object) { + return getDecorator(locale, object, null); + } + + /** + * Obtain a decorator given a object and an extra name to qualify the + * context using the given {@code locale}. + * + * @param locale user locale + * @param object object of decorated object + * @param name extra name to qualify the decorator to use + * @param <O> object of decorated object + * @return the decorator or {@code null} if not found + */ + @SuppressWarnings({"unchecked"}) + public <O> Decorator<O> getDecorator(Locale locale, + O object, + String name) { + Class<O> k = (Class<O>) object.getClass(); + return getDecorator(locale, k, name); + } + + /** + * Obtain a decorator given a type on the given {@code locale}. + * + * @param locale user locale + * @param type type of decorated object + * @param <O> type of decorated object + * @return the decorator or {@code null} if not found + */ + public <O> Decorator<O> getDecorator(Locale locale, + Class<O> type) { + return getDecorator(locale, type, null); + } + + /** + * Obtain a decorator given a type and a extra context name on the given + * {@code locale}. + * + * @param locale user locale + * @param type type of decorated object + * @param name extra name to qualify the decorator to use + * @param <O> type of decorated object + * @return the decorator or {@code null} if not found + */ + public <O> Decorator<O> getDecorator(Locale locale, + Class<O> type, + String name) { + DecoratorContext<O> d = getDecoratorContext(locale, type, name, true); + return d == null ? null : d.getDecorator(); + } + + public void clear() { + if (decoratorContexts != null) { + decoratorContexts.clear(); + } + } + + protected Map<Locale, Collection<DecoratorContext<?>>> getDecoratorContexts() { + if (decoratorContexts == null) { + decoratorContexts = new HashMap<Locale, Collection<DecoratorContext<?>>>(); + } + return decoratorContexts; + } + + protected Collection<DecoratorContext<?>> getDecoratorContexts(Locale locale, + boolean doLoad) { + + Collection<DecoratorContext<?>> decoratorContexts = + getDecoratorContexts().get(locale); + + if (decoratorContexts == null) { + decoratorContexts = new ArrayList<DecoratorContext<?>>(); + getDecoratorContexts().put(locale, decoratorContexts); + if (doLoad) { + loadDecorators(locale); + } + } + return decoratorContexts; + } + + @SuppressWarnings({"unchecked"}) + protected <T> DecoratorContext<T> getDecoratorContext(Locale locale, + Class<T> type, + String context, + boolean doLoad) { + DecoratorContext<T> result = null; + + Collection<DecoratorContext<?>> decoratorContexts = + getDecoratorContexts(locale, doLoad); + + if (decoratorContexts != null) { + for (DecoratorContext<?> d : decoratorContexts) { + if (type == null) { + if (d.accept(context)) { + result = (DecoratorContext<T>) d; + break; + } + continue; + } + if (d.accept(type, context)) { + result = (DecoratorContext<T>) d; + break; + } + } + } + return result; + } + + protected void registerPropertyDecorator(Locale locale, + Class<?> klass, + String expression) { + registerPropertyDecorator(locale, klass, null, expression); + } + + protected void registerJXPathDecorator(Locale locale, + Class<?> klass, String expression) { + registerJXPathDecorator(locale, klass, null, expression); + } + + protected void registerMultiJXPathDecorator(Locale locale, + Class<?> klass, + String expression, + String separator, + String separatorReplacement) { + registerMultiJXPathDecorator(locale, klass, null, expression, separator, + separatorReplacement); + } + + protected void registerPropertyDecorator(Locale locale, + Class<?> klass, + String name, + String expression) { + Decorator<?> decorator = + DecoratorUtils.newPropertyDecorator(klass, expression); + registerDecorator(locale, name, decorator); + } + + protected void registerJXPathDecorator(Locale locale, + Class<?> klass, + String name, + String expression) { + Decorator<?> decorator = + DecoratorUtils.newJXPathDecorator(klass, expression); + registerDecorator(locale, name, decorator); + } + + protected void registerMultiJXPathDecorator(Locale locale, + Class<?> klass, + String name, + String expression, + String separator, + String separatorReplacement) { + Decorator<?> decorator = DecoratorUtils.newMultiJXPathDecorator( + klass, expression, separator, separatorReplacement + ); + registerDecorator(locale, name, decorator); + } + + protected void registerDecorator(Locale locale, + Decorator<?> decorator) { + registerDecorator(locale, null, decorator); + } + + /** + * Register a new decorator in the cache of the provider. + * + * @param <T> type of data decorated + * @param locale + * @param context the name decorator + * @param decorator the decorator to register + */ + protected <T> void registerDecorator(Locale locale, + String context, + Decorator<T> decorator) { + + // obtain the decorator context + DecoratorContext<?> result = + getDecoratorContext(locale, + decorator.getInternalClass(), + context, + false + ); + + if (result != null) { + throw new IllegalArgumentException( + "there is an already register decorator with context " + + result); + } + + DecoratorContext<T> decoratorContext = + new DecoratorContext<T>(context, decorator); + if (log.isDebugEnabled()) { + log.debug(decoratorContext); + } + getDecoratorContexts(locale, false).add(decoratorContext); + } + + public static class DecoratorContext<T> { + + /** the context name of the decorator */ + final String context; + + /** the decorator */ + final Decorator<T> decorator; + + public DecoratorContext(String context, Decorator<T> decorator) { + this.context = context; + this.decorator = decorator; + } + + public String getContext() { + return context; + } + + public Decorator<T> getDecorator() { + return decorator; + } + + public Class<T> getType() { + return decorator.getInternalClass(); + } + + public boolean accept(Class<?> type, String context) { + boolean accept = getType().isAssignableFrom(type) && accept(context); + return accept; + } + + public boolean accept(String context) { + return this.context == null && context == null || + this.context != null && this.context.equals(context); + } + + @Override + public String toString() { + return super.toString() + "<type: " + getType().getName() + + ", context :" + context + ">"; + } + } +} Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -45,7 +45,7 @@ public abstract class DecoratorProvider { /** Logger */ - private static final Log log = LogFactory.getLog(JXPathDecorator.class); + private static final Log log = LogFactory.getLog(DecoratorProvider.class); /** Registred decorators. */ protected List<DecoratorContext<?>> decorators; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2004 - 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -27,6 +27,10 @@ import java.util.ArrayList; import java.util.List; +/** + * @author tchemit <chemit@codelutin.com> + * @since 2.2.1 + */ public class Data { int pos; Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java (rev 0) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -0,0 +1,229 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit + * %% + * This program 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 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.decorator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.Locale; + +/** + * Tests the {@link DecoratorMulti18nProvider} + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2.1 + */ +public class DecoratorMulti18nProviderTest { + + private static final String BY_NAME = "name"; + + private static final String BY_POS = "pos"; + + static protected Locale l_fr = Locale.FRANCE; + + static protected Locale l_en = Locale.UK; + + class MyDecoratorProvider extends DecoratorMulti18nProvider { + + @Override + protected void loadDecorators(Locale locale) { + + registerPropertyDecorator(locale, File.class, "name"); + registerPropertyDecorator(locale, File.class, BY_NAME, "parent"); + + registerJXPathDecorator(locale, Class.class, "${simpleName}$s " + locale.getCountry()); + registerJXPathDecorator(locale, Class.class, BY_NAME, "${name}$s " + locale.getCountry()); + + registerMultiJXPathDecorator(locale, Data.class, "${name}$s " + locale.getCountry(), "-", " "); + registerMultiJXPathDecorator(locale, Data.class, BY_POS, "${pos}$d " + locale.getCountry(), "-", " "); + } + } + + MyDecoratorProvider provider; + + @Before + public void beforeTest() throws Exception { + provider = new MyDecoratorProvider(); + } + + @Test + public void testGetDecoratorByObject() throws Exception { + + + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(l_fr, f); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("myFile", fileDecorator.toString(f)); + + Decorator<?> classDecorator; + + classDecorator = provider.getDecorator(l_fr, Class.class); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("File FR", classDecorator.toString(k)); + + classDecorator = provider.getDecorator(l_en, Class.class); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("File GB", classDecorator.toString(k)); + + Decorator<Data> dataDecorator; + + dataDecorator = provider.getDecorator(l_fr, d); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("name FR", dataDecorator.toString(d)); + + dataDecorator = provider.getDecorator(l_en, d); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("name GB", dataDecorator.toString(d)); + } + + @Test + public void testGetDecoratorByObjectAndName() throws Exception { + + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(l_fr, f, BY_NAME); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("null", fileDecorator.toString(f)); + + Decorator<Class> classDecorator; + + classDecorator = provider.getDecorator(l_fr, Class.class, BY_NAME); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("java.io.File FR", classDecorator.toString(k)); + + classDecorator = provider.getDecorator(l_en, Class.class, BY_NAME); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("java.io.File GB", classDecorator.toString(k)); + + + Decorator<Data> dataDecorator; + + dataDecorator = provider.getDecorator(l_fr, d, BY_NAME); + Assert.assertNull(dataDecorator); + + dataDecorator = provider.getDecorator(l_en, d, BY_NAME); + Assert.assertNull(dataDecorator); + + dataDecorator = provider.getDecorator(l_fr, d, BY_POS); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("0 FR", dataDecorator.toString(d)); + + dataDecorator = provider.getDecorator(l_en, d, BY_POS); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("0 GB", dataDecorator.toString(d)); + } + + @Test + public void testGetDecoratorByType() throws Exception { + + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(l_fr, File.class); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("myFile", fileDecorator.toString(f)); + + Decorator<Class> classDecorator; + + classDecorator = provider.getDecorator(l_fr, Class.class); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("File FR", classDecorator.toString(k)); + + classDecorator = provider.getDecorator(l_en, Class.class); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("File GB", classDecorator.toString(k)); + + Decorator<Data> dataDecorator; + + dataDecorator = provider.getDecorator(l_fr, Data.class); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("name FR", dataDecorator.toString(d)); + + dataDecorator = provider.getDecorator(l_en, Data.class); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("name GB", dataDecorator.toString(d)); + } + + @Test + public void testGetDecoratorByTypeAndName() throws Exception { + File f = new File("myFile"); + Data d = new Data(0, "name"); + Class<?> k = File.class; + + Decorator<File> fileDecorator = provider.getDecorator(l_fr, File.class, BY_NAME); + Assert.assertNotNull(fileDecorator); + Assert.assertEquals(File.class, fileDecorator.getInternalClass()); + Assert.assertEquals("null", fileDecorator.toString(f)); + + Decorator<Class> classDecorator; + + classDecorator = provider.getDecorator(l_fr, Class.class, BY_NAME); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("java.io.File FR", classDecorator.toString(k)); + + classDecorator = provider.getDecorator(l_en, Class.class, BY_NAME); + Assert.assertNotNull(classDecorator); + Assert.assertEquals(Class.class, classDecorator.getInternalClass()); + Assert.assertEquals("java.io.File GB", classDecorator.toString(k)); + + Decorator<Data> dataDecorator; + + dataDecorator = provider.getDecorator(l_fr, Data.class, BY_POS); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("0 FR", dataDecorator.toString(d)); + + dataDecorator = provider.getDecorator(l_en, Data.class, BY_POS); + Assert.assertNotNull(dataDecorator); + Assert.assertEquals(Data.class, dataDecorator.getInternalClass()); + Assert.assertEquals("0 GB", dataDecorator.toString(d)); + } + + +} Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -31,11 +31,11 @@ import java.io.File; /** - * User: chemit - * Date: 28 oct. 2009 - * Time: 21:28:46 + * @author tchemit <chemit@codelutin.com> + * @since 2.2.1 */ public class DecoratorProviderTest { + private static final String BY_NAME = "name"; class MyDecoratorProvider extends DecoratorProvider { Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -32,7 +32,7 @@ * A simple class to test JXPath context. * * @author tchemit <chemit@codelutin.com> - * @since 2.0.1 + * @since 2.2.1 */ public abstract class JXPathContextTester { Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -36,7 +36,7 @@ /** * @author tchemit <chemit@codelutin.com> - * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecoratorTest}). + * @since 2.2.1 */ public class JXPathDecoratorTest { Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -39,7 +39,7 @@ * Tests the class {@link MapPropertyHandler}. * * @author tchemit <chemit@codelutin.com> - * @since 2.0.1 + * @since 2.2.1 */ public class MapPropertyHandlerTest extends JXPathContextTester { Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-07-31 15:02:22 UTC (rev 2157) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-08-01 15:14:33 UTC (rev 2158) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2004 - 2011 CodeLutin + * Copyright (C) 2011 CodeLutin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -36,7 +36,7 @@ /** * @author tchemit <chemit@codelutin.com> - * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecoratorTest}). + * @since 2.2.1 */ public class MultiJXPathDecoratorTest {
participants (1)
-
tchemit@users.nuiton.org