I am using Spring Boot to create an app. When I run my application, and test the service, I get this which is correct.
However, when I run my test which looks like this:
public class CatalogControllerTet {
private MockMvc mvc;
@Autowired
private WebApplicationContext context;
@Autowired
private CatalogRepository catalogRepository;
@Before
public void setUp() throws Exception {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
@Test
public void getHello() throws Exception {
MvcResult r = mvc.perform(MockMvcRequestBuilders
.get("/catalogs")
.accept(MediaType.APPLICATION_JSON)).andReturn();
String content = r.getResponse().getContentAsString();
int i = 100;
}
}
When I put a breakpoint in my test, I see this. One thing I noticed is that I don't see anything in the "supportedMediaTypes" list mentioning JSON.
I've seen some other similar questions as mine, but they were traced back to the response object not having any getters/setters or something having to do with Jackson libraries. The fact that the service starts up and runs correctly means that it isn't those issues.
Any help on this is greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire