Java Code Examples for org.springframework.tests.sample.beans.TestBean#setTouchy()

The following examples show how to use org.springframework.tests.sample.beans.TestBean#setTouchy() . 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: BeanUtilsTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testCopyPropertiesWithEditable() throws Exception {
	TestBean tb = new TestBean();
	assertTrue("Name empty", tb.getName() == null);
	tb.setAge(32);
	tb.setTouchy("bla");
	TestBean tb2 = new TestBean();
	tb2.setName("rod");
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);

	// "touchy" should not be copied: it's not defined in ITestBean
	BeanUtils.copyProperties(tb, tb2, ITestBean.class);
	assertTrue("Name copied", tb2.getName() == null);
	assertTrue("Age copied", tb2.getAge() == 32);
	assertTrue("Touchy still empty", tb2.getTouchy() == null);
}
 
Example 2
Source File: BeanUtilsTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testCopyPropertiesWithIgnore() throws Exception {
	TestBean tb = new TestBean();
	assertTrue("Name empty", tb.getName() == null);
	tb.setAge(32);
	tb.setTouchy("bla");
	TestBean tb2 = new TestBean();
	tb2.setName("rod");
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);

	// "spouse", "touchy", "age" should not be copied
	BeanUtils.copyProperties(tb, tb2, "spouse", "touchy", "age");
	assertTrue("Name copied", tb2.getName() == null);
	assertTrue("Age still empty", tb2.getAge() == 0);
	assertTrue("Touchy still empty", tb2.getTouchy() == null);
}
 
Example 3
Source File: BeanUtilsTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testCopyPropertiesWithEditable() throws Exception {
	TestBean tb = new TestBean();
	assertTrue("Name empty", tb.getName() == null);
	tb.setAge(32);
	tb.setTouchy("bla");
	TestBean tb2 = new TestBean();
	tb2.setName("rod");
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);

	// "touchy" should not be copied: it's not defined in ITestBean
	BeanUtils.copyProperties(tb, tb2, ITestBean.class);
	assertTrue("Name copied", tb2.getName() == null);
	assertTrue("Age copied", tb2.getAge() == 32);
	assertTrue("Touchy still empty", tb2.getTouchy() == null);
}
 
Example 4
Source File: BeanUtilsTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testCopyPropertiesWithIgnore() throws Exception {
	TestBean tb = new TestBean();
	assertTrue("Name empty", tb.getName() == null);
	tb.setAge(32);
	tb.setTouchy("bla");
	TestBean tb2 = new TestBean();
	tb2.setName("rod");
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);

	// "spouse", "touchy", "age" should not be copied
	BeanUtils.copyProperties(tb, tb2, "spouse", "touchy", "age");
	assertTrue("Name copied", tb2.getName() == null);
	assertTrue("Age still empty", tb2.getAge() == 0);
	assertTrue("Touchy still empty", tb2.getTouchy() == null);
}
 
Example 5
Source File: BeanUtilsTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testCopyPropertiesWithEditable() throws Exception {
	TestBean tb = new TestBean();
	assertTrue("Name empty", tb.getName() == null);
	tb.setAge(32);
	tb.setTouchy("bla");
	TestBean tb2 = new TestBean();
	tb2.setName("rod");
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);

	// "touchy" should not be copied: it's not defined in ITestBean
	BeanUtils.copyProperties(tb, tb2, ITestBean.class);
	assertTrue("Name copied", tb2.getName() == null);
	assertTrue("Age copied", tb2.getAge() == 32);
	assertTrue("Touchy still empty", tb2.getTouchy() == null);
}
 
Example 6
Source File: BeanUtilsTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testCopyPropertiesWithIgnore() throws Exception {
	TestBean tb = new TestBean();
	assertTrue("Name empty", tb.getName() == null);
	tb.setAge(32);
	tb.setTouchy("bla");
	TestBean tb2 = new TestBean();
	tb2.setName("rod");
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);

	// "spouse", "touchy", "age" should not be copied
	BeanUtils.copyProperties(tb, tb2, "spouse", "touchy", "age");
	assertTrue("Name copied", tb2.getName() == null);
	assertTrue("Age still empty", tb2.getAge() == 0);
	assertTrue("Touchy still empty", tb2.getTouchy() == null);
}
 
