org.springframework.test.util.subpackage.Person Java Examples
The following examples show how to use
org.springframework.test.util.subpackage.Person.
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: ReflectionTestUtilsTests.java From spring-analysis-note with MIT License | 6 votes |
private static void assertSetFieldAndGetFieldBehavior(Person person) { // Set reflectively setField(person, "id", Long.valueOf(99), long.class); setField(person, "name", "Tom"); setField(person, "age", Integer.valueOf(42)); setField(person, "eyeColor", "blue", String.class); setField(person, "likesPets", Boolean.TRUE); setField(person, "favoriteNumber", PI, Number.class); // Get reflectively assertEquals(Long.valueOf(99), getField(person, "id")); assertEquals("Tom", getField(person, "name")); assertEquals(Integer.valueOf(42), getField(person, "age")); assertEquals("blue", getField(person, "eyeColor")); assertEquals(Boolean.TRUE, getField(person, "likesPets")); assertEquals(PI, getField(person, "favoriteNumber")); // Get directly assertEquals("ID (private field in a superclass)", 99, person.getId()); assertEquals("name (protected field)", "Tom", person.getName()); assertEquals("age (private field)", 42, person.getAge()); assertEquals("eye color (package private field)", "blue", person.getEyeColor()); assertEquals("'likes pets' flag (package private boolean field)", true, person.likesPets()); assertEquals("'favorite number' (package field)", PI, person.getFavoriteNumber()); }
Example #2
Source File: ReflectionTestUtilsTests.java From java-technology-stack with MIT License | 6 votes |
private static void assertSetFieldAndGetFieldBehavior(Person person) { // Set reflectively setField(person, "id", Long.valueOf(99), long.class); setField(person, "name", "Tom"); setField(person, "age", Integer.valueOf(42)); setField(person, "eyeColor", "blue", String.class); setField(person, "likesPets", Boolean.TRUE); setField(person, "favoriteNumber", PI, Number.class); // Get reflectively assertEquals(Long.valueOf(99), getField(person, "id")); assertEquals("Tom", getField(person, "name")); assertEquals(Integer.valueOf(42), getField(person, "age")); assertEquals("blue", getField(person, "eyeColor")); assertEquals(Boolean.TRUE, getField(person, "likesPets")); assertEquals(PI, getField(person, "favoriteNumber")); // Get directly assertEquals("ID (private field in a superclass)", 99, person.getId()); assertEquals("name (protected field)", "Tom", person.getName()); assertEquals("age (private field)", 42, person.getAge()); assertEquals("eye color (package private field)", "blue", person.getEyeColor()); assertEquals("'likes pets' flag (package private boolean field)", true, person.likesPets()); assertEquals("'favorite number' (package field)", PI, person.getFavoriteNumber()); }
Example #3
Source File: ReflectionTestUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setFieldAndGetFieldViaJdkDynamicProxy() throws Exception { ProxyFactory pf = new ProxyFactory(this.person); pf.addInterface(Person.class); Person proxy = (Person) pf.getProxy(); assertTrue("Proxy is a JDK dynamic proxy", AopUtils.isJdkDynamicProxy(proxy)); assertSetFieldAndGetFieldBehaviorForProxy(proxy, this.person); }
Example #4
Source File: ReflectionTestUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setFieldAndGetFieldViaCglibProxy() throws Exception { ProxyFactory pf = new ProxyFactory(this.person); pf.setProxyTargetClass(true); Person proxy = (Person) pf.getProxy(); assertTrue("Proxy is a CGLIB proxy", AopUtils.isCglibProxy(proxy)); assertSetFieldAndGetFieldBehaviorForProxy(proxy, this.person); }
Example #5
Source File: ReflectionTestUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
private static void assertSetFieldAndGetFieldBehaviorForProxy(Person proxy, Person target) { assertSetFieldAndGetFieldBehavior(proxy); // Get directly from Target assertEquals("ID (private field in a superclass)", 99, target.getId()); assertEquals("name (protected field)", "Tom", target.getName()); assertEquals("age (private field)", 42, target.getAge()); assertEquals("eye color (package private field)", "blue", target.getEyeColor()); assertEquals("'likes pets' flag (package private boolean field)", true, target.likesPets()); assertEquals("'favorite number' (package field)", PI, target.getFavoriteNumber()); }
Example #6
Source File: ReflectionTestUtilsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void setFieldAndGetFieldViaJdkDynamicProxy() throws Exception { ProxyFactory pf = new ProxyFactory(this.person); pf.addInterface(Person.class); Person proxy = (Person) pf.getProxy(); assertTrue("Proxy is a JDK dynamic proxy", AopUtils.isJdkDynamicProxy(proxy)); assertSetFieldAndGetFieldBehaviorForProxy(proxy, this.person); }
Example #7
Source File: ReflectionTestUtilsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void setFieldAndGetFieldViaCglibProxy() throws Exception { ProxyFactory pf = new ProxyFactory(this.person); pf.setProxyTargetClass(true); Person proxy = (Person) pf.getProxy(); assertTrue("Proxy is a CGLIB proxy", AopUtils.isCglibProxy(proxy)); assertSetFieldAndGetFieldBehaviorForProxy(proxy, this.person); }
Example #8
Source File: ReflectionTestUtilsTests.java From java-technology-stack with MIT License | 5 votes |
private static void assertSetFieldAndGetFieldBehaviorForProxy(Person proxy, Person target) { assertSetFieldAndGetFieldBehavior(proxy); // Get directly from Target assertEquals("ID (private field in a superclass)", 99, target.getId()); assertEquals("name (protected field)", "Tom", target.getName()); assertEquals("age (private field)", 42, target.getAge()); assertEquals("eye color (package private field)", "blue", target.getEyeColor()); assertEquals("'likes pets' flag (package private boolean field)", true, target.likesPets()); assertEquals("'favorite number' (package field)", PI, target.getFavoriteNumber()); }