Package org.springframework.beans

Examples of org.springframework.beans.SerializablePerson


    assertFalse(SerializationTestUtils.isSerializable(proxy));
  }

  public void testSerializationAdviceNotSerializable() throws Exception {
    SerializablePerson sp = new SerializablePerson();
    assertTrue(SerializationTestUtils.isSerializable(sp));

    ProxyFactory pf = new ProxyFactory(sp);

    // This isn't serializable
View Full Code Here


    assertFalse(SerializationTestUtils.isSerializable(proxy));
  }

  public void testSerializationSerializableTargetAndAdvice() throws Throwable {
    SerializablePerson personTarget = new SerializablePerson();
    personTarget.setName("jim");
    personTarget.setAge(26);

    assertTrue(SerializationTestUtils.isSerializable(personTarget));

    ProxyFactory pf = new ProxyFactory(personTarget);
View Full Code Here

      assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse());
      assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse()));
  }
 
  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);
View Full Code Here

  /**
   * Create an empty pointcut, populating instance variables.
   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() {
    ProxyFactory pf = new ProxyFactory(new SerializablePerson());
    nop = new SerializableNopInterceptor();
    pc = new NameMatchMethodPointcut();
    pf.addAdvisor(new DefaultPointcutAdvisor(pc, nop));
    proxied = (Person) pf.getProxy();
  }
View Full Code Here

  // TODO test reject swap to wrong interface or class?
  // how to decide what's valid?
 
 
  public void testSerialization() throws Exception {
    SerializablePerson sp1 = new SerializablePerson();
    sp1.setName("Tony");
    SerializablePerson sp2 = new SerializablePerson();
    sp1.setName("Gordon");
   
    HotSwappableTargetSource hts = new HotSwappableTargetSource(sp1);
    ProxyFactory pf = new ProxyFactory();
    pf.addInterface(Person.class);
    pf.setTargetSource(hts);
    pf.addAdvisor(new DefaultPointcutAdvisor(new SerializableNopInterceptor()));
    Person p = (Person) pf.getProxy();
   
    assertEquals(sp1.getName(), p.getName());
    hts.swap(sp2);
    assertEquals(sp2.getName(), p.getName());
   
    p = (Person) SerializationTestUtils.serializeAndDeserialize(p);
    // We need to get a reference to the client-side targetsource
    hts = (HotSwappableTargetSource) ((Advised) p).getTargetSource();
    assertEquals(sp2.getName(), p.getName());
    hts.swap(sp1);
    assertEquals(sp1.getName(), p.getName());
   
  }
View Full Code Here

    assertEquals("general error", ms.getMessage(ex.getGlobalError(), Locale.US));
    assertEquals("invalid field", ms.getMessage(ex.getFieldError("age"), Locale.US));
  }

  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");
View Full Code Here

TOP

Related Classes of org.springframework.beans.SerializablePerson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.