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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dynarowsettestcase.java

?? 這是一個有關common beanutils 的源碼
?? JAVA
字號:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.commons.beanutils;


import java.math.BigDecimal;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.List;

import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;


/**
 * Test accessing RowSets via DynaBeans.
 *
 * @author Craig R. McClanahan
 * @version $Revision: 556233 $ $Date: 2007-07-14 07:37:06 +0100 (Sat, 14 Jul 2007) $
 */

public class DynaRowSetTestCase extends TestCase {


    // ----------------------------------------------------- Instance Variables


    /**
     * The mock result set DynaClass to be tested.
     */
    protected RowSetDynaClass dynaClass = null;


    /**
     * Names of the columns for this test.  Must match the order they are
     * defined in {@link TestResultSetMetaData}, and must be all lower case.
     */
    protected String columns[] =
    { "bigdecimalproperty", "booleanproperty",
      "byteproperty", "dateproperty",
      "doubleproperty", "floatproperty",
      "intproperty", "longproperty",
      "nullproperty", "shortproperty",
      "stringproperty", "timeproperty",
      "timestampproperty" };


    // ----------------------------------------------------------- Constructors


    /**
     * Construct a new instance of this test case.
     *
     * @param name Name of the test case
     */
    public DynaRowSetTestCase(String name) {

        super(name);

    }


    // --------------------------------------------------- Overall Test Methods


    /**
     * Set up instance variables required by this test case.
     */
    public void setUp() throws Exception {

        dynaClass = new RowSetDynaClass(TestResultSet.createProxy());

    }


    /**
     * Return the tests included in this test suite.
     */
    public static Test suite() {

        return (new TestSuite(DynaRowSetTestCase.class));

    }


    /**
     * Tear down instance variables required by this test case.
     */
    public void tearDown() {

        dynaClass = null;

    }



    // ------------------------------------------------ Individual Test Methods


    public void testGetName() {

        assertEquals("DynaClass name",
                     "org.apache.commons.beanutils.RowSetDynaClass",
                     dynaClass.getName());


    }


    public void testGetDynaProperty() {

        // Invalid argument test
        try {
            dynaClass.getDynaProperty(null);
            fail("Did not throw IllegaArgumentException");
        } catch (IllegalArgumentException e) {
            // Expected result
        }

        // Negative test
        DynaProperty dynaProp = dynaClass.getDynaProperty("unknownProperty");
        assertTrue("unknown property returns null",
                   (dynaProp == null));

        // Positive test
        dynaProp = dynaClass.getDynaProperty("stringproperty");
        assertNotNull("string property exists", dynaProp);
        assertEquals("string property name", "stringproperty",
                     dynaProp.getName());
        assertEquals("string property class", String.class,
                     dynaProp.getType());

    }


    public void testGetDynaProperties() {

        DynaProperty dynaProps[] = dynaClass.getDynaProperties();
        assertNotNull("dynaProps exists", dynaProps);
        assertEquals("dynaProps length", columns.length, dynaProps.length);
        for (int i = 0; i < columns.length; i++) {
            assertEquals("Property " + columns[i],
                         columns[i], dynaProps[i].getName());
        }

    }


    public void testNewInstance() {

        try {
            dynaClass.newInstance();
            fail("Did not throw UnsupportedOperationException()");
        } catch (UnsupportedOperationException e) {
            // Expected result
        } catch (Exception e) {
            fail("Threw exception " + e);
        }

    }


    public void testListCount() {

        List rows = dynaClass.getRows();
        assertNotNull("list exists", rows);
        assertEquals("list row count", 5, rows.size());

    }


