djangid / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

'log().all()' after serializable multipart #410

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This code (in version 2.4.1):

 given()
            .multiPart("dto", dto, "application/json").log().all()
            .when()
            .post("/api/upload")
            .then()
            .statusCode(HttpStatus.SC_OK);

causes a

java.lang.IllegalArgumentException: Cannot specify file name for non file 
content (java.lang.String).
    at com.jayway.restassured.builder.MultiPartSpecBuilder.fileName(MultiPartSpecBuilder.java:120)
    at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.logRequestIfApplicable(MockMvcRequestSenderImpl.java:464)
    at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.sendRequest(MockMvcRequestSenderImpl.java:334)
    at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.post(MockMvcRequestSenderImpl.java:502)
    at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.post(MockMvcRequestSenderImpl.java:53)
  ...

I debugged a bit:
In the class 'MockMvcRequestSenderImpl' the 'dto' object is serialized and put 
in the (MockMultipartHttpServletRequestBuilder) request (line 319).
But if the 'requestLoggingFilter' is not null, eventually 
'fileName(multiPart.getFileName())' is called and multipart is neither a File, 
FileInputStream or byte[].

Without the 'log().all()' things work fine (except there's no logging...)

Kind regards,

steveN

Original issue reported on code.google.com by steven.m...@smartinstall.nl on 19 Jun 2015 at 7:23