1

I downloaded the Spring Petclinic project from https://github.com/spring-projects/spring-petclinic/

The Eclipse compilation works fine – I could run the project from Tomcat. However at maven compilation with the same JDK jdk1.6.0_45 got the error:

org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder required: java.lang.Object. The full error is as follows:

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /spring-petclinic/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java:[58,58] \spring-petclinic\src\test\java\org\springframework\samples\petclinic\web\VisitsViewTests.java:58:

incompatible types; inferred type argument(s) java.lang.Object do not conform to bounds of type variable(s) B found : org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder required: java.lang.Object

Running with debug output got the following error in the very beginning:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

The code for the VisitsViewTests is as follows:

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration("VisitsViewTests-config.xml")
@ActiveProfiles("jdbc")
public class VisitsViewTests {

@Autowired
private WebApplicationContext webApplicationContext;

private MockMvc mockMvc;

@Before
public void setup() {
    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
}

@Test
public void getVisitsXml() throws Exception {
    ResultActions actions =    this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
    actions.andDo(print()); // action is logged into the console
    actions.andExpect(status().isOk());
    actions.andExpect(content().contentType("application/xml"));
    actions.andExpect(xpath("/vets/vetList[id=1]  /firstName").string(containsString("James")));
}
}
venergiac
  • 7,469
  • 2
  • 48
  • 70
Alex
  • 7,007
  • 18
  • 69
  • 114

1 Answers1

1

Based on the comment I changed the Spring version in the pom.xml, pointing to 4.0.1. instead of 4.0.0.

<spring-framework.version>4.0.1.RELEASE</spring-framework.version>
Alex
  • 7,007
  • 18
  • 69
  • 114