Java Code Examples for org.springframework.tests.sample.beans.SerializablePerson#setName()
The following examples show how to use
org.springframework.tests.sample.beans.SerializablePerson#setName() .
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: DelegatingIntroductionInterceptorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception { SerializablePerson serializableTarget = new SerializablePerson(); String name = "Tony"; serializableTarget.setName("Tony"); ProxyFactory factory = new ProxyFactory(serializableTarget); factory.addInterface(Person.class); long time = 1000; TimeStamped ts = new SerializableTimeStamped(time); factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts))); factory.addAdvice(new SerializableNopInterceptor()); Person p = (Person) factory.getProxy(); assertEquals(name, p.getName()); assertEquals(time, ((TimeStamped) p).getTimeStamp()); Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p); assertEquals(name, p1.getName()); assertEquals(time, ((TimeStamped) p1).getTimeStamp()); }
Example 2
Source File: DelegatingIntroductionInterceptorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception { SerializablePerson serializableTarget = new SerializablePerson(); String name = "Tony"; serializableTarget.setName("Tony"); ProxyFactory factory = new ProxyFactory(serializableTarget); factory.addInterface(Person.class); long time = 1000; TimeStamped ts = new SerializableTimeStamped(time); factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts))); factory.addAdvice(new SerializableNopInterceptor()); Person p = (Person) factory.getProxy(); assertEquals(name, p.getName()); assertEquals(time, ((TimeStamped) p).getTimeStamp()); Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p); assertEquals(name, p1.getName()); assertEquals(time, ((TimeStamped) p1).getTimeStamp()); }
Example 3
Source File: DelegatingIntroductionInterceptorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception { SerializablePerson serializableTarget = new SerializablePerson(); String name = "Tony"; serializableTarget.setName("Tony"); ProxyFactory factory = new ProxyFactory(serializableTarget); factory.addInterface(Person.class); long time = 1000; TimeStamped ts = new SerializableTimeStamped(time); factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts))); factory.addAdvice(new SerializableNopInterceptor()); Person p = (Person) factory.getProxy(); assertEquals(name, p.getName()); assertEquals(time, ((TimeStamped) p).getTimeStamp()); Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p); assertEquals(name, p1.getName()); assertEquals(time, ((TimeStamped) p1).getTimeStamp()); }
Example 4
Source File: DataBinderTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testBindExceptionSerializable() throws Exception { SerializablePerson tb = new SerializablePerson(); tb.setName("myName"); tb.setAge(99); BindException ex = new BindException(tb, "tb"); ex.reject("invalid", "someMessage"); ex.rejectValue("age", "invalidField", "someMessage"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(ex); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); BindException ex2 = (BindException) ois.readObject(); assertTrue(ex2.hasGlobalErrors()); assertEquals("invalid", ex2.getGlobalError().getCode()); assertTrue(ex2.hasFieldErrors("age")); assertEquals("invalidField", ex2.getFieldError("age").getCode()); assertEquals(new Integer(99), ex2.getFieldValue("age")); ex2.rejectValue("name", "invalidField", "someMessage"); assertTrue(ex2.hasFieldErrors("name")); assertEquals("invalidField", ex2.getFieldError("name").getCode()); assertEquals("myName", ex2.getFieldValue("name")); }
Example 5
Source File: DataBinderTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testBindExceptionSerializable() throws Exception { SerializablePerson tb = new SerializablePerson(); tb.setName("myName"); tb.setAge(99); BindException ex = new BindException(tb, "tb"); ex.reject("invalid", "someMessage"); ex.rejectValue("age", "invalidField", "someMessage"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(ex); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); BindException ex2 = (BindException) ois.readObject(); assertTrue(ex2.hasGlobalErrors()); assertEquals("invalid", ex2.getGlobalError().getCode()); assertTrue(ex2.hasFieldErrors("age")); assertEquals("invalidField", ex2.getFieldError("age").getCode()); assertEquals(new Integer(99), ex2.getFieldValue("age")); ex2.rejectValue("name", "invalidField", "someMessage"); assertTrue(ex2.hasFieldErrors("name")); assertEquals("invalidField", ex2.getFieldError("name").getCode()); assertEquals("myName", ex2.getFieldValue("name")); }
Example 6
Source File: DataBinderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testBindExceptionSerializable() throws Exception { SerializablePerson tb = new SerializablePerson(); tb.setName("myName"); tb.setAge(99); BindException ex = new BindException(tb, "tb"); ex.reject("invalid", "someMessage"); ex.rejectValue("age", "invalidField", "someMessage"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(ex); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); BindException ex2 = (BindException) ois.readObject(); assertTrue(ex2.hasGlobalErrors()); assertEquals("invalid", ex2.getGlobalError().getCode()); assertTrue(ex2.hasFieldErrors("age")); assertEquals("invalidField", ex2.getFieldError("age").getCode()); assertEquals(new Integer(99), ex2.getFieldValue("age")); ex2.rejectValue("name", "invalidField", "someMessage"); assertTrue(ex2.hasFieldErrors("name")); assertEquals("invalidField", ex2.getFieldError("name").getCode()); assertEquals("myName", ex2.getFieldValue("name")); }