Search in sources :

Example 6 with Employee

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

the class GroovyControlGroupTests method verifyScriptUsingGenericGroovyApplicationContext.

@Test
@SuppressWarnings("resource")
public void verifyScriptUsingGenericGroovyApplicationContext() {
    ApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy");
    String foo = ctx.getBean("foo", String.class);
    assertEquals("Foo", foo);
    String bar = ctx.getBean("bar", String.class);
    assertEquals("Bar", bar);
    Pet pet = ctx.getBean(Pet.class);
    assertNotNull("pet", pet);
    assertEquals("Dogbert", pet.getName());
    Employee employee = ctx.getBean(Employee.class);
    assertNotNull("employee", employee);
    assertEquals("Dilbert", employee.getName());
    assertEquals("???", employee.getCompany());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) Employee(org.springframework.tests.sample.beans.Employee) Pet(org.springframework.tests.sample.beans.Pet) Test(org.junit.Test)

Aggregations

Employee (org.springframework.tests.sample.beans.Employee)6 Test (org.junit.Test)3 Bean (org.springframework.context.annotation.Bean)2 ApplicationContext (org.springframework.context.ApplicationContext)1 GenericGroovyApplicationContext (org.springframework.context.support.GenericGroovyApplicationContext)1 Pet (org.springframework.tests.sample.beans.Pet)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Test (org.testng.annotations.Test)1