content: /*
   * Copyright 1999-2018 Alibaba Group Holding Ltd.
   *
   * 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 com.alibaba.druid.bvt.proxy.filter;
  
  import com.alibaba.druid.pool.DruidDataSource;
  import com.alibaba.druid.stat.DruidDataSourceStatManager;
  import junit.framework.TestCase;
  
  import java.sql.*;
  
  public class ClobTest extends TestCase {
      protected int dataSourceListSize;
  
      protected void setUp() throws Exception {
          dataSourceListSize = DruidDataSourceStatManager.getInstance().getDataSourceList().size();
      }
  
      protected void tearDown() throws Exception {
          assertEquals(dataSourceListSize, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
      }
  
      public void test_clob() throws Exception {
          DruidDataSource dataSource = new DruidDataSource();
          dataSource.setFilters("stat");
          dataSource.setUrl("jdbc:mock:");
  
          Connection conn = dataSource.getConnection();
          Statement stmt = conn.createStatement();
          ResultSet rs = stmt.executeQuery("SELECT NULL");
  
          assertTrue(rs.next());
  
          {
              Clob x = rs.getClob(1);
              assertNull(x);
          }
  
          {
              NClob x = rs.getNClob(1);
              assertNull(x);
          }
  
          {
              Blob x = rs.getBlob(1);
              assertNull(x);
          }
  
          {
              SQLXML x = rs.getSQLXML(1);
              assertNull(x);
          }
  
          {
              String x = rs.getString(1);
              assertNull(x);
          }
  
          assertNull(rs.getRowId(1));
          assertNull(rs.getBigDecimal(1));
          assertNull(rs.getObject(1));
  
          rs.close();
          stmt.close();
          conn.close();
  
          dataSource.close();
      }
  }
  