Package org.springframework.beans.factory.parsing

Examples of org.springframework.beans.factory.parsing.ComponentDefinition


    assertEquals("true", defaults.getMerge());
    assertTrue(defaults.getSource() instanceof Element);
  }

  public void testBeanEventReceived() throws Exception {
    ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
    assertTrue(componentDefinition1 instanceof BeanComponentDefinition);
    assertEquals(1, componentDefinition1.getBeanDefinitions().length);
    BeanDefinition beanDefinition1 = componentDefinition1.getBeanDefinitions()[0];
    assertEquals(new TypedStringValue("Rob Harrop"),
        beanDefinition1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
    assertEquals(1, componentDefinition1.getBeanReferences().length);
    assertEquals("testBean2", componentDefinition1.getBeanReferences()[0].getBeanName());
    assertEquals(1, componentDefinition1.getInnerBeanDefinitions().length);
    BeanDefinition innerBd1 = componentDefinition1.getInnerBeanDefinitions()[0];
    assertEquals(new TypedStringValue("ACME"),
        innerBd1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue());
    assertTrue(componentDefinition1.getSource() instanceof Element);

    ComponentDefinition componentDefinition2 = this.eventListener.getComponentDefinition("testBean2");
    assertTrue(componentDefinition2 instanceof BeanComponentDefinition);
    assertEquals(1, componentDefinition1.getBeanDefinitions().length);
    BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0];
    assertEquals(new TypedStringValue("Juergen Hoeller"),
        beanDefinition2.getPropertyValues().getPropertyValue("name").getValue());
    assertEquals(0, componentDefinition2.getBeanReferences().length);
    assertEquals(1, componentDefinition2.getInnerBeanDefinitions().length);
    BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0];
    assertEquals(new TypedStringValue("Eva Schallmeiner"),
        innerBd2.getPropertyValues().getPropertyValue("name").getValue());
    assertTrue(componentDefinition2.getSource() instanceof Element);
  }
View Full Code Here


    Integer max = (Integer) this.beanFactory.getBean("java.lang.Integer.MAX_VALUE");
    assertEquals(Integer.MAX_VALUE, max.intValue());
  }

  public void testEvents() throws Exception {
    ComponentDefinition propertiesComponent = this.listener.getComponentDefinition("myProperties");
    assertNotNull("Event for 'myProperties' not sent", propertiesComponent);
    AbstractBeanDefinition propertiesBean = (AbstractBeanDefinition) propertiesComponent.getBeanDefinitions()[0];
    assertEquals("Incorrect BeanDefinition", PropertiesFactoryBean.class, propertiesBean.getBeanClass());

    ComponentDefinition constantComponent = this.listener.getComponentDefinition("min");
    assertNotNull("Event for 'min' not sent", propertiesComponent);
    AbstractBeanDefinition constantBean = (AbstractBeanDefinition) constantComponent.getBeanDefinitions()[0];
    assertEquals("Incorrect BeanDefinition", FieldRetrievingFactoryBean.class, constantBean.getBeanClass());
  }
View Full Code Here

  }

  public void testSourceExtraction() {
    Iterator iterator = context.getRegisteredComponents();
    while (iterator.hasNext()) {
      ComponentDefinition compDef = (ComponentDefinition) iterator.next();
      if (compDef instanceof CompositeComponentDefinition) {
        assertNotNull("CompositeComponentDefinition '" + compDef.getName()+ "' has no source attachment", ((CompositeComponentDefinition) compDef).getSource());
      }
      validateComponentDefinition(compDef);
    }
  }
View Full Code Here

    reader.setEventListener(this.eventListener);
    reader.loadBeanDefinitions(new ClassPathResource("txNamespaceHandlerTests.xml", getClass()));
  }

  public void testComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("txAdvice");
    assertTrue(component instanceof BeanComponentDefinition);
  }
View Full Code Here

    }
   
    public boolean containsComponentDefinition(String name) {
      Iterator iterator = REGISTERED_COMPONENTS.iterator();
      while (iterator.hasNext()) {
        ComponentDefinition cd = (ComponentDefinition) iterator.next();
        if (cd instanceof CompositeComponentDefinition) {
          ComponentDefinition[] innerCds = ((CompositeComponentDefinition) cd)
              .getNestedComponents();
          for (int i = 0; i < innerCds.length; i++) {
            if (innerCds[i].getName().equals(name)) {
              return true;
            }
          }
        }
        else {
          if (cd.getName().equals(name)) {
            return true;
          }
        }
      }
      return false;
View Full Code Here

    this.reader.setEventListener(this.eventListener);
    this.reader.loadBeanDefinitions(new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
  }

  public void testJndiLookupComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
    assertTrue(component instanceof BeanComponentDefinition);
  }
View Full Code Here

    ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
    assertTrue(component instanceof BeanComponentDefinition);
  }

  public void testLocalSlsbComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
    assertTrue(component instanceof BeanComponentDefinition);
  }
View Full Code Here

    ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
    assertTrue(component instanceof BeanComponentDefinition);
  }

  public void testRemoteSlsbComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
    assertTrue(component instanceof BeanComponentDefinition);
  }
View Full Code Here

    ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
    assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
    PointcutComponentDefinition pcd = null;
    for (int i = 0; i < nestedComponentDefs.length; i++) {
      ComponentDefinition componentDefinition = nestedComponentDefs[i];
      if (componentDefinition instanceof PointcutComponentDefinition) {
        pcd = (PointcutComponentDefinition) componentDefinition;
        break;
      }
    }
View Full Code Here

    ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
    assertEquals("Incorrect number of inner components", 3, nestedComponentDefs.length);
    AdvisorComponentDefinition acd = null;
    for (int i = 0; i < nestedComponentDefs.length; i++) {
      ComponentDefinition componentDefinition = nestedComponentDefs[i];
      if (componentDefinition instanceof AdvisorComponentDefinition) {
        acd = (AdvisorComponentDefinition) componentDefinition;
        break;
      }
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.parsing.ComponentDefinition

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.