openidposturlhandlermappingtests.java

来自「CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On 」· Java 代码 · 共 84 行

JAVA
84
字号
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.uportal.org/license.html */package org.jasig.cas.support.openid.web.support;import java.util.HashMap;import java.util.Map;import org.jasig.cas.support.openid.web.support.OpenIdPostUrlHandlerMapping;import org.springframework.beans.factory.support.RootBeanDefinition;import org.springframework.mock.web.MockHttpServletRequest;import org.springframework.web.context.support.GenericWebApplicationContext;import junit.framework.TestCase;/** *  * @author Scott Battaglia * @version $Revision: 1.1 $ $Date: 2005/08/19 18:27:17 $ * @since 3.1 * */public class OpenIdPostUrlHandlerMappingTests extends TestCase {    private OpenIdPostUrlHandlerMapping handlerMapping;    protected void setUp() throws Exception {        final GenericWebApplicationContext context = new GenericWebApplicationContext();        final RootBeanDefinition definition = new RootBeanDefinition(Object.class);        context.registerBeanDefinition("testHandler", definition);        context.start();        final Map<String, Object> properties = new HashMap<String, Object>();        properties.put("/login", new Object());        this.handlerMapping = new OpenIdPostUrlHandlerMapping();        this.handlerMapping.setUrlMap(properties);        this.handlerMapping.initApplicationContext();        super.setUp();    }        public void testNoMatch() {        final MockHttpServletRequest request = new MockHttpServletRequest();        request.setContextPath("/hello");                assertNull(this.handlerMapping.lookupHandler("/hello", request));    }        public void testImproperMatch() {        final MockHttpServletRequest request = new MockHttpServletRequest();        request.setContextPath("/hello");                assertNull(this.handlerMapping.lookupHandler("/login", request));    }        public void testProperMatchWrongMethod() {        final MockHttpServletRequest request = new MockHttpServletRequest();        request.setContextPath("/login");        request.setMethod("GET");                assertNull(this.handlerMapping.lookupHandler("/login", request));    }        public void testProperMatchCorrectMethodNoParam() {        final MockHttpServletRequest request = new MockHttpServletRequest();        request.setContextPath("/login");        request.setMethod("POST");                assertNull(this.handlerMapping.lookupHandler("/login", request));    }        public void testProperMatchCorrectMethodWithParam() {        final MockHttpServletRequest request = new MockHttpServletRequest();        request.setContextPath("/login");        request.setMethod("POST");        request.setParameter("openid.mode", "check_authentication");                        assertNotNull(this.handlerMapping.lookupHandler("/login", request));    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?