    public void testListResults() {

        // Grab the third row
        List rows = dynaClass.getRows();
        DynaBean row = (DynaBean) rows.get(2);

        // Invalid argument test
        try {
            row.get("unknownProperty");
            fail("Did not throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // Expected result
        }

        // Verify property values

        Object bigDecimalProperty = row.get("bigdecimalproperty");
        assertNotNull("bigDecimalProperty exists", bigDecimalProperty);
        assertTrue("bigDecimalProperty type",
                   bigDecimalProperty instanceof BigDecimal);
        assertEquals("bigDecimalProperty value",
                     123.45,
                     ((BigDecimal) bigDecimalProperty).doubleValue(),
                     0.005);

        Object intProperty = row.get("intproperty");
        assertNotNull("intProperty exists", intProperty);
        assertTrue("intProperty type",
                   intProperty instanceof Integer);
        assertEquals("intProperty value",
                     103,
                     ((Integer) intProperty).intValue());

        Object nullProperty = row.get("nullproperty");
        assertNull("nullProperty null", nullProperty);

        Object stringProperty = row.get("stringproperty");
        assertNotNull("stringProperty exists", stringProperty);
        assertTrue("stringProperty type",
                   stringProperty instanceof String);
        assertEquals("stringProperty value",
                     "This is a string",
                     (String) stringProperty);


    }

    /**
     * Test normal case column names (i.e. not converted to lower case)
     */
    public void testListResultsNormalCase() {
        RowSetDynaClass dynaClass = null;
        try {
            dynaClass = new RowSetDynaClass(TestResultSet.createProxy(), false);
        } catch (Exception e) {
            fail("Error creating RowSetDynaClass: " + e);
        }

        // Grab the third row
        List rows = dynaClass.getRows();
        DynaBean row = (DynaBean) rows.get(2);

        // Invalid argument test
        try {
            row.get("unknownProperty");
            fail("Did not throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // Expected result
        }

        // Verify property values

        Object bigDecimalProperty = row.get("bigDecimalProperty");
        assertNotNull("bigDecimalProperty exists", bigDecimalProperty);
        assertTrue("bigDecimalProperty type",
                   bigDecimalProperty instanceof BigDecimal);
        assertEquals("bigDecimalProperty value",
                     123.45,
                     ((BigDecimal) bigDecimalProperty).doubleValue(),
                     0.005);

        Object intProperty = row.get("intProperty");
        assertNotNull("intProperty exists", intProperty);
        assertTrue("intProperty type",
                   intProperty instanceof Integer);
        assertEquals("intProperty value",
                     103,
                     ((Integer) intProperty).intValue());

        Object nullProperty = row.get("nullProperty");
        assertNull("nullProperty null", nullProperty);

        Object stringProperty = row.get("stringProperty");
        assertNotNull("stringProperty exists", stringProperty);
        assertTrue("stringProperty type",
                   stringProperty instanceof String);
        assertEquals("stringProperty value",
                     "This is a string",
                     (String) stringProperty);


    }

    public void testLimitedRows() throws Exception {
        
        // created one with low limit
        RowSetDynaClass limitedDynaClass = new RowSetDynaClass(TestResultSet.createProxy(), 3);
        List rows = limitedDynaClass.getRows();
        assertNotNull("list exists", rows);
        assertEquals("limited row count", 3, rows.size());
        
    }

    /**
     * Test issues associated with Oracle JDBC driver.
     * 
     * See issue# https://issues.apache.org/jira/browse/BEANUTILS-142
     * 
     * @throws Exception if an error occurs
     */
    public void testInconsistentOracleDriver() throws Exception {

        ResultSetMetaData metaData = TestResultSetMetaData.createProxy(new TestResultSetMetaDataInconsistent());
        ResultSet resultSet = TestResultSet.createProxy(new TestResultSetInconsistent(metaData));

        // Date Column returns "java.sql.Timestamp" for the column class name but ResultSet getObject
        // returns a java.sql.Date value
        int dateColIdx = 4;
        assertEquals("Date Meta Name",       "dateProperty",       metaData.getColumnName(dateColIdx));
        assertEquals("Date Meta Class",      "java.sql.Timestamp", metaData.getColumnClassName(dateColIdx));
        assertEquals("Date Meta Type",       java.sql.Types.DATE,  metaData.getColumnType(dateColIdx));
        assertEquals("Date ResultSet Value", java.sql.Date.class,  resultSet.getObject("dateProperty").getClass());

        // Timestamp column class returns a custom Timestamp impl for the column class name and ResultSet getObject
        int timestampColIdx = 13;
        assertEquals("Timestamp Meta Name",       "timestampProperty",             metaData.getColumnName(timestampColIdx));
        assertEquals("Timestamp Meta Class",      CustomTimestamp.class.getName(), metaData.getColumnClassName(timestampColIdx));
        assertEquals("Timestamp Meta Type",       java.sql.Types.TIMESTAMP,        metaData.getColumnType(timestampColIdx));
        assertEquals("Timestamp ResultSet Value", CustomTimestamp.class,           resultSet.getObject("timestampProperty").getClass());

        RowSetDynaClass inconsistentDynaClass = new RowSetDynaClass(resultSet);
        DynaBean firstRow = (DynaBean)inconsistentDynaClass.getRows().get(0);
        Class expectedType = null;
        DynaProperty property = null;
        
        // Test Date
        property = firstRow.getDynaClass().getDynaProperty("dateproperty");
        expectedType = java.sql.Date.class;
        assertEquals("Date Class", expectedType, property.getType());
        assertEquals("Date Value", expectedType, firstRow.get(property.getName()).getClass());

        // Test Timestamp
        property = firstRow.getDynaClass().getDynaProperty("timestampproperty");
        expectedType = java.sql.Timestamp.class;
        assertEquals("Timestamp Class", expectedType, property.getType());
        assertEquals("Timestamp Value", expectedType, firstRow.get(property.getName()).getClass());
    }

    /**
     * A proxy ResultSet implementation that returns Timstamp for a date column.
     *
     * See issue# https://issues.apache.org/jira/browse/BEANUTILS-142 
     */
    private static class TestResultSetInconsistent extends  TestResultSet {

        public TestResultSetInconsistent(ResultSetMetaData metaData) {
            super(metaData);
        }
        /**
         * Get an columns's value
         * @param columnName Name of the column
         * @return the column value
         * @throws SQLException if an error occurs
         */
        public Object getObject(String columnName) throws SQLException {
            if ("timestampProperty".equals(columnName)) {
                return new CustomTimestamp();
            } else {
                return super.getObject(columnName);
            }
        }

    }

    /**
     * A proxy ResultSetMetaData implementation that returns a class name that
     * is inconsistent with the type returned by the ResultSet.getObject() method.
     *
     * See issue# https://issues.apache.org/jira/browse/BEANUTILS-142 
     */
    private static class TestResultSetMetaDataInconsistent extends  TestResultSetMetaData {

        /**
         * This method substitues class names of "java.sql.Timestamp" with
         * "java.sql.Date" to test inconsistent JDBC drivers.
         *
         * @param columnIndex The column index
         * @return The column class name
         * @throws SQLException if an error occurs
         */
        public String getColumnClassName(int columnIndex) throws SQLException {
            String columnName = getColumnName(columnIndex);
            if (columnName.equals("dateProperty")) {
                return java.sql.Timestamp.class.getName();
            } else if (columnName.equals("timestampProperty")) {
                return CustomTimestamp.class.getName();
            } else {
                return super.getColumnClassName(columnIndex);
            }
        }
    }
    private static class CustomTimestamp {
        private long timestamp = new java.util.Date().getTime();
        public String toString() {
            return "CustomTimestamp[" + timestamp + "]";
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久久久99999| 欧美激情一区二区三区四区| 欧美日韩日日骚| 97精品超碰一区二区三区| 欧美在线观看禁18| 欧美成人aa大片| 最新国产の精品合集bt伙计| 午夜视频一区在线观看| 国产一区免费电影| 欧美日韩国产高清一区二区 | 欧美夫妻性生活| 久久五月婷婷丁香社区| 亚洲欧美视频在线观看| 久久成人久久鬼色| 色综合天天天天做夜夜夜夜做| 91精品国产麻豆| 欧美精品一区男女天堂| 欧美极品美女视频| 免费看黄色91| 91久久国产综合久久| 精品美女被调教视频大全网站| 欧美激情中文字幕一区二区| 婷婷国产v国产偷v亚洲高清| 99久久精品国产麻豆演员表| 欧美大片在线观看一区| 亚洲精品成人精品456| 国产高清亚洲一区| 精品欧美黑人一区二区三区| 亚洲五月六月丁香激情| 成人免费黄色在线| 久久无码av三级| 久久99国产精品麻豆| 欧美性受xxxx黑人xyx性爽| 国产精品成人网| 国产成人丝袜美腿| 久久久777精品电影网影网 | 欧美本精品男人aⅴ天堂| 亚洲一区二区三区免费视频| 成人小视频在线| 国产欧美中文在线| 国产精品一卡二卡在线观看| 欧美tickling网站挠脚心| 日韩经典一区二区| 3d成人动漫网站| 丝袜亚洲精品中文字幕一区| 欧美亚洲高清一区| 亚洲福利一二三区| 91福利在线观看| 亚洲国产一区视频| 在线一区二区视频| 亚洲美女偷拍久久| 欧美亚洲一区二区三区四区| 亚洲最新视频在线观看| 91福利视频在线| 调教+趴+乳夹+国产+精品| 欧美日韩三级一区二区| 日本三级亚洲精品| 日韩免费观看高清完整版| 国产一区二区女| 国产欧美精品区一区二区三区 | 欧美一区中文字幕| 日韩av电影天堂| 欧美变态凌虐bdsm| 国产成人一区在线| 中文字幕一区二区三区蜜月| 99久久国产综合精品色伊 | 东方aⅴ免费观看久久av| 欧美一级高清片| 久久成人精品无人区| 91女人视频在线观看| 亚洲精选免费视频| 欧美久久久久中文字幕| 国内精品第一页| 最新欧美精品一区二区三区| 欧美伊人精品成人久久综合97| 日本欧美一区二区三区| 久久综合视频网| 大陆成人av片| 视频一区视频二区在线观看| 欧美成人video| 色哟哟亚洲精品| 精品无码三级在线观看视频 | 色噜噜狠狠色综合欧洲selulu| 亚洲图片欧美色图| 精品日韩在线观看| 国产裸体歌舞团一区二区| 亚洲视频在线观看一区| 欧美精品v国产精品v日韩精品 | 一区二区日韩av| 日韩免费视频一区| 色综合视频在线观看| 欧美bbbbb| 综合色中文字幕| 久久网站最新地址| 欧美另类一区二区三区| 国产成人鲁色资源国产91色综| 亚洲国产成人av| 国产精品久久久久久久久快鸭| 色婷婷综合久久久久中文 | 中文字幕一区二区三区蜜月| 日韩一区二区免费在线观看| 99视频精品免费视频| 亚洲成a人片在线不卡一二三区| 91麻豆.com| 国产成人在线看| 美女视频黄频大全不卡视频在线播放 | 一区二区三区免费观看| 久久久精品影视| 欧美精选一区二区| av在线不卡观看免费观看| 亚洲线精品一区二区三区八戒| 国产午夜精品一区二区三区嫩草| 欧美日韩国产一级二级| 91在线码无精品| 日韩一卡二卡三卡国产欧美| 99久久777色| 国产成人亚洲综合色影视| 久久99国产精品成人| 婷婷综合在线观看| 亚洲综合成人在线| 国产亚洲精品7777| 欧美探花视频资源| 在线免费一区三区| 色综合天天天天做夜夜夜夜做| 成人午夜视频网站| 国产精品亚洲专一区二区三区 | 亚洲福利一二三区| 一区二区三区四区中文字幕| 国产精品久久久久一区二区三区| 欧美日韩国产一级二级| 欧美日韩一区三区四区| 欧洲亚洲精品在线| 欧美日韩亚洲另类| 欧美日韩一区三区四区| 欧美色精品在线视频| 欧美在线观看一区二区| 在线观看日韩电影| 欧美亚洲国产bt| 91麻豆精品久久久久蜜臀| 欧美日韩综合在线| 97超碰欧美中文字幕| 国产精品一区二区x88av| 日本亚洲一区二区| 久久国产尿小便嘘嘘| 国内成+人亚洲+欧美+综合在线| 精品中文字幕一区二区| 国内欧美视频一区二区| 丁香婷婷综合激情五月色| 国产成人精品免费网站| 成人黄色777网| 91亚洲精品一区二区乱码| 欧美精品一区二| 精品欧美久久久| 国产精品无人区| 一区二区三区精品| 麻豆91在线播放免费| 国产精品一区久久久久| www.日韩av| 精品污污网站免费看| 日韩精品专区在线影院重磅| 精品女同一区二区| 欧美浪妇xxxx高跟鞋交| 91精品国产乱| 中文字幕佐山爱一区二区免费| 免费的国产精品| 一本大道久久精品懂色aⅴ| 久久日一线二线三线suv| 一区二区在线观看视频| 国产精品一区二区不卡| 日韩欧美自拍偷拍| 亚洲一区二区在线视频| 成人精品免费视频| 欧美一区二区成人| 夜夜嗨av一区二区三区四季av| 国产馆精品极品| 精品国产乱子伦一区| 亚洲一区二区视频在线观看| 成人av中文字幕| 欧美精品一区二区三区蜜桃| 亚洲一区在线免费观看| 成人动漫一区二区| 久久久久久97三级| 精品影视av免费| 欧美一区二视频| 香蕉成人啪国产精品视频综合网| 成人国产一区二区三区精品| 精品国产亚洲一区二区三区在线观看| 亚洲乱码日产精品bd| 国产成人亚洲综合a∨婷婷| 欧美不卡激情三级在线观看| 视频一区视频二区中文| 欧美日韩色一区| 午夜精品久久久久影视| 91麻豆精品一区二区三区| 亚洲视频图片小说| www.成人在线| 亚洲三级电影网站| 色先锋资源久久综合| 一区二区三区.www| 欧美日韩精品一区视频|