PersonService personService = new PersonServiceImpl("http://localhost:" + port + "/" + context + "/soap-services/PersonServiceService");
ArrayList<String> ids = new ArrayList<String>(Arrays.asList("id1", "id2", "id3", "id4"));
Collection persons = personService.readPersons(ids);
for (Object o : persons) {
Person person = (Person) o;
assertTrue(ids.remove(person.getId()));
assertEquals(new Date(1L), ((Event) person.getEvents().iterator().next()).getDate());
}
Collection<Person> empty = personService.readPersons(null);
assertTrue(empty == null || empty.isEmpty());
personService.deletePerson("somebody");
try {
personService.deletePerson(null);
fail("Should have thrown the exception.");
}
catch (ServiceException e) {
assertEquals("a person id must be supplied", e.getMessage());
assertEquals("no person id.", e.getAnotherMessage());
}
try {
personService.deletePerson("SPECIAL");
fail("should have thrown an exception.");
}
catch (Exception e) {
assertTrue(e.getMessage().contains("SPECIAL"));
}
Person person = new Person();
person.setId("new-person");
assertEquals("new-person", personService.storePerson(person).getId());
byte[] pixBytes = "this is a bunch of bytes that I would like to make sure are serialized correctly so that I can prove out that attachments are working properly".getBytes();
person.setPicture(new DataHandler(new ByteArrayDataSource(pixBytes, "image/jpeg")));
DataHandler returnedPix = personService.storePerson(person).getPicture();
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
InputStream inputStream = returnedPix.getInputStream();
int byteIn = inputStream.read();