Получение ошибки для методов MockMvc Perform()

Я создаю тест контроллера Spring MVC. Компилятор показывает ошибки для методов, выделенных ниже жирным шрифтом. Мне не хватает какой-то библиотеки или чего-то еще в моем коде? Какие-либо предложения?

Я использую следующие зависимости:

  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
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.MockMvcBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import com.zerosolutions.view.form.LoginCredentials;

@RunWith(value=SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration("classpath:dispatcher-servlet.xml")
public class TestingFrontController {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

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

    @Test
    public void getLoginSignupPage() throws Exception{
        this.mockMvc.perform(**get**("/"))
        .andExpect(status().isOk())
        .andExpect(forwardedUrl("login"))
        .andExpect(model().attribute("loginCred", **any**(LoginCredentials.class)));
    }

}

person Meena Chaudhary    schedule 30.10.2015    source источник
comment
что вы импортируете?   -  person sidgate    schedule 30.10.2015


Ответы (1)


добавьте следующее, чтобы импортировать эти методы

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
person sidgate    schedule 30.10.2015
comment
Это помогло, но все еще получаю за get() и any() - person Meena Chaudhary; 30.10.2015