亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? testvalidwhen.java

?? struts的源代碼
?? JAVA
字號(hào):
/*
 * $Id: TestValidWhen.java 54929 2004-10-16 16:38:42Z germuska $ 
 *
 * Copyright 2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.struts.validator;

import java.io.StringReader;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.struts.validator.validwhen.ValidWhenLexer;
import org.apache.struts.validator.validwhen.ValidWhenParser;
import org.apache.commons.validator.util.ValidatorUtils;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;


/**
 * Unit tests for the ValidWhen Parser/Lexer.
 */
public class TestValidWhen extends TestCase {
    
    /** All logging goes through this logger */
    private static Log log = LogFactory.getLog(TestValidWhen.class);

    protected PojoBean testBean;

    /**
     * Defines the testcase name for JUnit.
     *
     * @param theName the testcase's name.
     */
    public TestValidWhen(String theName) {
        super(theName);
    }

    /**
     * Start the tests.
     *
     * @param theArgs the arguments. Not used
     */
    public static void main(String[] theArgs) {
        junit.awtui.TestRunner.main(
            new String[] {TestValidWhen.class.getName()});
    }

    /**
     * @return a test suite (<code>TestSuite</code>) that includes all methods
     *         starting with "test"
     */
    public static Test suite() {
        // All methods starting with "test" will be executed in the test suite.
        return new TestSuite(TestValidWhen.class);
    }

    public void setUp() {
        testBean = new PojoBean(123, 789);
        testBean.setStringValue1("ABC"); 
        testBean.setStringValue2(null);
        testBean.setBeans(new PojoBean[] {new PojoBean(11, 12),
                                          new PojoBean(21, 22),
                                          new PojoBean(31, 42),
                                          new PojoBean(41, 52),
                                          new PojoBean(51, 62)});
        testBean.setMapped("testKey", "mappedValue");
    }

    public void tearDown() {
        testBean = null;
    }
    
    /**
     * Test Operators.
     */
    public void testProperty() {

        // *this*
        doParse("(*this* == 123)", testBean , 0, "intValue1", true);

        // Named property
        doParse("(intValue2 == 789)", testBean , 0, "intValue1", true);

        // Indexed Property
        doParse("(beans[].intValue1 == 21)", testBean , 1, "intValue1", true);
        doParse("(beans[1].intValue1 == 21)", testBean , 4, "intValue1", true);

        // Mapped Property - *** NOT SUPPORTED ***
        // doParse("(mapped(mappedValue) == 'testKey')", testBean , 0, "mappedValue", true);


    }
    
    /**
     * Test Operators.
     */
    public void testOperators() {

        // Equal
        doParse("(*this* == 123)", testBean , 0, "intValue1", true);

        // Not Equal
        doParse("(*this* != 456)", testBean , 0, "intValue1", true);

        // Less Than
        doParse("(*this* < 456)", testBean , 0, "intValue1", true);

        // Greater Than
        doParse("(*this* > 100)", testBean , 0, "intValue1", true);

        // Less Than Equal
        doParse("(*this* <= 123)", testBean , 0, "intValue1", true);

        // Greater Than Equal
        doParse("(*this* >= 123)", testBean , 0, "intValue1", true);

    }

    /**
     * Test String values.
     */
    public void testString() {

         doParse("(*this* != '--')", "XX", 0, "stringValue1", true);
         doParse("(*this* == '--')", "--", 0, "stringValue1", true);


         String testValue = "dsgUOLMdLsdL";

         // single quote
         doParse("(*this* == '" + testValue + "')", testValue, 0, "stringValue1", true);

         // double quote
         doParse("(*this* == \"" + testValue + "\")", testValue, 0, "stringValue1", true);
    }
    
    /**
     * Test Numeric values.
     */
    public void testNumeric() {

        // Test Zero
        PojoBean numberBean = new PojoBean(0, -50);
        doParse("(intValue1 == 0)", numberBean, 0, "intValue1", true);
        doParse("(intValue2 != 0)", numberBean, 0, "intValue2", true);
        doParse("(integerValue1 == 0)", numberBean, 0, "integerValue1", true);
        doParse("(integerValue2 != 0)", numberBean, 0, "integerValue2", true);

        // int
        doParse("(intValue1 == 123)", testBean , 0, "intValue1", true);

        // Integer
        doParse("(integerValue1 == 123)", testBean , 0, "integerValue1", true);

        // Negative Numbers
        doParse("((intValue2 < -10)     and (intValue2 > -60))", numberBean, 0, "intValue2", true);
        doParse("((integerValue2 < -10) and (integerValue2 > -60))", numberBean, 0, "integerValue2", true);

        // Hex
        doParse("(integerValue1 == 0x7B)", testBean , 0, "integerValue1", true);

        // Octal
        doParse("(integerValue1 == 0173)", testBean , 0, "integerValue1", true);

        // Test 'String' numbers
        PojoBean stringBean = new PojoBean("11", "2");
        doParse("(stringValue1 > stringValue2)", stringBean , 0, "stringValue1", true);
        doParse("(stringValue1 < stringValue2)", stringBean , 0, "stringValue1", false);

    }
    
