org.springframework.context.support.GenericGroovyApplicationContext Java Examples

The following examples show how to use org.springframework.context.support.GenericGroovyApplicationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyControlGroupTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: GroovyControlGroupTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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());
}
 
Example #3
Source File: GroovyControlGroupTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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());
}
 
Example #4
Source File: GroovyApplicationContextTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
}
 
Example #5
Source File: GroovyConfigurationUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenGroovyConfig_thenCorrectListLength() throws Exception {
    
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
    ctx.load("file:" + getPathPart() + FILE_NAME);
    ctx.refresh();

    BandsBean bb = ctx.getBean(BandsBean.class);

    assertEquals(3, bb.getBandsList()
        .size());
}
 
Example #6
Source File: GroovyConfigurationUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenGroovyConfig_thenCorrectPerson() throws Exception {

    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
    ctx.load("file:" + getPathPart() + FILE_NAME);
    ctx.refresh();

    JavaPersonBean j = ctx.getBean(JavaPersonBean.class);

    assertEquals("32", j.getAge());
    assertEquals("blue", j.getEyesColor());
    assertEquals("black", j.getHairColor());
}
 
Example #7
Source File: GroovyApplicationContextTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: GroovyApplicationContextTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: GroovyApplicationContextTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: GroovyApplicationContextTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
}
 
Example #11
Source File: GroovyApplicationContextTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
}
 
Example #12
Source File: GroovyApplicationContextTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
}
 
Example #13
Source File: GroovyApplicationContextTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
}
 
Example #14
Source File: GroovyApplicationContextTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
}
 
Example #15
Source File: GroovyApplicationContextTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test(expected = BeanDefinitionParsingException.class)
public void testConfigFileParsingError() {
	new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext-error.groovy");
}
 
Example #16
Source File: GroovyApplicationContextTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test(expected = BeanDefinitionParsingException.class)
public void testConfigFileParsingError() {
	new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext-error.groovy");
}
 
Example #17
Source File: GroovyApplicationContextTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test(expected = BeanDefinitionParsingException.class)
public void testConfigFileParsingError() {
	new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext-error.groovy");
}