当前位置: 首页>>代码示例>>Java>>正文


Java RequestPostProcessor类代码示例

本文整理汇总了Java中org.springframework.test.web.servlet.request.RequestPostProcessor的典型用法代码示例。如果您正苦于以下问题:Java RequestPostProcessor类的具体用法?Java RequestPostProcessor怎么用?Java RequestPostProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestPostProcessor类属于org.springframework.test.web.servlet.request包,在下文中一共展示了RequestPostProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: userToken

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
protected RequestPostProcessor userToken() {
    return new RequestPostProcessor() {
        @Override
        public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
            // If the tests requires setup logic for users, you can place it here.
            // Authorization headers or cookies for users should be added here as well.
            String accessToken;
            try {
                accessToken = getAccessToken("test", "test");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            request.addHeader("Authorization", "Bearer " + accessToken);
            return documentAuthorization(request, "User access token required.");
        }
    };
}
 
开发者ID:ScaCap,项目名称:spring-auto-restdocs,代码行数:18,代码来源:MockMvcBase.java

示例2: whenUserInfoNotInSessionThenEmptySessionExceptionIsThrown

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Test
public void whenUserInfoNotInSessionThenEmptySessionExceptionIsThrown() throws Exception{

	mockMvc.perform(get("/summary")
			.accept(MediaType.APPLICATION_JSON)
			.with(new RequestPostProcessor() {
				
				@Override
				public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
					
					request.getSession(true);
					return request;
				}
			}))
			.andExpect(status().isInternalServerError())
			.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
 
开发者ID:is-apps,项目名称:AlmaPortlet,代码行数:18,代码来源:ServletIntegrationTest.java

示例3: whenUserInfoHasInvalidBarcodeThenPatronLibraryAccessExceptionIsThrown

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Test
public void whenUserInfoHasInvalidBarcodeThenPatronLibraryAccessExceptionIsThrown() throws Exception {

	final UserInfo userInfo = new UserInfo("BadUUN","BadBarcode","BadSurname");

		mockMvc.perform(get("/summary")
			.accept(MediaType.APPLICATION_JSON)
			.with(new RequestPostProcessor() {
				
				@Override
				public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
					
					MockHttpSession mockSession = (MockHttpSession) request.getSession(true);
					mockSession.setAttribute(UserInfo.SESSION_ATTR, userInfo);
					request.setSession(mockSession);
					
					return request;
				}
			}))
			.andExpect(status().isOk())
			.andExpect(content().contentType(MediaType.APPLICATION_JSON))
			.andExpect(jsonPath("$.*", hasSize(9)))
			.andExpect(jsonPath("$.message", nullValue()))
			.andExpect(jsonPath("$.payload", nullValue()))
			.andReturn();
}
 
开发者ID:is-apps,项目名称:AlmaPortlet,代码行数:27,代码来源:ServletIntegrationTest.java

示例4: build

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
/**
 * Build a {@link org.springframework.test.web.servlet.MockMvc} instance.
 */
@Override
@SuppressWarnings("rawtypes")
public final MockMvc build() {

	WebApplicationContext wac = initWebAppContext();

	ServletContext servletContext = wac.getServletContext();
	MockServletConfig mockServletConfig = new MockServletConfig(servletContext);

	for (MockMvcConfigurer configurer : this.configurers) {
		RequestPostProcessor processor = configurer.beforeMockMvcCreated(this, wac);
		if (processor != null) {
			if (this.defaultRequestBuilder == null) {
				this.defaultRequestBuilder = MockMvcRequestBuilders.get("/");
			}
			if (this.defaultRequestBuilder instanceof ConfigurableSmartRequestBuilder) {
				((ConfigurableSmartRequestBuilder) this.defaultRequestBuilder).with(processor);
			}
		}
	}

	Filter[] filterArray = this.filters.toArray(new Filter[this.filters.size()]);

	return super.createMockMvc(filterArray, mockServletConfig, wac, this.defaultRequestBuilder,
			this.globalResultMatchers, this.globalResultHandlers, this.dispatchOptions);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:AbstractMockMvcBuilder.java

示例5: beforeMockMvcCreated

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Override
public RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder,
		WebApplicationContext context) {
	return request -> {
		request.setUserPrincipal(mock(Principal.class));
		return request;
	};
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:FrameworkExtensionTests.java

示例6: testAuthenticatedUser

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Test
public void testAuthenticatedUser() throws Exception {
    restUserMockMvc.perform(get("/api/authenticate")
            .with(new RequestPostProcessor() {
                public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
                    request.setRemoteUser("test");
                    return request;
                }
            })
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().string("test"));
}
 
