How to call Spring Controller's method with @RequestBody from JUNIT test case
<p>I have one controller method .</p>

<pre><code>@RequestMapping(method = RequestMethod.POST)
    @ResponseBody 
    public String uploadFiles(@RequestBody MyModel myModel) {...}
</code></pre>

<p>And I have to call this from JUNIT test cases. </p>

<p>So far I tried different ways, some of them is below and its giving me </p>

<p><code>java.lang.AssertionError: Status expected:&lt;200&gt; but was:&lt;415&gt;</code></p>

<pre><code>MvcResult result;   
            result = getMockMvc().perform(post("/fileUpload"))
                    .andExpect(status().isOk())
                    .andReturn();
</code></pre>

<p>and</p>

<pre><code>result = getMockMvc().perform(post("/fileUpload").accept(APPLICATION_JSON_CHARSET_UTF_8))
                        .andExpect(status().isOk())
                        .andReturn();
</code></pre>

<p>I can't pass my param in RequestHeader, RequestParam or PathVariable.</p>