org.springframework.scripting.TestBeanAwareMessenger Java Examples

The following examples show how to use org.springframework.scripting.TestBeanAwareMessenger. 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: BshScriptFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void resourceScriptFromTag() {
	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
	TestBean testBean = (TestBean) ctx.getBean("testBean");

	Collection<String> beanNames = Arrays.asList(ctx.getBeanNamesForType(Messenger.class));
	assertTrue(beanNames.contains("messenger"));
	assertTrue(beanNames.contains("messengerImpl"));
	assertTrue(beanNames.contains("messengerInstance"));

	Messenger messenger = (Messenger) ctx.getBean("messenger");
	assertEquals("Hello World!", messenger.getMessage());
	assertFalse(messenger instanceof Refreshable);

	Messenger messengerImpl = (Messenger) ctx.getBean("messengerImpl");
	assertEquals("Hello World!", messengerImpl.getMessage());

	Messenger messengerInstance = (Messenger) ctx.getBean("messengerInstance");
	assertEquals("Hello World!", messengerInstance.getMessage());

	TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
	assertEquals(testBean, messengerByType.getTestBean());

	TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
	assertEquals(testBean, messengerByName.getTestBean());

	Collection<Messenger> beans = ctx.getBeansOfType(Messenger.class).values();
	assertTrue(beans.contains(messenger));
	assertTrue(beans.contains(messengerImpl));
	assertTrue(beans.contains(messengerInstance));
	assertTrue(beans.contains(messengerByType));
	assertTrue(beans.contains(messengerByName));

	ctx.close();
	assertNull(messenger.getMessage());
	assertNull(messengerImpl.getMessage());
	assertNull(messengerInstance.getMessage());
}
 
Example #2
Source File: BshScriptFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void resourceScriptFromTag() {
	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
	TestBean testBean = (TestBean) ctx.getBean("testBean");

	Collection<String> beanNames = Arrays.asList(ctx.getBeanNamesForType(Messenger.class));
	assertTrue(beanNames.contains("messenger"));
	assertTrue(beanNames.contains("messengerImpl"));
	assertTrue(beanNames.contains("messengerInstance"));

	Messenger messenger = (Messenger) ctx.getBean("messenger");
	assertEquals("Hello World!", messenger.getMessage());
	assertFalse(messenger instanceof Refreshable);

	Messenger messengerImpl = (Messenger) ctx.getBean("messengerImpl");
	assertEquals("Hello World!", messengerImpl.getMessage());

	Messenger messengerInstance = (Messenger) ctx.getBean("messengerInstance");
	assertEquals("Hello World!", messengerInstance.getMessage());

	TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
	assertEquals(testBean, messengerByType.getTestBean());

	TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
	assertEquals(testBean, messengerByName.getTestBean());

	Collection<Messenger> beans = ctx.getBeansOfType(Messenger.class).values();
	assertTrue(beans.contains(messenger));
	assertTrue(beans.contains(messengerImpl));
	assertTrue(beans.contains(messengerInstance));
	assertTrue(beans.contains(messengerByType));
	assertTrue(beans.contains(messengerByName));

	ctx.close();
	assertNull(messenger.getMessage());
	assertNull(messengerImpl.getMessage());
	assertNull(messengerInstance.getMessage());
}
 
Example #3
Source File: JRubyScriptFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testResourceScriptFromTag() throws Exception {
	ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
	TestBean testBean = (TestBean) ctx.getBean("testBean");

	Messenger messenger = (Messenger) ctx.getBean("messenger");
	assertEquals("Hello World!", messenger.getMessage());
	assertFalse(messenger instanceof Refreshable);

	TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
	assertEquals(testBean, messengerByType.getTestBean());

	TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
	assertEquals(testBean, messengerByName.getTestBean());
}
 
Example #4
Source File: BshScriptFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void resourceScriptFromTag() throws Exception {
	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
	TestBean testBean = (TestBean) ctx.getBean("testBean");

	Collection<String> beanNames = Arrays.asList(ctx.getBeanNamesForType(Messenger.class));
	assertTrue(beanNames.contains("messenger"));
	assertTrue(beanNames.contains("messengerImpl"));
	assertTrue(beanNames.contains("messengerInstance"));

	Messenger messenger = (Messenger) ctx.getBean("messenger");
	assertEquals("Hello World!", messenger.getMessage());
	assertFalse(messenger instanceof Refreshable);

	Messenger messengerImpl = (Messenger) ctx.getBean("messengerImpl");
	assertEquals("Hello World!", messengerImpl.getMessage());

	Messenger messengerInstance = (Messenger) ctx.getBean("messengerInstance");
	assertEquals("Hello World!", messengerInstance.getMessage());

	TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
	assertEquals(testBean, messengerByType.getTestBean());

	TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
	assertEquals(testBean, messengerByName.getTestBean());

	Collection<Messenger> beans = ctx.getBeansOfType(Messenger.class).values();
	assertTrue(beans.contains(messenger));
	assertTrue(beans.contains(messengerImpl));
	assertTrue(beans.contains(messengerInstance));
	assertTrue(beans.contains(messengerByType));
	assertTrue(beans.contains(messengerByName));

	ctx.close();
	assertNull(messenger.getMessage());
	assertNull(messengerImpl.getMessage());
	assertNull(messengerInstance.getMessage());
}