开发者ID:josedab,项目名称:angularjs-springboot-bookstore,代码行数:14,代码来源:AccountResourceTest.java

示例7: bearerToken

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
public RequestPostProcessor bearerToken(final String clientid, final String username) {
	return mockRequest -> {
		OAuth2Authentication auth = oAuth2Authentication(clientid, username);
		OAuth2AccessToken token = tokenservice.createAccessToken(auth);
		mockRequest.addHeader("Authorization", "Bearer " + token.getValue());
		return mockRequest;
	};
}
 
开发者ID:timtebeek,项目名称:resource-server-testing,代码行数:9,代码来源:OAuthHelper.java

示例8: testAuthenticatedUser

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Test
public void testAuthenticatedUser() throws Exception {
    restUserMockMvc.perform(get("/app/rest/authenticate")
            .with(new RequestPostProcessor() {
                public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
                    request.setRemoteUser("test");
                    return request;
                }
            })
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().string("test"));
}
 
开发者ID:thpham,项目名称:ithings-demo,代码行数:14,代码来源:AccountResourceTest.java

示例9: testAuthenticatedUser

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Test
public void testAuthenticatedUser() throws Exception {
    restUserMockMvc.perform(get("/api/authenticate")
            .with(new RequestPostProcessor() {
                public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
                    request.setRemoteUser("test");
                    return request;
                }
            })
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(status().isOk())
            .andExpect(content().string("test"));
}
 
开发者ID:IHTSDO,项目名称:MLDS,代码行数:14,代码来源:AccountResourceTest.java

示例10: oauth2Authentication

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
public RequestPostProcessor oauth2Authentication(String username, Set<String> scopes) {
    return oauth2Authentication(username, scopes, Collections.emptySet());
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:4,代码来源:OAuth2TokenMockUtil.java

示例11: userCredentials

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
private RequestPostProcessor userCredentials() {
	return httpBasic("user", "password");
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:4,代码来源:SampleSecureOAuth2ActuatorApplicationTests.java

示例12: setupRequest

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
private RequestPostProcessor setupRequest() {
    return request -> {
        request.setRemoteAddr("127.0.0.1");
        return request;
    };
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:7,代码来源:DeviceCertificateCtrlExampleRequests.java

示例13: testPostpage0

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
private ResultActions testPostpage0(RequestPostProcessor postProcessor) throws Exception {
    log.info("postpage");
    Long problem_id = null;
    return mvc.perform(get("/postpage").with(postProcessor)
            .param("problem_id", Objects.toString(problem_id, "")));
}
 
开发者ID:zjnu-acm,项目名称:judge,代码行数:7,代码来源:BBSControllerTest.java

示例14: beforeMockMvcCreated

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
@Override
public RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder, WebApplicationContext cxt) {
	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MockMvcConfigurerAdapter.java

示例15: setForwardPostProcessor

import org.springframework.test.web.servlet.request.RequestPostProcessor; //导入依赖的package包/类
public void setForwardPostProcessor(RequestPostProcessor forwardPostProcessor) {
	this.forwardPostProcessor = forwardPostProcessor;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:HtmlUnitRequestBuilder.java


注:本文中的org.springframework.test.web.servlet.request.RequestPostProcessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。