Last active
December 4, 2015 18:12
-
-
Save tiarebalbi/38e2cc6e9771ac893546 to your computer and use it in GitHub Desktop.
Potential error on Spring Web Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2015-12-04 16:06:46.280 INFO 24204 --- [ main] o.s.b.test.SpringBootMockServletContext : Initializing Spring FrameworkServlet '' | |
2015-12-04 16:06:46.280 INFO 24204 --- [ main] o.s.t.web.servlet.TestDispatcherServlet : FrameworkServlet '': initialization started | |
2015-12-04 16:06:46.295 INFO 24204 --- [ main] o.s.t.web.servlet.TestDispatcherServlet : FrameworkServlet '': initialization completed in 15 ms | |
MockHttpServletRequest: | |
HTTP Method = POST | |
Request URI = /test/device | |
Parameters = {} | |
Headers = {Accept=[application/json;charset=UTF-8], Content-Type=[application/json]} | |
Handler: | |
Type = org.springframework.data.rest.webmvc.RepositoryEntityController | |
Method = public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.PersistentEntityResource,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler,java.lang.String) throws org.springframework.web.HttpRequestMethodNotSupportedException | |
Async: | |
Async started = false | |
Async result = null | |
Resolved Exception: | |
Type = null | |
ModelAndView: | |
View name = null | |
View = null | |
Model = null | |
FlashMap: | |
Attributes = null | |
MockHttpServletResponse: | |
Status = 201 | |
Error message = null | |
Headers = {ETag=["0"], Last-Modified=[Fri, 04 Dec 2015 18:06:46 GMT], Location=[http://localhost/test/device/5661d636a826c4c5bba249c2], Content-Type=[application/json;charset=UTF-8]} | |
Content type = application/json;charset=UTF-8 | |
Body = { | |
"name" : "RT2", | |
"_links" : { | |
"self" : { | |
"href" : "http://localhost/test/device/5661d636a826c4c5bba249c2" | |
}, | |
"equipamento" : { | |
"href" : "http://localhost/test/device/5661d636a826c4c5bba249c2" | |
} | |
} | |
} | |
Forwarded URL = null | |
Redirected URL = http://localhost/test/device/5661d636a826c4c5bba249c2 | |
Cookies = [] | |
java.lang.NoClassDefFoundError: com/jayway/jsonpath/InvalidPathException | |
at org.springframework.test.web.servlet.result.JsonPathResultMatchers.<init>(JsonPathResultMatchers.java:53) | |
at org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(MockMvcResultMatchers.java:180) | |
at io.climacta.repository.EquipamentoRepositoryTest.deveSalvarUmRegistroViaRest(EquipamentoRepositoryTest.java:105) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
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:75) | |
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) | |
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) | |
at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239) | |
at org.junit.rules.RunRules.evaluate(RunRules.java:20) | |
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) | |
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) | |
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254) | |
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89) | |
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:70) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) | |
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193) | |
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) | |
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) | |
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) | |
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) | |
Caused by: java.lang.ClassNotFoundException: com.jayway.jsonpath.InvalidPathException | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) | |
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) | |
... 39 more |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@SpringApplicationConfiguration(classes = GerenciadorDadosApplication.class) | |
@WebAppConfiguration | |
class Test { | |
@Test | |
public void shouldSave() throws Exception { | |
Device device = new Device(); | |
device.setName("RT2"); | |
ObjectMapper mapper = new ObjectMapper(); | |
String json = mapper.writeValueAsString(device); | |
this.mockMvc.perform(post("/test/device") | |
.accept(MediaType.parseMediaType("application/json;charset=UTF-8")) | |
.content(json).contentType(MediaType.APPLICATION_JSON) | |
) | |
.andDo(print()) | |
.andExpect(status().isCreated()) | |
.andExpect(jsonPath("$.name").value("RT2")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment