I want to write JUNIT tests for this function
public static int creerFichierXml(TextField titre_projet,TextField description1,TextField svn,TextField planning1,TextField planning2,TextField goals,TextField mail){
//Créer le fichier XML et l'envoyer au serveur
int returnCode = 0;
ParseToXML j=new ParseToXML();
try {
j.main(description1, svn, planning1, planning2, goals,mail);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod("http://localhost:8080/createItem?name="+titre_projet.toString());
postMethod.setRequestHeader("Content-type", "application/xml; charset=ISO-8859-1");
try {
postMethod.setRequestBody(new FileInputStream(new File("C:/integrationContinue/src/main/resources/config.xml")));
returnCode = client.executeMethod(postMethod);
System.out.println("*********************************************"+returnCode);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return returnCode;
}
This code is used to create an xml file then send it to server with postMethod
Junit must test http Connection, Parse to Xml and call main function