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


Java RequestContextHolder.setRequestContext方法代码示例

本文整理汇总了Java中org.springframework.webflow.execution.RequestContextHolder.setRequestContext方法的典型用法代码示例。如果您正苦于以下问题:Java RequestContextHolder.setRequestContext方法的具体用法?Java RequestContextHolder.setRequestContext怎么用?Java RequestContextHolder.setRequestContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.webflow.execution.RequestContextHolder的用法示例。


在下文中一共展示了RequestContextHolder.setRequestContext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");

    this.servicesManager.save(r);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    final RequestContext ctx = mock(RequestContext.class);
    final MutableAttributeMap scope = new LocalAttributeMap();
    scope.put("service", org.jasig.cas.services.TestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader("User-Agent", "Mozilla");
    assertEquals("test", this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例2: verifyGetServiceWithTheme

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceWithTheme() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new WebApplicationServiceFactory().createService("myServiceId");
    requestContext.getFlowScope().put("service", webApplicationService);

    final ResourceLoader loader = mock(ResourceLoader.class);
    final Resource resource = mock(Resource.class);
    when(resource.exists()).thenReturn(true);
    when(loader.getResource(anyString())).thenReturn(resource);

    this.registeredServiceThemeBasedViewResolver.setResourceLoader(loader);

    assertEquals("/WEB-INF/view/jsp/myTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例3: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");

    this.servicesManager.save(r);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    final RequestContext ctx = mock(RequestContext.class);
    final MutableAttributeMap scope = new LocalAttributeMap();
    scope.put("service", TestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader("User-Agent", "Mozilla");
    assertEquals("test", this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例4: verifyGetServiceThemeDoesNotExist

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceThemeDoesNotExist() {
    final RegexRegisteredService r = new RegexRegisteredService();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");

    this.servicesManager.save(r);

    final MockHttpServletRequest request = new MockHttpServletRequest();
    final RequestContext ctx = mock(RequestContext.class);
    final MutableAttributeMap scope = new LocalAttributeMap();
    scope.put("service", RegisteredServiceTestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader(WebUtils.USER_AGENT_HEADER, MOZILLA);
    assertEquals(DEFAULT_THEME_NAME, this.serviceThemeResolver.resolveThemeName(request));
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:ServiceThemeResolverTests.java

示例5: verifyGetServiceWithDefault

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceWithDefault() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new WebApplicationServiceFactory().createService("myDefaultId");
    requestContext.getFlowScope().put("service", webApplicationService);

    assertEquals("/WEB-INF/view/jsp/default/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例6: verifyNoService

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyNoService() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    assertEquals("/WEB-INF/view/jsp/default/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例7: verifyGetServiceWithTheme

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceWithTheme() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new SimpleWebApplicationServiceImpl("myServiceId");
    requestContext.getFlowScope().put("service", webApplicationService);

    assertEquals("/WEB-INF/view/jsp/myTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例8: verifyGetServiceWithDefault

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceWithDefault() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new SimpleWebApplicationServiceImpl("myDefaultId");
    requestContext.getFlowScope().put("service", webApplicationService);

    assertEquals("/WEB-INF/view/jsp/defaultTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例9: verifyNoService

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyNoService() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    assertEquals("/WEB-INF/view/jsp/defaultTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例10: before

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Before
public void before() {
    final RequestContext ctx = mock(RequestContext.class);
    when(ctx.getConversationScope()).thenReturn(new LocalAttributeMap<>());
    WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), ctx);
    RequestContextHolder.setRequestContext(ctx);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:8,代码来源:YubiKeyAuthenticationHandlerTests.java

示例11: verifyGetServiceWithTheme

import org.springframework.webflow.execution.RequestContextHolder; //导入方法依赖的package包/类
@Test
public void verifyGetServiceWithTheme() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new WebApplicationServiceFactory().createService("myServiceId");
    requestContext.getFlowScope().put("service", webApplicationService);

    assertEquals("/WEB-INF/view/jsp/myTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:12,代码来源:RegisteredServiceThemeBasedViewResolverTests.java


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