/*
 Copyright (C) 2002-2004 MySQL AB

 This program is free software; you can redistribute it and/or modify
 it under the terms of version 2 of the GNU General Public License as 
 published by the Free Software Foundation.

 There are special exceptions to the terms and conditions of the GPL 
 as it is applied to this software. View the full text of the 
 exception in file EXCEPTIONS-CONNECTOR-J in the directory of this 
 software distribution.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



 */
//package testsuite.regression;

import testsuite.BaseTestCase;
import java.sql.DatabaseMetaData;

/**
 * Testcase for MySQL bug #22613
 * http://bugs.mysql.com/bug.php?id=22613
 * 
 * @author Kolbe Kegel
 */
public class BUG22613 extends BaseTestCase {

	/**
	 * 
	 */
	public BUG22613(String name) {
		super(name);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#setUp()
	 */
	public void setUp() throws Exception {
		// TODO Auto-generated method stub
		super.setUp();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#tearDown()
	 */
	public void tearDown() throws Exception {
		// TODO Auto-generated method stub
		super.tearDown();
	}

	/**
	 * Runs all test cases in this test suite
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		junit.textui.TestRunner.run(BUG22613.class);
	}

	/**
	 * DOCUMENT ME!
	 * 
	 * @throws Exception
	 *             DOCUMENT ME!
	 */
	 public void testBug22613() throws Exception {
		 String maxValue = "a,bc,def,ghij";
		 DatabaseMetaData meta = conn.getMetaData();
		 this.rs = meta.getColumns(null,"test","t1","s");
		 rs.first();
		 System.err.println("COLUMN_SIZE of "+rs.getString("COLUMN_SIZE")+" for max value of '"+maxValue+"'");
		 assertTrue(maxValue.length()==rs.getInt("COLUMN_SIZE"));
	 }

	private void createTables() throws Exception {
		this.stmt.executeUpdate("drop table if exists bug22613");
		this.stmt.executeUpdate("CREATE TABLE `bug22613` ( `s` set('a','bc','def','ghij') default NULL);");
	}

	private void dropTables() throws Exception {
		this.stmt.executeUpdate("drop table if exists bug22613");
	}
}
