org.springframework.scripting.CallCounter Java Examples

The following examples show how to use org.springframework.scripting.CallCounter. 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: GroovyScriptFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testRefreshableFromTag() throws Exception {
	ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
	assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("refreshableMessenger"));

	Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
	CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertTrue(messenger instanceof Refreshable);
	assertEquals(0, countingAspect.getCalls());
	assertEquals("Hello World!", messenger.getMessage());
	assertEquals(1, countingAspect.getCalls());

	assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
}
 
Example #2
Source File: GroovyScriptFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testRefreshableFromTag() throws Exception {
	ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
	assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("refreshableMessenger"));

	Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
	CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertTrue(messenger instanceof Refreshable);
	assertEquals(0, countingAspect.getCalls());
	assertEquals("Hello World!", messenger.getMessage());
	assertEquals(1, countingAspect.getCalls());

	assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
}
 
Example #3
Source File: GroovyScriptFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testRefreshableFromTag() throws Exception {
	ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
	assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("refreshableMessenger"));

	Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
	CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertTrue(messenger instanceof Refreshable);
	assertEquals(0, countingAspect.getCalls());
	assertEquals("Hello World!", messenger.getMessage());
	assertEquals(1, countingAspect.getCalls());

	assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
}
 
Example #4
Source File: GroovyScriptFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testResourceScriptFromTag() throws Exception {
	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
	Messenger messenger = (Messenger) ctx.getBean("messenger");
	CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertFalse(messenger instanceof Refreshable);
	assertEquals(0, countingAspect.getCalls());
	assertEquals("Hello World!", messenger.getMessage());
	assertEquals(1, countingAspect.getCalls());

	ctx.close();
	assertEquals(-200, countingAspect.getCalls());
}
 
Example #5
Source File: GroovyScriptFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testResourceScriptFromTag() throws Exception {
	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
	Messenger messenger = (Messenger) ctx.getBean("messenger");
	CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertFalse(messenger instanceof Refreshable);
	assertEquals(0, countingAspect.getCalls());
	assertEquals("Hello World!", messenger.getMessage());
	assertEquals(1, countingAspect.getCalls());

	ctx.close();
	assertEquals(-200, countingAspect.getCalls());
}
 
Example #6
Source File: GroovyScriptFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testResourceScriptFromTag() throws Exception {
	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
	Messenger messenger = (Messenger) ctx.getBean("messenger");
	CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");

	assertTrue(AopUtils.isAopProxy(messenger));
	assertFalse(messenger instanceof Refreshable);
	assertEquals(0, countingAspect.getCalls());
	assertEquals("Hello World!", messenger.getMessage());
	assertEquals(1, countingAspect.getCalls());

	ctx.close();
	assertEquals(-200, countingAspect.getCalls());
}