MiscTest.java 1.57 KB
Newer Older
1 2 3 4 5 6
package org.postgresql.test.jdbc2;

import org.postgresql.test.JDBC2Tests;
import junit.framework.TestCase;
import java.sql.*;

7
/*
8
 * $Id: MiscTest.java,v 1.5 2002/05/30 16:26:55 davec Exp $
9 10 11 12 13
 *
 * Some simple tests based on problems reported by users. Hopefully these will
 * help prevent previous problems from re-occuring ;-)
 *
 */
14 15 16 17 18 19 20 21
public class MiscTest extends TestCase
{

	public MiscTest(String name)
	{
		super(name);
	}

22
	/*
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
	 * Some versions of the driver would return rs as a null?
	 *
	 * Sasha <ber0806@iperbole.bologna.it> was having this problem.
	 *
	 * Added Feb 13 2001
	 */
	public void testDatabaseSelectNullBug()
	{
		try
		{
			Connection con = JDBC2Tests.openDB();

			Statement st = con.createStatement();
			ResultSet rs = st.executeQuery("select datname from pg_database");
			assertNotNull(rs);

			while (rs.next())
			{
				String s = rs.getString(1);
			}

			rs.close();
			st.close();

			JDBC2Tests.closeDB(con);
		}
		catch (Exception ex)
		{
			fail(ex.getMessage());
		}
	}
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

	public void xtestLocking()
	{

		System.out.println("testing lock");
		try
		{
			Connection con = JDBC2Tests.openDB();
			Connection con2 = JDBC2Tests.openDB();

			JDBC2Tests.createTable(con, "test_lock", "name text");
			Statement st = con.createStatement();
			Statement st2 = con2.createStatement();
			con.setAutoCommit(false);
			st.execute("lock table test_lock");
			st2.executeUpdate( "insert into test_lock ( name ) values ('hello')" );
 			con.commit();
			JDBC2Tests.dropTable(con, "test_lock");
			con.close();
		}
		catch ( Exception ex )
		{
			fail( ex.getMessage() );
		}
	}
79
}