Package org.impalaframework.module.definition

Examples of org.impalaframework.module.definition.SimpleBeansetModuleDefinition


    reader = new ApplicationWithBeansetsModuleTypeReader();
  }

  public void testReadModuleDefinition() {
    ModuleDefinition definition = reader.readModuleDefinition(null, "mymodule", new Properties());
    SimpleBeansetModuleDefinition moduleDefinition = (SimpleBeansetModuleDefinition) definition;
    assertEquals("mymodule", moduleDefinition.getName());
    assertEquals("APPLICATION_WITH_BEANSETS", moduleDefinition.getType());
  }
View Full Code Here


 
  public void testReadModuleDefinitionLocations() {
    Properties properties = new Properties();
    properties.put(ModuleElementNames.CONFIG_LOCATIONS_ELEMENT, "loc1, loc2,loc3");
    ModuleDefinition definition = reader.readModuleDefinition(null, "mymodule", properties);
    SimpleBeansetModuleDefinition moduleDefinition = (SimpleBeansetModuleDefinition) definition;
    assertEquals("mymodule", moduleDefinition.getName());
    assertEquals("APPLICATION_WITH_BEANSETS", moduleDefinition.getType());
    assertEquals(Arrays.asList(new String[]{ "loc1", "loc2", "loc3"}), moduleDefinition.getConfigLocations());
  }
