Search in sources :

Example 6 with Employee

use of org.springframework.beans.testfixture.beans.Employee in project spring-framework by spring-projects.

the class GroovyControlGroupTests method verifyScriptUsingGenericGroovyApplicationContext.

@Test
@SuppressWarnings("resource")
void verifyScriptUsingGenericGroovyApplicationContext() {
    ApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy");
    String foo = ctx.getBean("foo", String.class);
    assertThat(foo).isEqualTo("Foo");
    String bar = ctx.getBean("bar", String.class);
    assertThat(bar).isEqualTo("Bar");
    Pet pet = ctx.getBean(Pet.class);
    assertThat(pet).as("pet").isNotNull();
    assertThat(pet.getName()).isEqualTo("Dogbert");
    Employee employee = ctx.getBean(Employee.class);
    assertThat(employee).as("employee").isNotNull();
    assertThat(employee.getName()).isEqualTo("Dilbert");
    assertThat(employee.getCompany()).isEqualTo("???");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) Employee(org.springframework.beans.testfixture.beans.Employee) Pet(org.springframework.beans.testfixture.beans.Pet) Test(org.junit.jupiter.api.Test)

Aggregations

Employee (org.springframework.beans.testfixture.beans.Employee)6 Test (org.junit.Test)2 Bean (org.springframework.context.annotation.Bean)2 Test (org.junit.jupiter.api.Test)1 Pet (org.springframework.beans.testfixture.beans.Pet)1 ApplicationContext (org.springframework.context.ApplicationContext)1 GenericGroovyApplicationContext (org.springframework.context.support.GenericGroovyApplicationContext)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Test (org.testng.annotations.Test)1