Java 类org.springframework.test.web.servlet.setup.MockMvcBuilders 实例源码

项目:xm-uaa    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterOnOtherPath() throws Exception {
    props.getCors().setAllowedOrigins(Collections.singletonList("*"));
    props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
    props.getCors().setAllowedHeaders(Collections.singletonList("*"));
    props.getCors().setMaxAge(1800L);
    props.getCors().setAllowCredentials(true);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/test/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
项目:xm-ms-dashboard    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterOnOtherPath() throws Exception {
    props.getCors().setAllowedOrigins(Collections.singletonList("*"));
    props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
    props.getCors().setAllowedHeaders(Collections.singletonList("*"));
    props.getCors().setMaxAge(1800L);
    props.getCors().setAllowCredentials(true);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/test/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:ProfileInfoResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    String mockProfile[] = {"test"};
    JHipsterProperties.Ribbon ribbon = new JHipsterProperties.Ribbon();
    ribbon.setDisplayOnActiveProfiles(mockProfile);
    when(jHipsterProperties.getRibbon()).thenReturn(ribbon);

    String activeProfiles[] = {"test"};
    when(environment.getDefaultProfiles()).thenReturn(activeProfiles);
    when(environment.getActiveProfiles()).thenReturn(activeProfiles);

    ProfileInfoResource profileInfoResource = new ProfileInfoResource(environment, jHipsterProperties);
    this.restProfileMockMvc = MockMvcBuilders
        .standaloneSetup(profileInfoResource)
        .build();
}
项目:xm-ms-entity    文件:XmEntityResourceExtendedIntTest.java   
@Before
public void setup() {
    log.info("Init setup");

    //  xmEntitySearchRepository.deleteAll();

    TenantContext.setCurrent("RESINTTEST");
    lepManager.beginThreadContext(ctx -> {
        ctx.setValue(XmLepConstants.CONTEXT_KEY_TENANT, TenantContext.getCurrent());
    });

    MockitoAnnotations.initMocks(this);
    CalendarResource calendarResource = new CalendarResource(calendarService);
    EventResource eventResource = new EventResource(eventService);
    XmEntityResource xmEntityResource = new XmEntityResource(xmEntityService, profileService, profileEventProducer);
    this.restXmEntityMockMvc = MockMvcBuilders.standaloneSetup(xmEntityResource, calendarResource, eventResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setValidator(validator)
        .setMessageConverters(jacksonMessageConverter).build();

    xmEntityIncoming = createEntityComplexIncoming(em);

}
项目:shoucang    文件:AccountResourceTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    doNothing().when(mockMailService).sendActivationEmail((User) anyObject(), anyString());

    AccountResource accountResource = new AccountResource();
    ReflectionTestUtils.setField(accountResource, "userRepository", userRepository);
    ReflectionTestUtils.setField(accountResource, "userService", userService);
    ReflectionTestUtils.setField(accountResource, "mailService", mockMailService);

    AccountResource accountUserMockResource = new AccountResource();
    ReflectionTestUtils.setField(accountUserMockResource, "userRepository", userRepository);
    ReflectionTestUtils.setField(accountUserMockResource, "userService", mockUserService);
    ReflectionTestUtils.setField(accountUserMockResource, "mailService", mockMailService);

    this.restMvc = MockMvcBuilders.standaloneSetup(accountResource).build();
    this.restUserMockMvc = MockMvcBuilders.standaloneSetup(accountUserMockResource).build();
}
项目:jhipster-microservices-example    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterOnOtherPath() throws Exception {
    props.getCors().setAllowedOrigins(Collections.singletonList("*"));
    props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
    props.getCors().setAllowedHeaders(Collections.singletonList("*"));
    props.getCors().setMaxAge(1800L);
    props.getCors().setAllowCredentials(true);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/test/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
项目:jhipster-microservices-example    文件:ExceptionTranslatorTest.java   
@Test
public void processValidationErrorTest() throws Exception {
    UserJWTController control = new UserJWTController(null, null);
    MockMvc jwtMock = MockMvcBuilders.standaloneSetup(control)
        .setControllerAdvice(new ExceptionTranslator())
        .build();
    MvcResult res = jwtMock.perform(post("/api/authenticate")
        .contentType(MediaType.APPLICATION_JSON_UTF8)
        .accept(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL)
        .content("{\"username\":\"fakeUsernameTooLongfakeUsernameTooLongfakeUsernameTooLongfakeUsernameTooLong" +
            "\",\"password\":\"fakePassword\",\"rememberMe\":false}"))
        .andExpect(status().isBadRequest())
        .andReturn();

    assertThat(res.getResolvedException(), instanceOf(MethodArgumentNotValidException.class));
}
项目:jhipster-microservices-example    文件:ProfileInfoResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    String mockProfile[] = {"test"};
    JHipsterProperties.Ribbon ribbon = new JHipsterProperties.Ribbon();
    ribbon.setDisplayOnActiveProfiles(mockProfile);
    when(jHipsterProperties.getRibbon()).thenReturn(ribbon);

    String activeProfiles[] = {"test"};
    when(environment.getDefaultProfiles()).thenReturn(activeProfiles);
    when(environment.getActiveProfiles()).thenReturn(activeProfiles);

    ProfileInfoResource profileInfoResource = new ProfileInfoResource(environment, jHipsterProperties);
    this.restProfileMockMvc = MockMvcBuilders
        .standaloneSetup(profileInfoResource)
        .build();
}
项目:spring-io    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterOnOtherPath() throws Exception {
    props.getCors().setAllowedOrigins(Collections.singletonList("*"));
    props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
    props.getCors().setAllowedHeaders(Collections.singletonList("*"));
    props.getCors().setMaxAge(1800L);
    props.getCors().setAllowCredentials(true);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/test/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
项目:xm-ms-timeline    文件:ProfileInfoResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    String mockProfile[] = {"test"};
    JHipsterProperties.Ribbon ribbon = new JHipsterProperties.Ribbon();
    ribbon.setDisplayOnActiveProfiles(mockProfile);
    when(jHipsterProperties.getRibbon()).thenReturn(ribbon);

    String activeProfiles[] = {"test"};
    when(environment.getDefaultProfiles()).thenReturn(activeProfiles);
    when(environment.getActiveProfiles()).thenReturn(activeProfiles);

    ProfileInfoResource profileInfoResource = new ProfileInfoResource(environment, jHipsterProperties);
    this.restProfileMockMvc = MockMvcBuilders
        .standaloneSetup(profileInfoResource)
        .build();
}
项目:xm-ms-entity    文件:LocationResourceIntTest.java   
@Before
public void setup() {

    TenantContext.setCurrent("RESINTTEST");

    MockitoAnnotations.initMocks(this);
    LocationResource locationResource = new LocationResource(locationRepository, locationSearchRepository);
    this.restLocationMockMvc = MockMvcBuilders.standaloneSetup(locationResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setValidator(validator)
        .setMessageConverters(jacksonMessageConverter).build();

    location = createEntity(em);

}
项目:TorgCRM-Server    文件:ProjectResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final ProjectResource projectResource = new ProjectResource(projectService);
    this.restProjectMockMvc = MockMvcBuilders.standaloneSetup(projectResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setConversionService(createFormattingConversionService())
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:EntryResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    EntryResource entryResource = new EntryResource(entryRepository, entrySearchRepository);
    this.restEntryMockMvc = MockMvcBuilders.standaloneSetup(entryResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:xm-ms-config    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterDeactivated2() throws Exception {
    props.getCors().setAllowedOrigins(new ArrayList<>());

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
项目:spring-boot-oauth2-demo    文件:SpringfoxConfigTest.java   
@Before
public void setup() throws IOException {
    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();

    ClassPathResource pathfileRes = new ClassPathResource("application.yml");
    projectDir = pathfileRes.getFile().getParentFile().getParentFile().getParentFile();
}
项目:xm-uaa    文件:SocialControllerIntTest.java   
@Before
@SneakyThrows
public void setup() {
    TenantProperties properties = new TenantProperties();
    properties.setSocial(asList(
        new TenantProperties.Social("twitter", "xxx", "yyy", DEFAULT_DOMAIN),
        new TenantProperties.Social("facebook", "xxx", "yyy", DEFAULT_DOMAIN)
    ));
    tenantPropertiesService.onRefresh("/config/tenants/"+ DEFAULT_TENANT + "/uaa/uaa.yml",
        new ObjectMapper(new YAMLFactory()).writeValueAsString(properties));

    MockitoAnnotations.initMocks(this);
    SocialController socialController = new SocialController(socialService, providerSignInUtils,
        connectionFactoryLocator, usersConnectionRepository, signInAdapter, connectSupport, sessionStrategy, socialConfigRepository);
    this.restUserMockMvc = MockMvcBuilders.standaloneSetup(socialController)
        .setControllerAdvice(exceptionTranslator)
        .setMessageConverters(jacksonMessageConverter)
        .build();
    when(sessionStrategy.getAttribute(any(RequestAttributes.class), eq(ProviderSignInAttempt.SESSION_ATTRIBUTE)))
        .thenReturn(providerSignInAttempt);
    when(connection.fetchUserProfile())
        .thenReturn(new UserProfile("id", "name", "fname", "lname", "email", "username"));
    when(connection.createData()).thenReturn(
        new ConnectionData("twitter", "providerUserId", "displayName", "profileUrl", "imageUrl", "", "secret",
            "refreshToken", 1000L));
    Mockito.<Connection<?>>when(connectSupport.completeConnection(any(OAuth1ConnectionFactory.class), any()))
        .thenReturn(connection);
    Mockito.<Connection<?>>when(connectSupport.completeConnection(any(OAuth2ConnectionFactory.class), any()))
        .thenReturn(connection);
    when(connectSupport.buildOAuthUrl(any(), any(), any())).thenReturn("SomeCallbackUrl");
    Mockito.<Connection<?>>when(providerSignInAttempt.getConnection(any())).thenReturn(connection);
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Test
public void testCorsFilterOnApiPath() throws Exception {
    props.getCors().setAllowedOrigins(Collections.singletonList("*"));
    props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
    props.getCors().setAllowedHeaders(Collections.singletonList("*"));
    props.getCors().setMaxAge(1800L);
    props.getCors().setAllowCredentials(true);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        options("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com")
            .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST"))
        .andExpect(status().isOk())
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "other.domain.com"))
        .andExpect(header().string(HttpHeaders.VARY, "Origin"))
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,POST,PUT,DELETE"))
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"))
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "1800"));

    mockMvc.perform(
        get("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "other.domain.com"));
}
项目:buenojo    文件:LevelResourceTest.java   
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    LevelResource levelResource = new LevelResource();
    ReflectionTestUtils.setField(levelResource, "levelRepository", levelRepository);
    this.restLevelMockMvc = MockMvcBuilders.standaloneSetup(levelResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:xm-uaa    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterOnApiPath() throws Exception {
    props.getCors().setAllowedOrigins(Collections.singletonList("*"));
    props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
    props.getCors().setAllowedHeaders(Collections.singletonList("*"));
    props.getCors().setMaxAge(1800L);
    props.getCors().setAllowCredentials(true);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        options("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com")
            .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST"))
        .andExpect(status().isOk())
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "other.domain.com"))
        .andExpect(header().string(HttpHeaders.VARY, "Origin"))
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,POST,PUT,DELETE"))
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"))
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "1800"));

    mockMvc.perform(
        get("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "other.domain.com"));
}
项目:spring-io    文件:AuditResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    AuditEventService auditEventService =
        new AuditEventService(auditEventRepository, auditEventConverter);
    AuditResource auditResource = new AuditResource(auditEventService);
    this.restAuditMockMvc = MockMvcBuilders.standaloneSetup(auditResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setConversionService(formattingConversionService)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:buenojo    文件:CourseResourceTest.java   
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    CourseResource courseResource = new CourseResource();
    ReflectionTestUtils.setField(courseResource, "courseRepository", courseRepository);
    this.restCourseMockMvc = MockMvcBuilders.standaloneSetup(courseResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:xm-ms-config    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterDeactivated() throws Exception {
    props.getCors().setAllowedOrigins(null);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
项目:meparty    文件:RestfulExceptionHandlerTest.java   
@Before
public void setUp() {

  testController = Mockito.mock(TestController.class);

  this.mockMvc = MockMvcBuilders.standaloneSetup(testController)
      .setControllerAdvice(new RestfulExceptionHandler())
      .build();
}
项目:sentry    文件:PrivilegeResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    PrivilegeResource privilegeResource = new PrivilegeResource();
    ReflectionTestUtils.setField(privilegeResource, "privilegeRepository", privilegeRepository);
    this.restPrivilegeMockMvc = MockMvcBuilders.standaloneSetup(privilegeResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:xm-ms-entity    文件:EventResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    EventResource eventResource = new EventResource(eventService);
    this.restEventMockMvc = MockMvcBuilders.standaloneSetup(eventResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:jhipster-microservices-example    文件:UserResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    UserResource userResource = new UserResource(userRepository, mailService, userService, userSearchRepository);
    this.restUserMockMvc = MockMvcBuilders.standaloneSetup(userResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setMessageConverters(jacksonMessageConverter)
        .build();
}
项目:petstore-order    文件:APIBaseTest.java   
@Before
public void baseBefore() {
    this.mockMvc =
            MockMvcBuilders.
                    webAppContextSetup(this.wac).
                    build();
}
项目:jhipster-microservices-example    文件:LogsResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);

    LogsResource logsResource = new LogsResource();
    this.restLogsMockMvc = MockMvcBuilders
        .standaloneSetup(logsResource)
        .build();
}
项目:buenojo    文件:CourseLevelSessionResourceIntTest.java   
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    CourseLevelSessionResource courseLevelSessionResource = new CourseLevelSessionResource();
    ReflectionTestUtils.setField(courseLevelSessionResource, "courseLevelSessionRepository", courseLevelSessionRepository);
    this.restCourseLevelSessionMockMvc = MockMvcBuilders.standaloneSetup(courseLevelSessionResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:qualitoast    文件:CampagneResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final CampagneResource campagneResource = new CampagneResource(campagneService);
    this.restCampagneMockMvc = MockMvcBuilders.standaloneSetup(campagneResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setConversionService(createFormattingConversionService())
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:Your-Microservice    文件:ExampleClientIntegrationIT.java   
/**
 * Before each Test perform Mock Reset Assured Setup...
 *
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    RestAssuredMockMvc.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
    RestAssuredMockMvc.enableLoggingOfRequestAndResponseIfValidationFails();
}
项目:Smart-Shopping    文件:MvcControllerSecurityTest.java   
@Before
public void setup() {
    this.mockMvc = MockMvcBuilders//
            .webAppContextSetup(webApplicationContext)//
            .apply(springSecurity())
            .build();
}
项目:spring-boot-completablefuture    文件:UserControllerIntTest.java   
@Before
public void setup() {
    this.mockMvc = MockMvcBuilders
            .standaloneSetup(userController)
            .setCustomArgumentResolvers(pageableArgumentResolver)
            .build();
}
项目:jhipster-microservices-example    文件:ExceptionTranslatorTest.java   
@Before
public void setup() {
    SecurityContextHolder.clearContext();
    AccountResource control = new AccountResource();
    this.mock = MockMvcBuilders.standaloneSetup(control)
        .setControllerAdvice(new ExceptionTranslator())
        .build();
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:TagResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    TagResource tagResource = new TagResource(tagRepository, tagSearchRepository);
    this.restTagMockMvc = MockMvcBuilders.standaloneSetup(tagResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:school-express-delivery    文件:UserTest.java   
@Before
public void setup() throws Exception {
    mockMvc = MockMvcBuilders.webAppContextSetup(applicationContext).build();
    recipToken = TestUtil.getToken(mockMvc, "18217699894", "123456");
    replaceToken = TestUtil.getToken(mockMvc, "18217699800", "123456");
    adminToken = TestUtil.getToken(mockMvc, "18217699895", "123456");
    System.out.println("收件人TOKEN:" + recipToken);
    System.out.println("代取人TOKEN:" + replaceToken);
    System.out.println("管理员TOKEN:" + adminToken);
}
项目:qualitoast    文件:TypeTestResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final TypeTestResource typeTestResource = new TypeTestResource(typeTestService);
    this.restTypeTestMockMvc = MockMvcBuilders.standaloneSetup(typeTestResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setConversionService(createFormattingConversionService())
        .setMessageConverters(jacksonMessageConverter).build();
}
项目:bxbot-ui-server    文件:TestAuthenticationController.java   
@Before
public void setup() {
    mockMvc = MockMvcBuilders
            .webAppContextSetup(context)
            .apply(springSecurity())
            .build();
}
项目:devoxxus-jhipster-microservices-demo    文件:LogsResourceIntTest.java   
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);

    LogsResource logsResource = new LogsResource();
    this.restLogsMockMvc = MockMvcBuilders
        .standaloneSetup(logsResource)
        .build();
}
项目:xm-ms-timeline    文件:WebConfigurerTest.java   
@Test
public void testCorsFilterDeactivated() throws Exception {
    props.getCors().setAllowedOrigins(null);

    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
        .addFilters(webConfigurer.corsFilter())
        .build();

    mockMvc.perform(
        get("/api/test-cors")
            .header(HttpHeaders.ORIGIN, "other.domain.com"))
        .andExpect(status().isOk())
        .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}