java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference>

Spring JIRA | Joe | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/users") public class UserControllerConsume { @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public String handleJson(@RequestBody String s) { System.out.println("json body : "+s); return ""; } @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE) public String handleXML(@RequestBody String s) { System.out.println("xml body "+s); return ""; } } ------------------------ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class WebConfigConsume { @Bean public UserControllerConsume myMvcController() { return new UserControllerConsume(); } } --------------- import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration(classes = WebConfigConsume.class) public class UserControllerTestConsume { @Autowired private WebApplicationContext wac; private MockMvc mockMvc; @Before public void setup() { DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.wac); this.mockMvc = builder.build(); } @Test public void testMyMvcController() throws Exception { ResultMatcher ok = MockMvcResultMatchers.status().isOk(); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.post("/users") .contentType(MediaType.APPLICATION_JSON) .content("{ \"userName\": \"Joe\"}"); this.mockMvc.perform(builder) .andExpect(ok); } @Test public void testMyMvcController2() throws Exception { ResultMatcher ok = MockMvcResultMatchers.status().isOk(); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.post("/users") .contentType(MediaType.APPLICATION_XML) .content("<user><userName>Joe</userName></user>"); this.mockMvc.perform(builder) .andExpect(ok); } } ----------------------------- "C:\Program Files\Java\jdk1.8.0_65\bin\java" -ea -Didea.launcher.port=7541 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.2\bin" -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.2\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.2\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\rt.jar;D:\LogicBig\example-projects\spring-mvc\spring-mvc-request-mapping\target\test-classes;D:\LogicBig\example-projects\spring-mvc\spring-mvc-request-mapping\target\classes;C:\Users\Joe\.m2\repository\org\springframework\spring-webmvc\3.2.5.RELEASE\spring-webmvc-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-beans\3.2.5.RELEASE\spring-beans-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-context\3.2.5.RELEASE\spring-context-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-aop\3.2.5.RELEASE\spring-aop-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-core\3.2.5.RELEASE\spring-core-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-expression\3.2.5.RELEASE\spring-expression-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-web\3.2.5.RELEASE\spring-web-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-test\3.2.5.RELEASE\spring-test-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\javax\servlet\javax.servlet-api\3.0.1\javax.servlet-api-3.0.1.jar;C:\Users\Joe\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Joe\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.logicbig.example.UserControllerTestConsume Feb 09, 2016 9:40:52 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.GenericWebApplicationContext@66d33a: startup date [Tue Feb 09 21:40:52 CST 2016]; root of context hierarchy Feb 09, 2016 9:40:53 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@23e028a9: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,webConfigConsume,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myMvcController]; root of factory hierarchy Feb 09, 2016 9:40:53 PM org.springframework.mock.web.MockServletContext log INFO: Initializing Spring FrameworkServlet '' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization started Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users.*] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users/] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization completed in 182 ms Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleNoSuchRequestHandlingMethod WARNING: No matching handler method found for servlet request: path '/users', method 'POST', parameters map[[empty]] java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference> at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89) at org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:549) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:148) at com.logicbig.example.UserControllerTestConsume.testMyMvcController2(UserControllerTestConsume.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Feb 09, 2016 9:40:53 PM org.springframework.mock.web.MockServletContext log INFO: Initializing Spring FrameworkServlet '' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization started Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users.*] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users/] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization completed in 13 ms Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleNoSuchRequestHandlingMethod WARNING: No matching handler method found for servlet request: path '/users', method 'POST', parameters map[[empty]] Feb 09, 2016 9:40:53 PM org.springframework.context.support.AbstractApplicationContext doClose INFO: Closing org.springframework.web.context.support.GenericWebApplicationContext@66d33a: startup date [Tue Feb 09 21:40:52 CST 2016]; root of context hierarchy java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference> at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89) at org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:549) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:148) at com.logicbig.example.UserControllerTestConsume.testMyMvcController(UserControllerTestConsume.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Process finished with exit code -1 ---------------------------------- Looks like media type is completely ignored here : @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) Am I missing something or it's a bug? Thanks

    Spring JIRA | 1 year ago | Joe
    java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference>
  2. 0

    import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/users") public class UserControllerConsume { @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public String handleJson(@RequestBody String s) { System.out.println("json body : "+s); return ""; } @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE) public String handleXML(@RequestBody String s) { System.out.println("xml body "+s); return ""; } } ------------------------ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class WebConfigConsume { @Bean public UserControllerConsume myMvcController() { return new UserControllerConsume(); } } --------------- import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration(classes = WebConfigConsume.class) public class UserControllerTestConsume { @Autowired private WebApplicationContext wac; private MockMvc mockMvc; @Before public void setup() { DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.wac); this.mockMvc = builder.build(); } @Test public void testMyMvcController() throws Exception { ResultMatcher ok = MockMvcResultMatchers.status().isOk(); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.post("/users") .contentType(MediaType.APPLICATION_JSON) .content("{ \"userName\": \"Joe\"}"); this.mockMvc.perform(builder) .andExpect(ok); } @Test public void testMyMvcController2() throws Exception { ResultMatcher ok = MockMvcResultMatchers.status().isOk(); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.post("/users") .contentType(MediaType.APPLICATION_XML) .content("<user><userName>Joe</userName></user>"); this.mockMvc.perform(builder) .andExpect(ok); } } ----------------------------- "C:\Program Files\Java\jdk1.8.0_65\bin\java" -ea -Didea.launcher.port=7541 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.2\bin" -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.2\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.2\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_65\jre\lib\rt.jar;D:\LogicBig\example-projects\spring-mvc\spring-mvc-request-mapping\target\test-classes;D:\LogicBig\example-projects\spring-mvc\spring-mvc-request-mapping\target\classes;C:\Users\Joe\.m2\repository\org\springframework\spring-webmvc\3.2.5.RELEASE\spring-webmvc-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-beans\3.2.5.RELEASE\spring-beans-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-context\3.2.5.RELEASE\spring-context-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-aop\3.2.5.RELEASE\spring-aop-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-core\3.2.5.RELEASE\spring-core-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-expression\3.2.5.RELEASE\spring-expression-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-web\3.2.5.RELEASE\spring-web-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\Joe\.m2\repository\org\springframework\spring-test\3.2.5.RELEASE\spring-test-3.2.5.RELEASE.jar;C:\Users\Joe\.m2\repository\javax\servlet\javax.servlet-api\3.0.1\javax.servlet-api-3.0.1.jar;C:\Users\Joe\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Joe\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.logicbig.example.UserControllerTestConsume Feb 09, 2016 9:40:52 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.GenericWebApplicationContext@66d33a: startup date [Tue Feb 09 21:40:52 CST 2016]; root of context hierarchy Feb 09, 2016 9:40:53 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@23e028a9: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,webConfigConsume,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myMvcController]; root of factory hierarchy Feb 09, 2016 9:40:53 PM org.springframework.mock.web.MockServletContext log INFO: Initializing Spring FrameworkServlet '' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization started Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users.*] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users/] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization completed in 182 ms Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleNoSuchRequestHandlingMethod WARNING: No matching handler method found for servlet request: path '/users', method 'POST', parameters map[[empty]] java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference> at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89) at org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:549) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:148) at com.logicbig.example.UserControllerTestConsume.testMyMvcController2(UserControllerTestConsume.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Feb 09, 2016 9:40:53 PM org.springframework.mock.web.MockServletContext log INFO: Initializing Spring FrameworkServlet '' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization started Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users.*] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/users/] onto handler 'myMvcController' Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet '': initialization completed in 13 ms Feb 09, 2016 9:40:53 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleNoSuchRequestHandlingMethod WARNING: No matching handler method found for servlet request: path '/users', method 'POST', parameters map[[empty]] Feb 09, 2016 9:40:53 PM org.springframework.context.support.AbstractApplicationContext doClose INFO: Closing org.springframework.web.context.support.GenericWebApplicationContext@66d33a: startup date [Tue Feb 09 21:40:52 CST 2016]; root of context hierarchy java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference> at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89) at org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:549) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:148) at com.logicbig.example.UserControllerTestConsume.testMyMvcController(UserControllerTestConsume.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Process finished with exit code -1 ---------------------------------- Looks like media type is completely ignored here : @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) Am I missing something or it's a bug? Thanks

    Spring JIRA | 1 year ago | Joe
    java.lang.AssertionError: Status Expected :200 Actual :404 <Click to see difference>
  3. 0

    Unit Test with Mock

    Stack Overflow | 2 years ago
    java.lang.AssertionError: Status expected:<200> but was:<400>
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    GitHub comment 15#35897674

    GitHub | 3 years ago | mathieubodin
    java.lang.AssertionError: Status expected:<200> but was:<500>
  6. 0

    Mock MVC unexpected result - Code - Help To User

    helptouser.com | 1 year ago
    java.lang.AssertionError: Status expected:<200> but was:<404>
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.AssertionError

    Status Expected :200 Actual :404 <Click to see difference>

    at org.springframework.test.util.AssertionErrors.fail()
  2. Spring TestContext
    MockMvc$1.andExpect
    1. org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60)
    2. org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89)
    3. org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:549)
    4. org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:148)
    4 frames
  3. com.logicbig.example
    UserControllerTestConsume.testMyMvcController2
    1. com.logicbig.example.UserControllerTestConsume.testMyMvcController2(UserControllerTestConsume.java:57)
    1 frame
  4. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:497)
    4 frames
  5. JUnit
    RunBefores.evaluate
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    5 frames
  6. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    4. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    5. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
    5 frames
  7. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    2. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    3. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    4. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    5. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    5 frames
  8. Spring TestContext
    RunAfterTestClassCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    2 frames
  9. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    1 frame
  10. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    1 frame
  11. JUnit
    JUnitCore.run
    1. org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    1 frame
  12. IntelliJ junit4 module
    JUnit4IdeaTestRunner.startRunnerWithArgs
    1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    1 frame
  13. IDEA
    JUnitStarter.main
    1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    2 frames
  14. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:497)
    4 frames
  15. IDEA
    AppMain.main
    1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
    1 frame