📄 openidposturlhandlermappingtests.java
字号:
/* * 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -