Java Code Examples for org.springframework.tests.sample.beans.ITestBean#toString()

The following examples show how to use org.springframework.tests.sample.beans.ITestBean#toString() . 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: JndiObjectFactoryBeanTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testLookupWithExposeAccessContext() throws Exception {
	JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
	TestBean tb = new TestBean();
	final Context mockCtx = mock(Context.class);
	given(mockCtx.lookup("foo")).willReturn(tb);
	jof.setJndiTemplate(new JndiTemplate() {
		@Override
		protected Context createInitialContext() {
			return mockCtx;
		}
	});
	jof.setJndiName("foo");
	jof.setProxyInterface(ITestBean.class);
	jof.setExposeAccessContext(true);
	jof.afterPropertiesSet();
	assertTrue(jof.getObject() instanceof ITestBean);
	ITestBean proxy = (ITestBean) jof.getObject();
	assertEquals(0, tb.getAge());
	proxy.setAge(99);
	assertEquals(99, tb.getAge());
	proxy.equals(proxy);
	proxy.hashCode();
	proxy.toString();
	verify(mockCtx, times(2)).close();
}
 
Example 2
Source File: JndiObjectFactoryBeanTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testLookupWithExposeAccessContext() throws Exception {
	JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
	TestBean tb = new TestBean();
	final Context mockCtx = mock(Context.class);
	given(mockCtx.lookup("foo")).willReturn(tb);
	jof.setJndiTemplate(new JndiTemplate() {
		@Override
		protected Context createInitialContext() {
			return mockCtx;
		}
	});
	jof.setJndiName("foo");
	jof.setProxyInterface(ITestBean.class);
	jof.setExposeAccessContext(true);
	jof.afterPropertiesSet();
	assertTrue(jof.getObject() instanceof ITestBean);
	ITestBean proxy = (ITestBean) jof.getObject();
	assertEquals(0, tb.getAge());
	proxy.setAge(99);
	assertEquals(99, tb.getAge());
	proxy.equals(proxy);
	proxy.hashCode();
	proxy.toString();
	verify(mockCtx, times(2)).close();
}
 
Example 3
Source File: JndiObjectFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testLookupWithExposeAccessContext() throws Exception {
	JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
	TestBean tb = new TestBean();
	final Context mockCtx = mock(Context.class);
	given(mockCtx.lookup("foo")).willReturn(tb);
	jof.setJndiTemplate(new JndiTemplate() {
		@Override
		protected Context createInitialContext() {
			return mockCtx;
		}
	});
	jof.setJndiName("foo");
	jof.setProxyInterface(ITestBean.class);
	jof.setExposeAccessContext(true);
	jof.afterPropertiesSet();
	assertTrue(jof.getObject() instanceof ITestBean);
	ITestBean proxy = (ITestBean) jof.getObject();
	assertEquals(0, tb.getAge());
	proxy.setAge(99);
	assertEquals(99, tb.getAge());
	proxy.equals(proxy);
	proxy.hashCode();
	proxy.toString();
	verify(mockCtx, times(2)).close();
}
 
Example 4
Source File: ProxyFactoryBeanTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMethodPointcuts() {
	ITestBean tb = (ITestBean) factory.getBean("pointcuts");
	PointcutForVoid.reset();
	assertTrue("No methods intercepted", PointcutForVoid.methodNames.isEmpty());
	tb.getAge();
	assertTrue("Not void: shouldn't have intercepted", PointcutForVoid.methodNames.isEmpty());
	tb.setAge(1);
	tb.getAge();
	tb.setName("Tristan");
	tb.toString();
	assertEquals("Recorded wrong number of invocations", 2, PointcutForVoid.methodNames.size());
	assertTrue(PointcutForVoid.methodNames.get(0).equals("setAge"));
	assertTrue(PointcutForVoid.methodNames.get(1).equals("setName"));
}
 
Example 5
Source File: ProxyFactoryBeanTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMethodPointcuts() {
	ITestBean tb = (ITestBean) factory.getBean("pointcuts");
	PointcutForVoid.reset();
	assertTrue("No methods intercepted", PointcutForVoid.methodNames.isEmpty());
	tb.getAge();
	assertTrue("Not void: shouldn't have intercepted", PointcutForVoid.methodNames.isEmpty());
	tb.setAge(1);
	tb.getAge();
	tb.setName("Tristan");
	tb.toString();
	assertEquals("Recorded wrong number of invocations", 2, PointcutForVoid.methodNames.size());
	assertTrue(PointcutForVoid.methodNames.get(0).equals("setAge"));
	assertTrue(PointcutForVoid.methodNames.get(1).equals("setName"));
}
 
Example 6
Source File: ProxyFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMethodPointcuts() {
	ITestBean tb = (ITestBean) factory.getBean("pointcuts");
	PointcutForVoid.reset();
	assertTrue("No methods intercepted", PointcutForVoid.methodNames.isEmpty());
	tb.getAge();
	assertTrue("Not void: shouldn't have intercepted", PointcutForVoid.methodNames.isEmpty());
	tb.setAge(1);
	tb.getAge();
	tb.setName("Tristan");
	tb.toString();
	assertEquals("Recorded wrong number of invocations", 2, PointcutForVoid.methodNames.size());
	assertTrue(PointcutForVoid.methodNames.get(0).equals("setAge"));
	assertTrue(PointcutForVoid.methodNames.get(1).equals("setName"));
}