Package net.sourceforge.stripes.config

Examples of net.sourceforge.stripes.config.DefaultConfiguration


public class DefaultFormatterFactoryTest {
    @Test(groups = "fast")
    public void testFormatterSuperclass() throws Exception {
        DefaultFormatterFactory factory = new DefaultFormatterFactory();
        factory.init(new DefaultConfiguration());

        Locale locale = Locale.getDefault();
        Formatter<?> formatter;

        factory.add(A.class, AFormatter.class);
View Full Code Here


    }

    @Test(groups = "fast")
    public void testFormatterInterface() throws Exception {
        DefaultFormatterFactory factory = new DefaultFormatterFactory();
        factory.init(new DefaultConfiguration());

        Locale locale = Locale.getDefault();
        Formatter<?> formatter;

        factory.add(X.class, XFormatter.class);
View Full Code Here

    }

    @Test(groups = "fast")
    public void testNullFormatterIsNeverBestMatch() throws Exception {
        DefaultFormatterFactory factory = new DefaultFormatterFactory();
        factory.init(new DefaultConfiguration());

        Locale locale = Locale.getDefault();
        Formatter<?> formatter;

        // cause null formatter to be cached for B
View Full Code Here

    }

    @Test(groups = "fast")
    public void testFormatterSuperclassImplementsInterface() throws Exception {
        DefaultFormatterFactory factory = new DefaultFormatterFactory();
        factory.init(new DefaultConfiguration());

        Locale locale = Locale.getDefault();
        Formatter<?> formatter;

        // simple test to get formatter for a superclass interface
        factory.add(X.class, XFormatter.class);
        factory.add(Y.class, YFormatter.class);
        factory.add(Z.class, ZFormatter.class);

        formatter = factory.getFormatter(SuperclassImplementsX.class, locale, null, null);
        Assert.assertEquals(XFormatter.class, formatter.getClass());
        formatter = factory.getFormatter(SuperclassImplementsY.class, locale, null, null);
        Assert.assertEquals(YFormatter.class, formatter.getClass());
        formatter = factory.getFormatter(SuperclassImplementsZ.class, locale, null, null);
        Assert.assertEquals(ZFormatter.class, formatter.getClass());

        /*
         * test that if Z extends Y extends X and Y implements I and a formatter is registered for
         * both X and I then the formatter returned for Y and Z is the I formatter
         */
        factory = new DefaultFormatterFactory();
        factory.init(new DefaultConfiguration());

        factory.add(SuperclassImplementsX.class, XFormatter.class); // mapping for base class
        factory.add(Y.class, YFormatter.class); // mapping for interface in the middle

        formatter = factory.getFormatter(SuperclassImplementsX.class, locale, null, null);
View Full Code Here

        Assert.assertEquals(YFormatter.class, formatter.getClass());
    }

    public void testFormatterForInterfaceSuperclass() throws Exception {
        DefaultFormatterFactory factory = new DefaultFormatterFactory();
        factory.init(new DefaultConfiguration());

        Locale locale = Locale.getDefault();
        Formatter<?> formatter;

        factory.add(IfaceLevel1.class, IfaceLevel1Formatter.class);
View Full Code Here

    @SuppressWarnings("unchecked")
  @Test(groups="fast")
    public void testCharTypeConverter() throws Exception{
      DefaultTypeConverterFactory factory = new DefaultTypeConverterFactory();
      factory.init(new DefaultConfiguration());
     
      TypeConverter typeConverter = factory.getTypeConverter(Character.class, Locale.getDefault());
        Assert.assertEquals(CharacterTypeConverter.class, typeConverter.getClass());

      typeConverter = factory.getTypeConverter(Character.TYPE, Locale.getDefault());
View Full Code Here

    }

    /** Gets a reference to the default configuration, which can be used for simple testing. */
    public static synchronized Configuration getDefaultConfiguration() {
        if (configuration == null) {
            Configuration configuration = new DefaultConfiguration();
            MockFilterConfig filterConfig = new MockFilterConfig();
            filterConfig.addAllInitParameters(getDefaultFilterParams());
            MockServletContext mockServletContext = createServletContext();
            try {
                filterConfig.setServletContext(mockServletContext);
                configuration.setBootstrapPropertyResolver(new BootstrapPropertyResolver(filterConfig));
                configuration.init();
                StripesTestFixture.configuration = configuration;
            } finally {
                mockServletContext.close();
            }
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.config.DefaultConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.