DMZSyncServiceImpl extends RemoteServiceServlet implements
		DMZSyncService { protected String sendData(String json,String url) throws DMZSyncException { HttpClient httpClient = new HttpClient(); String ret = ""; PostMethod postMethod = new PostMethod(url); NameValuePair[] registerInform = new NameValuePair[1]; registerInform[0] = new NameValuePair("data", json); postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); postMethod.setRequestBody(registerInform); authenticate(httpClient, postMethod); int statusCode = 0; try { statusCode = httpClient.executeMethod(postMethod); ret = postMethod.getResponseBodyAsString(); } catch (HttpException e) { throw new DMZSyncException(DMZSyncExceptionType.HTTP_EXCEPTION,url+": "+e.getMessage()); } catch (IOException e1) { throw new DMZSyncException(DMZSyncExceptionType.CONNECT_HOST_ADDRESS_EXCEPTION,url+": "+e1.getMessage()); } if(ret.equals("Data Error")){ throw new DMZSyncException(DMZSyncExceptionType.RUN_TIME_EXCEPTION,": "+ret); } if (!(statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY)) { System.err.println("field."); } return ret; }  @Override List<String> pushToDMZ(Long standardizedPatientId,String locale); @Override void pullFromDMZ(Long standardizedPatientId); @Override String sendSync(String locale); @Override void getSync(String locale); String preProcessData(String data);  }
@Test public void testSendData() { MyDMZSyncServiceImpl instance2 = new MyDMZSyncServiceImpl(); returnData = "{\"class\":\"sp_portal.local.StandardizedPatient\",\"id\":23,\"anamnesisForm\":{\"class\":\"sp_portal.local.AnamnesisForm\",\"id\":5,\"createDate\":\"2009-09-18T16:00:00Z\",\"origId\":6,\"standardizedPatients\":[{\"_ref\":\"../..\",\"class\":\"sp_portal.local.StandardizedPatient\"}]},\"bankaccount\":{\"class\":\"sp_portal.local.Bankaccount\",\"id\":5,\"bankName\":\"KTS\",\"bic\":\"BENDSFF1JEV\",\"city\":null,\"iban\":\"CH78 5685 7565 4364 7\",\"origId\":31,\"ownerName\":null,\"postalCode\":null,\"standardizedPatients\":[{\"_ref\":\"../..\",\"class\":\"sp_portal.local.StandardizedPatient\"}]},\"birthday\":\"1965-09-23T16:00:00Z\",\"city\":\"PaulVille\",\"description\":null,\"email\":\"beddebu@hss.ch\",\"gender\":1,\"height\":182,\"immagePath\":null,\"maritalStatus\":null,\"mobile\":\"078 586 29 84\",\"name\":\"Buser\",\"nationality\":{\"class\":\"sp_portal.local.Nationality\",\"id\":2,\"nationality\":\"Deutschland\",\"origId\":6},\"origId\":23,\"postalCode\":4051,\"preName\":\"Bettina\",\"profession\":{\"class\":\"sp_portal.local.Profession\",\"id\":5,\"origId\":6,\"profession\":\"Florist/in\"},\"socialInsuranceNo\":null,\"street\":\"Rankenbergweg 1\",\"telephone\":\"9999999999\",\"telephone2\":null,\"videoPath\":null,\"weight\":82,\"workPermission\":null}"; String excptedData = null; try { String url = instance2.getHostAddress() + "/DataImportExport/importSP"; excptedData = instance2.sendData(returnData,url); } catch (Exception e) { e.printStackTrace(); e.getCause().printStackTrace(); Assert.fail("error occured " + e.getMessage()); } assertEquals(excptedData,returnData); }