@Test(groups = "require-test-server-running")
  public void testEndpointPolymorphVO() {
    TestEndpoint te = applicationContext.getBean(TestEndpoint.class);

    RequestWrapper rw = new RequestWrapper();
    rw.setAccess1(makeRemoteAccess("ssh", "password"));
    rw.setAccess2(makeLocalAccess("path"));

    List<Access> al1 = new ArrayList<Access>();
    al1.add(makeRemoteAccess("ssh1", "password1"));
    al1.add(makeLocalAccess("path1"));
    al1.add(makeRemoteAccess("ssh2", "password2"));
    rw.setAccessList(al1);

    Map<String, Access> m1 = new HashMap<String, Access>();
    m1.put("ra1", makeRemoteAccess("ssh1", "password1"));
    m1.put("ra2", makeRemoteAccess("ssh2", "password2"));
    m1.put("la", makeLocalAccess("path1"));
    rw.setAccessMap(m1);

    ResponseWrapper rw2 = te.testAccess(rw);
    assertEquals(EndpointResponseStatus.OK, rw2.getStatus());

    RemoteAccess ra2 = rw2.getAccess1();
    assertEquals("ssh", ra2.getRemoteType());
    assertEquals("password", ra2.getRemoteAccessField());
    assertEquals("remote access", ra2.getAccessField());

    LocalAccess la2 = rw2.getAccess2();
    assertEquals("path", la2.getLocalAccessField());
    assertEquals("local access", la2.getAccessField());

    List<Access> al2 = rw2.getAccessList();
    assertNotNull(al2);
    assertEquals(3, al2.size());
    assertEquals(RemoteAccess.class, al1.get(0).getClass());
    assertEquals(((RemoteAccess) al1.get(0)).getRemoteType(), "ssh1");
    assertEquals(((RemoteAccess) al1.get(0)).getRemoteAccessField(), "password1");
    assertEquals(LocalAccess.class, al1.get(1).getClass());
    assertEquals(((LocalAccess) al1.get(1)).getLocalAccessField(), "path1");
    assertEquals(RemoteAccess.class, al1.get(2).getClass());
    assertEquals(((RemoteAccess) al1.get(2)).getRemoteType(), "ssh2");
    assertEquals(((RemoteAccess) al1.get(2)).getRemoteAccessField(), "password2");

    Map<String, Access> m2 = rw2.getAccessMap();
    assertNotNull(m2);
    assertEquals(3, m2.size());
    assertEquals(RemoteAccess.class, m2.get("ra1").getClass());
    assertEquals(((RemoteAccess) m2.get("ra1")).getRemoteType(), "ssh1");
    assertEquals(((RemoteAccess) m2.get("ra1")).getRemoteAccessField(), "password1");
    assertEquals(LocalAccess.class, m2.get("la").getClass());
    assertEquals(((LocalAccess) m2.get("la")).getLocalAccessField(), "path1");
    assertEquals(RemoteAccess.class, m2.get("ra2").getClass());
    assertEquals(((RemoteAccess) m2.get("ra2")).getRemoteType(), "ssh2");
    assertEquals(((RemoteAccess) m2.get("ra2")).getRemoteAccessField(), "password2");
  }
 private LocalAccess makeLocalAccess(String field) {
   LocalAccess la1 = new LocalAccess();
   la1.setLocalAccessField(field);
   la1.setAccessField("local access");
   return la1;
 }