Package org.impalaframework.spring.bean

Examples of org.impalaframework.spring.bean.StringFactoryBean


        final BasicServiceRegistryEntry reference = new StaticServiceRegistryEntry("bean", "beanName", "moduleName", ClassUtils.getDefaultClassLoader());
        doTest(reference);
    }
   
    public void testWithFactoryBean() throws Exception {
        final StringFactoryBean bean = new StringFactoryBean();
        bean.setValue("bean");
        final BasicServiceRegistryEntry reference = new StaticServiceRegistryEntry(bean, "beanName", "moduleName", ClassUtils.getDefaultClassLoader());
        doTest(reference);
    }
View Full Code Here


        assertEquals(0, entryDelegate.getModuleReferences("module1").size());
        assertEquals(1, entryDelegate.getModuleReferences("module2").size());
    }

    public void testClassMatching() throws Exception {
        final StringFactoryBean factoryBean = new StringFactoryBean();
        factoryBean.setValue("some service");
        registryaddService("bean1", "module1", factoryBean.getObject(), classLoader);

        ServiceRegistryEntry service = registry.getService("bean1", classes, false);
        assertEquals("some service", service.getServiceBeanReference().getService());

        //must match all classes provided
View Full Code Here

   
    public void testGetServiceByExportTypes() throws Exception {
       
        classes = new Class[]{String.class};
       
        final StringFactoryBean factoryBean = new StringFactoryBean();
        factoryBean.setValue("some service");
        registryaddService("bean1", "module1", factoryBean, classLoader);

        try {
            registry.getService(null, classes, false);
            fail();
        }
        catch (IllegalArgumentException e) {
            assertEquals("Either bean name must be not null, or export types must be non-empty", e.getMessage());
        }
       
        try {
            registry.getService(null, new Class[0], false);
            fail();
        }
        catch (IllegalArgumentException e) {
            assertEquals("Either bean name must be not null, or export types must be non-empty", e.getMessage());
        }

        try {
            registry.getServices((String)null, classes, false);
            fail();
        }
        catch (IllegalArgumentException e) {
            assertEquals("Either bean name must be not null, or export types must be non-empty", e.getMessage());
        }
       
        try {
            registry.getServices((String)null, new Class[0], false);
            fail();
        }
        catch (IllegalArgumentException e) {
            assertEquals("Either bean name must be not null, or export types must be non-empty", e.getMessage());
        }   
       
        //not registered under any export types
        assertNull(registry.getService("bean1", classes, true));
        assertNull(registry.getService(null, classes, true));
       
        assertTrue(registry.getServices("bean1", classes, true).isEmpty());
        assertTrue(registry.getServices((String)null, classes, true).isEmpty());
       
        //now register bean with export types
        List<Class<?>> list = Collections.<Class<?>>singletonList(String.class);
        registryaddService(null, "module1", factoryBean.getObject(), list, null, classLoader);
       
        assertNotNull(registry.getService(null, classes, true));
        assertNull(registry.getService("bean1", classes, true));
       
        assertFalse(registry.getServices((String)null, classes, true).isEmpty());
        assertTrue(registry.getServices("bean1", classes, true).isEmpty());
       
        registryaddService("bean2", "module1", factoryBean.getObject(), list, null, classLoader);
        assertNotNull(registry.getService("bean2", classes, true));
        assertFalse(registry.getServices("bean2", classes, true).isEmpty());
    }
View Full Code Here

        }
    }
   
    public void testCheckClassesFactoryBean() throws Exception {
       
        StringFactoryBean service = new StringFactoryBean();
        service.setValue("service");
       
        List<Class<?>> toCheck = new ArrayList<Class<?>>();
        toCheck.add(String.class);
        toCheck.add(Object.class);
       
        entryDelegate.checkClasses(new StaticServiceRegistryEntry(service.getObject(), "bean", "module", toCheck, null, classLoader));
    }
View Full Code Here

TOP

Related Classes of org.impalaframework.spring.bean.StringFactoryBean

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.