lundi 7 septembre 2015

How to create tests in Java using Yeti?

Somebody maybe know any tutorial or anything about testing .java files using Yeti? I created Rest Service using Jersey and now I have to test it with Yeti but I have totally no idea how to do it. On github of Yeti it's written "Just run Yeti with the HTML files containing your tests." but I don't know what HTML files I have to create.

Here is my Java code. Maybe if I will write it, it will be easier for you to give me any clues how can I start to create tests.

@Path("/ftpaction")
public class JerseyFileUpload {

    @POST
    @Path("/upload")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response postMsg(@HeaderParam("FTP-Host") String Host, @HeaderParam("FTP-Port") String Port,
            @HeaderParam("FTP-User") String User, @HeaderParam("FTP-Password") String Password,
            @HeaderParam("FTP-Path") String Path, @HeaderParam("FTP-ExistingFilesActivity") String ExistingFilesActivity,
            @FormDataParam("file") InputStream inputStream) {

        try {
            InformationHandler informationHandler = new InformationHandler(Path, Host, Port, User, Password,
                    ProgramTask.WORK_ON_FTP);

            DirectoriesActivity userDecision = returnUserDecision(ExistingFilesActivity);

            CountriesStructure worker = new CountriesStructure();
            worker.prepareCountriesStructure(inputStream, true, informationHandler, userDecision);

        } catch (UsernameOrPasswordException e) {
            return Response.status(401).build();
        } catch (SocketException e) {
            return Response.status(404).build();
        } catch (IOException e) {
            return Response.status(400).build();
        } catch (JAXBException e) {
            return Response.status(500).build();
        } catch (Exception e) {
            return Response.status(500).build();
        }
        return Response.status(200).entity("Success!").build();
    }

    private DirectoriesActivity returnUserDecision(String ExistingFilesActivity) throws IOException {
        DirectoriesActivity userDecision;
        if (ExistingFilesActivity.toLowerCase().equals("delete")) {
            userDecision = DirectoriesActivity.DELETE;
        } else if (ExistingFilesActivity.toLowerCase().equals("replace")) {
            userDecision = DirectoriesActivity.REPLACE;
        } else if (ExistingFilesActivity.toLowerCase().equals("add")) {
            userDecision = DirectoriesActivity.ADD_NEW_CONTENTS;
        } else {
            throw new IOException();
        }
        return userDecision;
    }
}

Aucun commentaire:

Enregistrer un commentaire