Search in sources :

Example 1 with ComponentDefinition

use of cn.taketoday.beans.factory.parsing.ComponentDefinition in project today-infrastructure by TAKETODAY.

the class AopNamespaceHandlerEventTests method pointcutEvents.

@Test
void pointcutEvents() {
    this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT);
    ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
    assertThat(componentDefinitions).as("Incorrect number of events fired").hasSize(1);
    assertThat(componentDefinitions[0]).as("No holder with nested components").isInstanceOf(CompositeComponentDefinition.class);
    CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0];
    assertThat(compositeDef.getName()).isEqualTo("aop:config");
    ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
    assertThat(nestedComponentDefs).as("Incorrect number of inner components").hasSize(2);
    PointcutComponentDefinition pcd = null;
    for (ComponentDefinition componentDefinition : nestedComponentDefs) {
        if (componentDefinition instanceof PointcutComponentDefinition) {
            pcd = (PointcutComponentDefinition) componentDefinition;
            break;
        }
    }
    assertThat(pcd).as("PointcutComponentDefinition not found").isNotNull();
    assertThat(pcd.getBeanDefinitions()).as("Incorrect number of BeanDefinitions").hasSize(1);
}
Also used : CompositeComponentDefinition(cn.taketoday.beans.factory.parsing.CompositeComponentDefinition) CompositeComponentDefinition(cn.taketoday.beans.factory.parsing.CompositeComponentDefinition) ComponentDefinition(cn.taketoday.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with ComponentDefinition

use of cn.taketoday.beans.factory.parsing.ComponentDefinition in project today-infrastructure by TAKETODAY.

the class JeeNamespaceHandlerEventTests method testLocalSlsbComponentEventReceived.

@Test
public void testLocalSlsbComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
    boolean condition = component instanceof BeanComponentDefinition;
    assertThat(condition).isTrue();
}
Also used : BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) ComponentDefinition(cn.taketoday.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.jupiter.api.Test)

Example 3 with ComponentDefinition

use of cn.taketoday.beans.factory.parsing.ComponentDefinition in project today-infrastructure by TAKETODAY.

the class JeeNamespaceHandlerEventTests method testRemoteSlsbComponentEventReceived.

@Test
public void testRemoteSlsbComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
    boolean condition = component instanceof BeanComponentDefinition;
    assertThat(condition).isTrue();
}
Also used : BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) ComponentDefinition(cn.taketoday.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.jupiter.api.Test)

Example 4 with ComponentDefinition

use of cn.taketoday.beans.factory.parsing.ComponentDefinition in project today-infrastructure by TAKETODAY.

the class EventPublicationTests method beanEventReceived.

@Test
public void beanEventReceived() throws Exception {
    ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
    boolean condition3 = componentDefinition1 instanceof BeanComponentDefinition;
    assertThat(condition3).isTrue();
    assertThat(componentDefinition1.getBeanDefinitions().length).isEqualTo(1);
    BeanDefinition beanDefinition1 = componentDefinition1.getBeanDefinitions()[0];
    assertThat(beanDefinition1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue()).isEqualTo(new TypedStringValue("Rob Harrop"));
    assertThat(componentDefinition1.getBeanReferences().length).isEqualTo(1);
    assertThat(componentDefinition1.getBeanReferences()[0].getBeanName()).isEqualTo("testBean2");
    assertThat(componentDefinition1.getInnerBeanDefinitions().length).isEqualTo(1);
    BeanDefinition innerBd1 = componentDefinition1.getInnerBeanDefinitions()[0];
    assertThat(innerBd1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue()).isEqualTo(new TypedStringValue("ACME"));
    boolean condition2 = componentDefinition1.getSource() instanceof Element;
    assertThat(condition2).isTrue();
    ComponentDefinition componentDefinition2 = this.eventListener.getComponentDefinition("testBean2");
    boolean condition1 = componentDefinition2 instanceof BeanComponentDefinition;
    assertThat(condition1).isTrue();
    assertThat(componentDefinition1.getBeanDefinitions().length).isEqualTo(1);
    BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0];
    assertThat(beanDefinition2.getPropertyValues().getPropertyValue("name")).isEqualTo(new TypedStringValue("Juergen Hoeller"));
    assertThat(componentDefinition2.getBeanReferences().length).isEqualTo(0);
    assertThat(componentDefinition2.getInnerBeanDefinitions().length).isEqualTo(1);
    BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0];
    assertThat(innerBd2.getPropertyValues().getPropertyValue("name")).isEqualTo(new TypedStringValue("Eva Schallmeiner"));
    boolean condition = componentDefinition2.getSource() instanceof Element;
    assertThat(condition).isTrue();
}
Also used : Element(org.w3c.dom.Element) BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) TypedStringValue(cn.taketoday.beans.factory.config.TypedStringValue) BeanDefinition(cn.taketoday.beans.factory.config.BeanDefinition) ComponentDefinition(cn.taketoday.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.jupiter.api.Test)

Example 5 with ComponentDefinition

use of cn.taketoday.beans.factory.parsing.ComponentDefinition in project today-framework by TAKETODAY.

the class JeeNamespaceHandlerEventTests method testJndiLookupComponentEventReceived.

@Test
public void testJndiLookupComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
    boolean condition = component instanceof BeanComponentDefinition;
    assertThat(condition).isTrue();
}
Also used : BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) ComponentDefinition(cn.taketoday.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(cn.taketoday.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

ComponentDefinition (cn.taketoday.beans.factory.parsing.ComponentDefinition)18 Test (org.junit.jupiter.api.Test)18 BeanComponentDefinition (cn.taketoday.beans.factory.parsing.BeanComponentDefinition)16 CompositeComponentDefinition (cn.taketoday.beans.factory.parsing.CompositeComponentDefinition)8 BeanDefinition (cn.taketoday.beans.factory.config.BeanDefinition)4 BeanReference (cn.taketoday.beans.factory.config.BeanReference)2 TypedStringValue (cn.taketoday.beans.factory.config.TypedStringValue)2 AbstractBeanDefinition (cn.taketoday.beans.factory.support.AbstractBeanDefinition)2 HashSet (java.util.HashSet)2 Element (org.w3c.dom.Element)2