Example 7
Source File: BeanUtilsTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testCopyProperties() throws Exception {
	TestBean tb = new TestBean();
	tb.setName("rod");
	tb.setAge(32);
	tb.setTouchy("touchy");
	TestBean tb2 = new TestBean();
	assertTrue("Name empty", tb2.getName() == null);
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);
	BeanUtils.copyProperties(tb, tb2);
	assertTrue("Name copied", tb2.getName().equals(tb.getName()));
	assertTrue("Age copied", tb2.getAge() == tb.getAge());
	assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
}
 
Example 8
Source File: BeanUtilsTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testCopyPropertiesWithDifferentTypes2() throws Exception {
	TestBean tb = new TestBean();
	tb.setName("rod");
	tb.setAge(32);
	tb.setTouchy("touchy");
	DerivedTestBean tb2 = new DerivedTestBean();
	assertTrue("Name empty", tb2.getName() == null);
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);
	BeanUtils.copyProperties(tb, tb2);
	assertTrue("Name copied", tb2.getName().equals(tb.getName()));
	assertTrue("Age copied", tb2.getAge() == tb.getAge());
	assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
}
 
Example 9
Source File: BeanUtilsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testCopyProperties() throws Exception {
	TestBean tb = new TestBean();
	tb.setName("rod");
	tb.setAge(32);
	tb.setTouchy("touchy");
	TestBean tb2 = new TestBean();
	assertTrue("Name empty", tb2.getName() == null);
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);
	BeanUtils.copyProperties(tb, tb2);
	assertTrue("Name copied", tb2.getName().equals(tb.getName()));
	assertTrue("Age copied", tb2.getAge() == tb.getAge());
	assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
}
 
Example 10
Source File: BeanUtilsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testCopyPropertiesWithDifferentTypes2() throws Exception {
	TestBean tb = new TestBean();
	tb.setName("rod");
	tb.setAge(32);
	tb.setTouchy("touchy");
	DerivedTestBean tb2 = new DerivedTestBean();
	assertTrue("Name empty", tb2.getName() == null);
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);
	BeanUtils.copyProperties(tb, tb2);
	assertTrue("Name copied", tb2.getName().equals(tb.getName()));
	assertTrue("Age copied", tb2.getAge() == tb.getAge());
	assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
}
 
Example 11
Source File: BeanUtilsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyProperties() throws Exception {
	TestBean tb = new TestBean();
	tb.setName("rod");
	tb.setAge(32);
	tb.setTouchy("touchy");
	TestBean tb2 = new TestBean();
	assertTrue("Name empty", tb2.getName() == null);
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);
	BeanUtils.copyProperties(tb, tb2);
	assertTrue("Name copied", tb2.getName().equals(tb.getName()));
	assertTrue("Age copied", tb2.getAge() == tb.getAge());
	assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
}
 
Example 12
Source File: BeanUtilsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyPropertiesWithDifferentTypes2() throws Exception {
	TestBean tb = new TestBean();
	tb.setName("rod");
	tb.setAge(32);
	tb.setTouchy("touchy");
	DerivedTestBean tb2 = new DerivedTestBean();
	assertTrue("Name empty", tb2.getName() == null);
	assertTrue("Age empty", tb2.getAge() == 0);
	assertTrue("Touchy empty", tb2.getTouchy() == null);
	BeanUtils.copyProperties(tb, tb2);
	assertTrue("Name copied", tb2.getName().equals(tb.getName()));
	assertTrue("Age copied", tb2.getAge() == tb.getAge());
	assertTrue("Touchy copied", tb2.getTouchy().equals(tb.getTouchy()));
}