View Full Code Here

  private ConfigurableApplicationContext parent;

  private ConfigurableApplicationContext child;

  public final void testInitialModuleDefinition() {
    BeansetModuleDefinition definition = new SimpleBeansetModuleDefinition(plugin4);
    loadChild(definition);
    System.out.println(Arrays.toString(child.getBeanDefinitionNames()));
    assertTrue(child.containsBean("bean1"));
    assertTrue(child.containsBean("importedBean1"));
    assertTrue(child.containsBean("importedBean2"));
View Full Code Here

 
  public void testWithOverrides() {
    Properties properties = new Properties();
    properties.setProperty(ApplicationWithBeansetsModuleTypeReader.OVERRIDES_ELEMENT, "beanset: all;");
    ModuleDefinition definition = reader.readModuleDefinition(null, "mymodule", properties);
    SimpleBeansetModuleDefinition moduleDefinition = (SimpleBeansetModuleDefinition) definition;
    assertEquals("mymodule", moduleDefinition.getName());
    assertEquals("APPLICATION_WITH_BEANSETS", moduleDefinition.getType());
    assertEquals(Collections.singletonMap("beanset", Collections.singleton("all")), moduleDefinition.getOverrides());
  }
View Full Code Here

    assertTrue(child.containsBean("importedBean1"));
    assertTrue(child.containsBean("importedBean2"));
  }
 
  public final void testModifiedModuleDefinition() {
    BeansetModuleDefinition definition = new SimpleBeansetModuleDefinition(plugin4, "alternative: myImports");
    loadChild(definition);
    System.out.println(Arrays.toString(child.getBeanDefinitionNames()));
    assertTrue(child.containsBean("bean1"));
    assertTrue(child.containsBean("importedBean1"));
    assertFalse(child.containsBean("importedBean2"));
View Full Code Here

    assertTrue(child.containsBean("importedBean1"));
    assertFalse(child.containsBean("importedBean2"));
  }
 
  public final void testNewBeanDefinitionReader() {
    BeansetModuleDefinition definition = new SimpleBeansetModuleDefinition(plugin4);
    BeansetApplicationModuleLoader loader = new BeansetApplicationModuleLoader();
 
    XmlBeanDefinitionReader reader = loader.newBeanDefinitionReader("id", new GenericApplicationContext(), definition);
    int definitions = reader.loadBeanDefinitions(new ClassPathResource("parentTestContext.xml"));
    assertTrue(definitions > 0);
View Full Code Here

* @author Phil Zoio
*/
public class SimpleBeansetAwareModuleDefinitionTest extends TestCase {

  public void testGetType() {
    SimpleBeansetModuleDefinition definition = new SimpleBeansetModuleDefinition("p1", new HashMap<String, Set<String>>());
    assertEquals("APPLICATION_WITH_BEANSETS", definition.getType());
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void testConstructorsWithParent() {
    ModuleDefinition parent = new SimpleModuleDefinition("bean");
    HashMap<String, Set<String>> map = new HashMap<String, Set<String>>();
    map.put("key", Collections.EMPTY_SET);
    SimpleBeansetModuleDefinition definition = new SimpleBeansetModuleDefinition(parent, "p1", map);
    assertEquals(parent, definition.getParentDefinition());
    assertEquals("p1", definition.getName());
    assertEquals(Collections.EMPTY_SET, definition.getOverrides().get("key"));
   
    definition = new SimpleBeansetModuleDefinition(parent, "p1");
    assertEquals(parent, definition.getParentDefinition());
    assertEquals("p1", definition.getName());
    assertEquals(Collections.EMPTY_MAP, definition.getOverrides());
   
    definition = new SimpleBeansetModuleDefinition(parent, "p1", "key: value");
    assertEquals(parent, definition.getParentDefinition());
    assertEquals("p1", definition.getName());
    assertNotNull(definition.getOverrides().get("key"));
  }
View Full Code Here

    List<String> locationList = Arrays.asList(locations);
   
    ModuleDefinition parent = new SimpleModuleDefinition(null, "bean", locations);
    HashMap<String, Set<String>> map = new HashMap<String, Set<String>>();
    map.put("key", Collections.EMPTY_SET);
    SimpleBeansetModuleDefinition spec = new SimpleBeansetModuleDefinition(parent, "p1", locations, map);
    assertEquals(parent, spec.getParentDefinition());
    assertEquals("p1", spec.getName());
    assertEquals(Collections.EMPTY_SET, spec.getOverrides().get("key"));
    assertEquals(locationList, spec.getConfigLocations());
   
    spec = new SimpleBeansetModuleDefinition(parent, "p1", locations);
    assertEquals(parent, spec.getParentDefinition());
    assertEquals("p1", spec.getName());
    assertEquals(Collections.EMPTY_MAP, spec.getOverrides());
    assertEquals(locationList, spec.getConfigLocations());
   
    spec = new SimpleBeansetModuleDefinition(parent, "p1", locations, "key: value");
    assertEquals(parent, spec.getParentDefinition());
    assertEquals("p1", spec.getName());
    assertNotNull(spec.getOverrides().get("key"));
    assertEquals(locationList, spec.getConfigLocations());
  }
View Full Code Here

    assertEquals(locationList, spec.getConfigLocations());
  }
 
  public void testEqualsObject() {
    Map<String, Set<String>> map1 = new HashMap<String, Set<String>>();
    SimpleBeansetModuleDefinition p1a = new SimpleBeansetModuleDefinition("p1", map1);
    Map<String, Set<String>> map2 = new HashMap<String, Set<String>>();
    SimpleBeansetModuleDefinition p1b = new SimpleBeansetModuleDefinition("p1", map2);
    assertEquals(p1a, p1b);

    SimpleBeansetModuleDefinition p2b = new SimpleBeansetModuleDefinition("p2", map2);
    assertFalse(p1b.equals(p2b));

    map1.put("bean1", Collections.singleton("context1-a.xml"));
    map1.put("bean2", Collections.singleton("context2-a.xml"));

    map2.put("bean1", Collections.singleton("context1-a.xml"));
    map2.put("bean2", Collections.singleton("context2-a.xml"));

    // these contain the same overrides, so use these
    p1a = new SimpleBeansetModuleDefinition("p1", map1);
    p1b = new SimpleBeansetModuleDefinition("p1", map2);
    assertEquals(p1a, p1b);

    // now change bean2 in map2
    map2.put("bean2", Collections.singleton("context2-b.xml"));
    p1b = new SimpleBeansetModuleDefinition("p1", map2);
    assertFalse(p1b.equals(p2b));

    map2.remove("bean2");
    p1b = new SimpleBeansetModuleDefinition("p1", map2);
    assertFalse(p1b.equals(p2b));
  }
View Full Code Here

TOP

Related Classes of org.impalaframework.module.definition.SimpleBeansetModuleDefinition

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.