    /**
     * Test Null.
     */
    public void testNull() {

        // Not Null
        doParse("(*this* != null)", testBean , 0, "stringValue1", true);

        // Null
        doParse("(*this* == null)", testBean , 0, "stringValue2", true);


    }
    
    /**
     * Test Joined expressions ('and' or 'or')
     */
    public void testJoined() {

        // Join with 'or'
        doParse("((*this* == 'ABC') or (stringValue2 == null))", testBean , 0, "stringValue1", true);
        doParse("((*this* != 'ABC') or (stringValue2 == null))", testBean , 0, "stringValue1", true);
        doParse("((*this* == 'ABC') or (stringValue2 != null))", testBean , 0, "stringValue1", true);
        doParse("((*this* != 'ABC') or (stringValue2 != null))", testBean , 0, "stringValue1", false);

        // Join with 'and'
        doParse("((*this* == 'ABC') and (stringValue2 == null))", testBean , 0, "stringValue1", true);
        doParse("((*this* != 'ABC') and (stringValue2 == null))", testBean , 0, "stringValue1", false);
        doParse("((*this* == 'ABC') and (stringValue2 != null))", testBean , 0, "stringValue1", false);
        doParse("((*this* != 'ABC') and (stringValue2 != null))", testBean , 0, "stringValue1", false);

    }
    

    /**
     * Parse the expression and check that the expected result
     * (either true or false) occurs - fail if an exception is thrown
     * opr the wrong result occurs.
     *
     * @param test Test expression
     * @param bean Test Bean
     * @param index index value
     * @param property Bean property
     * @param expected Expected Result
     */
    private void doParse(String test, Object bean, int index, String property, boolean expected) {
        boolean result = false;
        try {
            result = doParse(test, bean, index, property);
        } catch (Exception ex) {
            log.error("Parsing " + test + " for property '"+property+"'", ex);
            fail("Parsing " + test + " threw " + ex);
        }
        if (expected) {
            assertTrue(test + " didn't return TRUE for " + property, result);
        } else {
            assertFalse(test + " didn't return FALSE for " + property, result);
        }
    }

    /**
     * Parse the expression and check that an Exception is throw.
     * Failes if no expection is thrown.
     *
     * @param test Test expression
     * @param bean Test Bean
     * @param index index value
     * @param property Bean property
     */
    private void doParseFail(String test, Object bean, int index, String property) {

        try {
            boolean result = doParse(test, bean, index, property);
            fail("Parsing " + test + " didn't throw exception as expected " + result);
        } catch (Exception expected) {
            // ignore exception - expected result
        }
    }

