Package org.springframework.core.io

Examples of org.springframework.core.io.Resource


    }

    /** Test parseEntities() for valid configuration, simple example. */
    @SuppressWarnings("rawtypes")
    @Test public void testParseEntitiesValidSimple() throws IOException {
        Resource entities = TestUtils.createMockedResource("java.lang.String\n");
        List<Class> classes = DaoObjectifyService.parseEntities(entities);
        assertEquals(1, classes.size());
        assertEquals(java.lang.String.class, classes.get(0));
    }
View Full Code Here


        buffer.append("\n")// empty line
        buffer.append("java.lang.String\n");
        buffer.append("java.util.Date\n");
        buffer.append("   \t    \n")// whitespace-only line
        buffer.append("   # This is a comment with some leading spaces\n");
        Resource entities = TestUtils.createMockedResource(buffer.toString());
        List<Class> classes = DaoObjectifyService.parseEntities(entities);
        assertEquals(2, classes.size());
        assertEquals(java.lang.String.class, classes.get(0));
        assertEquals(java.util.Date.class, classes.get(1));
    }
View Full Code Here

        assertEquals(java.util.Date.class, classes.get(1));
    }

    /** Test parseEntities() for invalid data (unknown class). */
    @Test public void testParseEntitiesUnknownClass() throws IOException {
        Resource entities = TestUtils.createMockedResource("ken.whatever.Bogus\n");
        try {
            DaoObjectifyService.parseEntities(entities);
        } catch (CedarRuntimeException e) { }
    }
View Full Code Here

        } catch (CedarRuntimeException e) { }
    }

    /** Test parseEntities() for invalid data (null input reader). */
    @Test public void testParseEntitiesBadInput() throws IOException {
        Resource entities = TestUtils.createMockedResource(null);
        try {
            DaoObjectifyService.parseEntities(entities);
        } catch (CedarRuntimeException e) { }
    }
View Full Code Here

        } catch (CedarRuntimeException e) { }
    }

    /** Create a mocked service for testing. */
    private static DaoObjectifyService createService() {
        Resource entities = TestUtils.createMockedResource("java.lang.String")// valid
        ObjectifyServiceProxy objectifyServiceProxy = mock(ObjectifyServiceProxy.class);
        DaoObjectifyService service = new DaoObjectifyService();
        service.setObjectifyServiceProxy(objectifyServiceProxy);
        service.setEntities(entities)// valid because String is a known class
        service.afterPropertiesSet();
View Full Code Here

*/
public class HierarchicalPropertiesTest {

    /** Test constructor, getters and setters. */
    @Test public void testConstructor() {
        Resource classpathResource = new PropertiesResource(null);
        Resource environmentResource = new PropertiesResource(null);

        HierarchicalProperties properties = new HierarchicalProperties();
        properties.toString(); // make sure it works for empty object

        properties.setLogContents(true);
View Full Code Here

        assertEquals("2000", properties.get("MyConfig.two"));
        assertEquals("1000", properties.get("MyConfig.three"));
    }

    private static HierarchicalProperties getProperties(Properties classpathProperties, Properties environmentProperties) {
        Resource classpathResource = new PropertiesResource(classpathProperties);
        Resource environmentResource = new PropertiesResource(environmentProperties);
        HierarchicalProperties properties = new HierarchicalProperties();
        properties.setClasspathResource(classpathResource);
        properties.setEnvironmentResource(environmentResource);
        properties.afterPropertiesSet();
        return properties;
View Full Code Here

        GaeVelocityUtils gaeVelocityUtils = mock(GaeVelocityUtils.class);
        service.setGaeVelocityUtils(gaeVelocityUtils);
        assertSame(gaeVelocityUtils, service.getGaeVelocityUtils());

        Resource templateDirResource = mock(Resource.class);
        service.setTemplateDirResource(templateDirResource);
        assertSame(templateDirResource, service.getTemplateDirResource());
    }
View Full Code Here

    /** Test the afterPropertiesSet() method. */
    @Test public void testAfterPropertiesSet() throws Exception {
        GaeVelocityTemplateService service = new GaeVelocityTemplateService();
        GaeVelocityUtils gaeVelocityUtils = mock(GaeVelocityUtils.class);
        Resource templateDirResource = mock(Resource.class, RETURNS_DEEP_STUBS);   // so call1().call2().call3() works

        try {
            service.setGaeVelocityUtils(null);
            service.setTemplateDirResource(templateDirResource);
            service.afterPropertiesSet();
            fail("Expected NotConfiguredException");
        } catch (NotConfiguredException e) { }

        try {
            service.setGaeVelocityUtils(gaeVelocityUtils);
            service.setTemplateDirResource(null);
            service.afterPropertiesSet();
            fail("Expected NotConfiguredException");
        } catch (NotConfiguredException e) { }

        try {
            when(templateDirResource.exists()).thenReturn(false);
            service.setGaeVelocityUtils(gaeVelocityUtils);
            service.setTemplateDirResource(templateDirResource);
            service.afterPropertiesSet();
        } catch (NotConfiguredException e) { }

        when(templateDirResource.exists()).thenReturn(true);
        when(templateDirResource.getFile().getPath()).thenReturn("path");
        service.setGaeVelocityUtils(gaeVelocityUtils);
        service.setTemplateDirResource(templateDirResource);
        service.afterPropertiesSet();
        assertEquals("path", service.getTemplateDir());
    }
View Full Code Here

    /** Create a service instance properly stubbed for testing. */
    private static GaeVelocityTemplateService createService() throws Exception {
        GaeVelocityTemplateService service = new GaeVelocityTemplateService();
        GaeVelocityUtils gaeVelocityUtils = GaeVelocityUtils.getInstance();
        Resource templateDirResource = mock(Resource.class, RETURNS_DEEP_STUBS);   // so call1().call2().call3() works

        when(templateDirResource.exists()).thenReturn(true);
        when(templateDirResource.getFile().getPath()).thenReturn(TEMPLATE_DIR);

        service.setGaeVelocityUtils(gaeVelocityUtils);
        service.setTemplateDirResource(templateDirResource);
        service.afterPropertiesSet();

View Full Code Here

TOP

Related Classes of org.springframework.core.io.Resource

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.