Hi, i have a service that upload a file. When i use a typically html form
everything works ok.
Now i try to test this using the client framework and the values of the
parameters are null.

Here is the interface:
-----------------------------------------
@Path("upload")
public interface UploadServiceJaxRS {

    @POST
    @Path("FileUploadServlet")
    @Consumes("multipart/form-data")
    public void uploadProcessPOST(@MultipartForm FileUploadForm form);
}
----------------------------------------

the POJO:
----------------------------------------
public class FileUploadForm {

    private String name;

    private byte[] txtFile;

    public FileUploadForm() {}

    public byte[] getTxtFile() {
        return txtFile;
    }

    public String getName() {
        return name;
    }

    @FormParam("txtFile")
    @PartType("application/octet-stream")
    public void setTxtFile(final byte[] txtFile) {
        this.txtFile = txtFile;
    }


    @FormParam("name")
    @PartType("text/plain")
    public void setName(String name) {
        this.name = name;
    }
}
-------------------------------------------

and the test:
-------------------------------------------
    @Test
    public void testPDFCreation() throws Exception{
        RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
        File file = new File("/tmp/test.txt");
        byte[] bytes = FileUtils.getBytes(file);
        FileUploadForm form = new FileUploadForm();
        form.setName(file.getName());
        form.setTxtFile(bytes);

        UploadServiceJaxRS client =
ProxyFactory.create(UploadServiceJaxRS.class, "http://localhost:8080/e-forms
");
        try {
            client.uploadProcessPOST(form);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
-------------------------------------------

Inside the implementation, the form parameter comes with their attributes
with null values

Any ideas?
Thanks!
------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to