@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"); }
@Test(groups = "require-test-server-running") public void testEndpointVoidResult() { TestEndpoint te = applicationContext.getBean(TestEndpoint.class); TestRequest tr1 = new TestRequest(); tr1.setStringField("string"); tr1.setCreated(new Date()); tr1.setRequestId(System.currentTimeMillis() + ":"); tr1.setRequestSource("src"); tr1.setSessionId("session" + System.currentTimeMillis()); te.testVoidResult(tr1); }
@Test(groups = "require-test-server-running") public void testEndpointException() { TestEndpoint te = applicationContext.getBean(TestEndpoint.class); TestRequest tr1 = new TestRequest(); tr1.setStringField("string"); tr1.setCreated(new Date()); tr1.setRequestId(System.currentTimeMillis() + ":"); tr1.setRequestSource("src"); tr1.setSessionId("session" + System.currentTimeMillis()); TestResponse tr = te.testException(tr1); assertEquals(EndpointResponseStatus.ERROR, tr.getStatus()); }