⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 annotationbeanpostprocessortests.java

📁 CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一
💻 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.util.annotation;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;import java.util.Map;import org.springframework.beans.FatalBeanException;import junit.framework.TestCase;/** *  * @author Scott Battaglia * @version $Revision: 1.1 $ $Date: 2005/08/19 18:27:17 $ * @since 3.1 * */public class AnnotationBeanPostProcessorTests extends TestCase {        private AbstractAnnotationBeanPostProcessor[] processors = new AbstractAnnotationBeanPostProcessor[] {new GreaterThanAnnotationBeanPostProcessor(), new IsInAnnotationBeanPostProcessor(), new NotEmptyAnnotationBeanPostProcessor(), new NotNullAnnotationBeanPostProcessor()};         public void testFailed() {        for (final AbstractAnnotationBeanPostProcessor processor : this.processors) {            try {                processor.postProcessBeforeInitialization(new BadTestClass(), "test");                fail("processor: " + processor.getClass().getName() + "did not fail.");            } catch (final FatalBeanException e) {                System.out.println(e.getMessage());            }        }                try {            this.processors[2].postProcessBeforeInitialization(new BadNotEmptyCollection(), "test");            fail("processor: " + this.processors[2].getClass().getName() + " did not fail.");        } catch (final FatalBeanException e) {            System.out.println(e.getMessage());        }                try {            this.processors[2].postProcessBeforeInitialization(new BadNotEmptyArray(), "test");            fail("processor: " + this.processors[2].getClass().getName() + " did not fail.");        } catch (final FatalBeanException e) {            System.out.println(e.getMessage());        }                try {            this.processors[2].postProcessBeforeInitialization(new BadNotEmptyArray2(), "test");            fail("processor: " + this.processors[2].getClass().getName() + " did not fail.");        } catch (final FatalBeanException e) {            System.out.println(e.getMessage());        }    }    public void testPassed() {        for (final AbstractAnnotationBeanPostProcessor processor : this.processors) {            try {                processor.postProcessBeforeInitialization(new GoodTestClass(), "test");                            } catch (final FatalBeanException e) {                fail("processor: " + processor.getClass().getName() + "did fail:" + e.getMessage());            }        }    }        protected class BadNotEmptyCollection {        @SuppressWarnings("unused")        @NotEmpty        private Collection c =  new ArrayList();    }    protected class BadNotEmptyArray {        @SuppressWarnings("unused")        @NotEmpty        private Object[] os2 = null;    }        protected class BadNotEmptyArray2 {        @SuppressWarnings("unused")        @NotEmpty        private Object[] os2 = new Object[0];    }    protected class BadSuperTestClass {        @SuppressWarnings("unused")        @NotNull        private String testNull = null;    }        protected class BadTestClass extends BadSuperTestClass {                @SuppressWarnings("unused")        @GreaterThan(0)        @IsIn({0,1,2})        private int test = -1;        @SuppressWarnings("unused")        @NotNull        private String testNull = null;                @SuppressWarnings("unused")        @NotEmpty        private Map map = new HashMap();    }protected class GoodTestClass {                @SuppressWarnings("unused")        @GreaterThan(0)        @IsIn({0,1,2})        private int test = 1;                @SuppressWarnings("unused")        @NotNull        private String testNull = "haha";                @NotEmpty        private Collection<Object> c =  new ArrayList<Object>();                @SuppressWarnings("unused")        private final Object[] os = new Object[] {new Object()};                @NotEmpty        private Map<String,String> map = new HashMap<String,String>();                public GoodTestClass() {            this.c.add(new Object());            this.map.put("test", "test");        }            }    }

⌨️ 快捷键说明

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