    /**
     * Parse the expression returning the result
     *
     * @param test Test expression
     * @param bean Test Bean
     * @param index index value
     * @param property Bean property
     */
    private boolean doParse(String test, Object bean, int index, String property) throws Exception {

        if (bean == null) {
            throw new NullPointerException("Bean is null for property '"+property+"'"); 
        }

        String value = String.class.isInstance(bean) 
                            ? (String)bean 
                            : ValidatorUtils.getValueAsString(bean, property);

        ValidWhenLexer lexer = new ValidWhenLexer(new StringReader(test));

        ValidWhenParser parser = new ValidWhenParser(lexer);
        parser.setForm(bean);
        parser.setIndex(index);
        parser.setValue(value);

        parser.expression();
        return parser.getResult();

    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级xxx| 日韩黄色免费电影| 一级特黄大欧美久久久| 亚洲成国产人片在线观看| 美女网站视频久久| 国产揄拍国内精品对白| eeuss影院一区二区三区 | 亚洲日本一区二区| 日韩av中文在线观看| 国产麻豆9l精品三级站| 99国内精品久久| 51精品秘密在线观看| 久久久久久久电影| 亚洲乱码中文字幕| 久久国产精品99久久久久久老狼| 国产精品18久久久久久久久久久久| 91丨九色丨尤物| 日韩午夜av一区| 中文字幕在线播放不卡一区| 午夜精品福利一区二区三区av| 国产一区不卡视频| 欧美在线一二三| 久久先锋影音av| 亚洲二区视频在线| 粉嫩av一区二区三区在线播放| 欧美专区在线观看一区| 26uuu国产电影一区二区| 亚洲乱码国产乱码精品精小说| 美女被吸乳得到大胸91| 色欧美片视频在线观看在线视频| 日韩午夜中文字幕| 亚洲激情图片一区| 国产精品69毛片高清亚洲| 欧美精品日韩综合在线| 国产精品人人做人人爽人人添| 日本欧美加勒比视频| 99re在线精品| 久久九九久精品国产免费直播| 亚洲高清久久久| 99久久精品99国产精品| 精品国产91久久久久久久妲己| 亚洲图片欧美一区| 91免费在线视频观看| 欧美刺激午夜性久久久久久久| 亚洲在线观看免费视频| 丰满白嫩尤物一区二区| 日韩精品在线网站| 午夜国产精品影院在线观看| 色综合天天综合网天天看片| 久久精品人人做人人爽人人| 奇米777欧美一区二区| 色噜噜狠狠成人网p站| 国产精品国产精品国产专区不蜜 | 日韩欧美成人一区| 亚洲一区二区精品3399| 成人黄色综合网站| 精品处破学生在线二十三| 午夜精品123| 91行情网站电视在线观看高清版| 日本一区二区免费在线观看视频| 麻豆国产精品官网| 91麻豆精品国产91久久久使用方法 | 中文字幕人成不卡一区| 国产成人三级在线观看| 久久综合九色欧美综合狠狠 | 欧美一二区视频| 亚洲电影第三页| 欧美午夜精品免费| 亚洲狠狠丁香婷婷综合久久久| 99久久99久久精品免费看蜜桃| 久久久久成人黄色影片| 国产成人在线视频免费播放| 精品国偷自产国产一区| 老司机午夜精品| 精品久久久久一区| 激情久久久久久久久久久久久久久久| 日韩一区二区麻豆国产| 日韩1区2区日韩1区2区| 日韩你懂的电影在线观看| 奇米色一区二区| 精品国产乱子伦一区| 久久99精品久久久| 久久精品欧美一区二区三区不卡 | 精品免费一区二区三区| 日韩电影在线一区| 日韩欧美中文字幕精品| 精品中文字幕一区二区小辣椒| 欧美不卡在线视频| 国产一区二区按摩在线观看| 久久精品视频网| 99精品欧美一区| 亚洲专区一二三| 在线成人免费观看| 激情深爱一区二区| 国产精品久久久久久久第一福利 | 午夜精品久久久久影视| 91精品久久久久久久久99蜜臂| 蜜臀av在线播放一区二区三区| 日韩丝袜情趣美女图片| 激情综合亚洲精品| 国产精品久久一卡二卡| 色老汉一区二区三区| 三级久久三级久久久| 欧美精品一区二区三区在线播放 | 久久精品欧美一区二区三区不卡| 成人免费视频caoporn| 亚洲另类一区二区| 7777精品伊人久久久大香线蕉最新版 | 成人黄色在线视频| 亚洲福利视频三区| 精品国产乱码久久久久久久久 | 亚洲国产精品成人综合| 91香蕉视频黄| 日韩精品一卡二卡三卡四卡无卡| 精品国产三级a在线观看| 成人午夜视频网站| 亚洲成a人片在线观看中文| 精品国产乱码久久久久久闺蜜| av一二三不卡影片| 日韩二区在线观看| 国产精品色呦呦| 7777精品伊人久久久大香线蕉最新版| 国产精品资源在线| 亚洲一二三四区| 久久综合色婷婷| 色婷婷久久久亚洲一区二区三区| 日本不卡视频在线| 国产精品久久久久久久久果冻传媒| 欧美日韩亚洲综合| 国产 欧美在线| 三级在线观看一区二区| 中文av一区特黄| 日韩一区二区免费电影| 99精品视频一区| 国产乱一区二区| 午夜国产不卡在线观看视频| 欧美极品美女视频| 日韩亚洲欧美在线观看| 色999日韩国产欧美一区二区| 久久 天天综合| 亚洲一二三四区不卡| 国产欧美日韩视频在线观看| 欧美日韩国产一级片| av一区二区三区四区| 激情五月婷婷综合| 五月婷婷欧美视频| 中文字幕日韩欧美一区二区三区| 欧美成人三级在线| 欧美日韩精品一区二区三区 | 亚洲视频香蕉人妖| 国产亚洲人成网站| 欧美一区二区三区免费| 色嗨嗨av一区二区三区| 成人美女视频在线观看| 精品亚洲aⅴ乱码一区二区三区| 亚洲国产成人高清精品| 国产精品久99| 国产性做久久久久久| 欧美日韩精品久久久| 91影视在线播放| 粉嫩蜜臀av国产精品网站| 久久91精品久久久久久秒播| 亚洲图片欧美视频| 一区二区三区在线视频免费| 国产日产欧产精品推荐色| 精品国产乱码久久久久久老虎| 6080国产精品一区二区| 欧美视频一区二区在线观看| 9色porny自拍视频一区二区| 国产高清一区日本| 久久激情综合网| 美女mm1313爽爽久久久蜜臀| 天天色 色综合| 亚洲午夜免费电影| 艳妇臀荡乳欲伦亚洲一区| 日韩高清在线电影| 亚洲韩国精品一区| 亚洲成人激情综合网| 一区二区三区**美女毛片| 成人免费视频在线观看| 国产精品狼人久久影院观看方式| 欧美激情一区二区三区在线| 久久人人97超碰com| 精品福利av导航| 26uuu精品一区二区在线观看| 精品国产一区二区在线观看| 欧美一二三区在线观看| 日韩欧美卡一卡二| 91精品国产乱码久久蜜臀| 精品视频1区2区| 欧美日韩视频在线观看一区二区三区 | 欧美久久久久久久久中文字幕| 欧洲生活片亚洲生活在线观看| 在线观看亚洲一区| 欧美制服丝袜第一页| 欧美猛男男办公室激情| 欧美二区在线观看| 日韩色在线观看| 精品国产乱码久久久久久1区2区 | 韩国成人精品a∨在线观看|