Search in sources :

Example 1 with GenericGroovyApplicationContext

use of org.springframework.context.support.GenericGroovyApplicationContext in project spring-framework by spring-projects.

the class GroovyApplicationContextTests method testLoadingMultipleConfigFilesWithRelativeClass.

@Test
public void testLoadingMultipleConfigFilesWithRelativeClass() {
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
    ctx.load(GroovyApplicationContextTests.class, "applicationContext2.groovy", "applicationContext.groovy");
    ctx.refresh();
    Object framework = ctx.getBean("framework");
    assertNotNull("could not find framework bean", framework);
    assertEquals("Grails", framework);
    Object company = ctx.getBean("company");
    assertNotNull("could not find company bean", company);
    assertEquals("SpringSource", company);
}
Also used : GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) Test(org.junit.Test)

Example 2 with GenericGroovyApplicationContext

use of org.springframework.context.support.GenericGroovyApplicationContext in project spring-framework by spring-projects.

the class GroovyApplicationContextTests method testLoadingMultipleConfigFiles.

@Test
public void testLoadingMultipleConfigFiles() {
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext2.groovy", "org/springframework/context/groovy/applicationContext.groovy");
    Object framework = ctx.getBean("framework");
    assertNotNull("could not find framework bean", framework);
    assertEquals("Grails", framework);
    Object company = ctx.getBean("company");
    assertNotNull("could not find company bean", company);
    assertEquals("SpringSource", company);
}
Also used : GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) Test(org.junit.Test)

Example 3 with GenericGroovyApplicationContext

use of org.springframework.context.support.GenericGroovyApplicationContext 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)

Example 4 with GenericGroovyApplicationContext

use of org.springframework.context.support.GenericGroovyApplicationContext in project spring-framework by spring-projects.

the class GroovyApplicationContextTests method testLoadingConfigFile.

@Test
public void testLoadingConfigFile() {
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext.groovy");
    Object framework = ctx.getBean("framework");
    assertNotNull("could not find framework bean", framework);
    assertEquals("Grails", framework);
}
Also used : GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) Test(org.junit.Test)

Example 5 with GenericGroovyApplicationContext

use of org.springframework.context.support.GenericGroovyApplicationContext in project cradle by BingLau7.

the class Main method groovyLoadBean.

public static void groovyLoadBean() {
    GenericApplicationContext context = new GenericGroovyApplicationContext("services.groovy");
    TestBean testBean = context.getBean("testBean", TestBean.class);
    System.out.println(testBean);
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext)

Aggregations

GenericGroovyApplicationContext (org.springframework.context.support.GenericGroovyApplicationContext)5 Test (org.junit.Test)4 ApplicationContext (org.springframework.context.ApplicationContext)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1 Employee (org.springframework.tests.sample.beans.Employee)1 Pet (org.springframework.tests.sample.beans.Pet)1