möchte ich JUnit-Tests für diese FunktionTestfunktion (ParseToXML, PostMethod) mit Junit
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;
}
Dieser Code verwendet schreiben ist eine XML-Datei dann schicken Sie es an den Server mit postMethod
Junit muss erstellen Test hTTP-Verbindung, um XML-Parse und Hauptfunktion