title: Creating a MultipartFormDataInput object for Java jUnit testing
body: <p>uI've got a Resteasy webservice method that takes a MultipartFormDataInput object as its parm, and pulls lots of information out of it.  I'd like to write a jUnit test for this method, but I've been unable to find any way to create this object and put dummy data in it so I can call my webservice method directly.  The service method extracts the data from the form like this...</p>
  
  <pre><code>@POST
  @Path("/requestDeviceCode")
  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
  @Consumes("multipart/form-data")
  public DeviceCodeModel requestDeviceCode(final MultipartFormDataInput inputMultipart) {
  
      // process the form data - only field in the form is the token
      Map&lt;String, List&lt;InputPart&gt;&gt; formData = null; // we'll put the form data in here
      formData = inputMultipart.getFormDataMap();
  
      String token = null;
      try {
          token = formData.get("Token").get(0).getBodyAsString();
          this._logger.debug("Pulled encrypted token out of input form, it's " + token);
  </code></pre>
  
  <p>and that works fine, but trying to create an object to pass as a parm to 'requestDeviceCode' has me stymied.  I've tried variations of this...</p>
  
  <pre><code>        // create a multipartForm (input to the service POST) and add the "token" string to it
          MultipartFormDataOutput newForm = new MultipartFormDataOutput();
          newForm.addFormData("Token", encryptedXMLString, MediaType.APPLICATION_XML_TYPE);
  
          _service.requestDeviceCode((MultipartFormDataInput) newForm);
  </code></pre>
  
  <p>but it's just not doing it (this particular error is that I can't cast the Output form to an Input form).  I haven't been able to find a way to create a new MultiPartFormDataInput and add data to it.</p>
  
  <p>Does anyone have any advice?</p>