Package org.springframework.tests.sample.objects

Examples of org.springframework.tests.sample.objects.TestObject


    }
  }

  @Test
  public void rejectsNullSrc() {
    TestObject src = null;
    String dest = new String();
    try {
      ReflectionUtils.shallowCopyFieldState(src, dest);
      fail();
    } catch (IllegalArgumentException ex) {
View Full Code Here


    }
  }

  @Test
  public void rejectsNullDest() {
    TestObject src = new TestObject();
    String dest = null;
    try {
      ReflectionUtils.shallowCopyFieldState(src, dest);
      fail();
    } catch (IllegalArgumentException ex) {
View Full Code Here

    }
  }

  @Test
  public void validCopy() {
    TestObject src = new TestObject();
    TestObject dest = new TestObject();
    testValidCopy(src, dest);
  }
View Full Code Here

    assertEquals(src.prot, dest.prot);
  }

  @Test
  public void validCopyToSubType() {
    TestObject src = new TestObject();
    TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField();
    dest.magic = 11;
    testValidCopy(src, dest);
    // Should have left this one alone
    assertEquals(11, dest.magic);
View Full Code Here

  }

  private void testValidCopy(TestObject src, TestObject dest) {
    src.setName("freddie");
    src.setAge(15);
    src.setSpouse(new TestObject());
    assertFalse(src.getAge() == dest.getAge());

    ReflectionUtils.shallowCopyFieldState(src, dest);
    assertEquals(src.getAge(), dest.getAge());
    assertEquals(src.getSpouse(), dest.getSpouse());
View Full Code Here

  private static class MockElementFactory implements AutoPopulatingList.ElementFactory {

    @Override
    public Object createElement(int index) {
      TestObject bean = new TestObject();
      bean.setAge(index);
      return bean;
    }
View Full Code Here

  @Test
  public void invokeMethod() throws Exception {
    String rob = "Rob Harrop";

    TestObject bean = new TestObject();
    bean.setName(rob);

    Method getName = TestObject.class.getMethod("getName", (Class[]) null);
    Method setName = TestObject.class.getMethod("setName", new Class[] { String.class });

    Object name = ReflectionUtils.invokeMethod(getName, bean);
    assertEquals("Incorrect name returned", rob, name);

    String juergen = "Juergen Hoeller";
    ReflectionUtils.invokeMethod(setName, bean, new Object[] { juergen });
    assertEquals("Incorrect name set", juergen, bean.getName());
  }
View Full Code Here

    assertFalse(ReflectionUtils.declaresException(illegalExMethod, Exception.class));
  }

  @Test
  public void copySrcToDestinationOfIncorrectClass() {
    TestObject src = new TestObject();
    String dest = new String();
    try {
      ReflectionUtils.shallowCopyFieldState(src, dest);
      fail();
    } catch (IllegalArgumentException ex) {
View Full Code Here

* @author Rob Harrop
*/
public class ConventionsTests extends TestCase {

  public void testSimpleObject() {
    TestObject testObject = new TestObject();
    assertEquals("Incorrect singular variable name", "testObject", Conventions.getVariableName(testObject));
  }
View Full Code Here

    assertEquals("Incorrect plural array form", "testObjectList", Conventions.getVariableName(testObjects));
  }

  public void testCollections() {
    List<TestObject> list = new ArrayList<TestObject>();
    list.add(new TestObject());
    assertEquals("Incorrect plural List form", "testObjectList", Conventions.getVariableName(list));

    Set<TestObject> set = new HashSet<TestObject>();
    set.add(new TestObject());
    assertEquals("Incorrect plural Set form", "testObjectList", Conventions.getVariableName(set));

    List<?> emptyList = new ArrayList<Object>();
    try {
      Conventions.getVariableName(emptyList);
View Full Code Here

TOP

Related Classes of org.springframework.tests.sample.objects.TestObject

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.