Permalink
Browse files

test: add tests for getBigDecimal of int4 field in both text and bina…

…ry modes
  • Loading branch information...
vlsi committed Nov 13, 2015
1 parent 6eaedec commit faac28818c222f5f873074d18935c10810c7e470
@@ -0,0 +1,18 @@
package org.postgresql.test;
import java.util.Properties;
import org.postgresql.test.jdbc2.CursorFetchTest;
public class CursorFetchBinaryTest extends CursorFetchTest {
public CursorFetchBinaryTest(String name)
{
super(name);
}
@Override
protected void updateProperties(Properties props)
{
forceBinary(props);
}
}
@@ -0,0 +1,48 @@
package org.postgresql.test.jdbc2;
import junit.framework.TestCase;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import org.postgresql.PGProperty;
import org.postgresql.test.TestUtil;
public class BaseTest extends TestCase {
protected Connection con;
public BaseTest(String name)
{
super(name);
try
{
new org.postgresql.Driver();
}
catch (Exception ex)
{
/* ignore */
}
}
protected void updateProperties(Properties props) {
}
protected void forceBinary(Properties props)
{
PGProperty.PREPARE_THRESHOLD.set(props, -1);
}
protected void setUp() throws Exception
{
Properties props = new Properties();
updateProperties(props);
con = TestUtil.openDB(props);
}
protected void tearDown() throws SQLException
{
TestUtil.closeDB(con);
}
}
@@ -0,0 +1,16 @@
package org.postgresql.test.jdbc2;
import java.util.Properties;
public class BatchExecuteBinaryTest extends BatchExecuteTest {
public BatchExecuteBinaryTest(String name)
{
super(name);
}
@Override
protected void updateProperties(Properties props)
{
forceBinary(props);
}
}
@@ -7,18 +7,14 @@
*/
package org.postgresql.test.jdbc2;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.BatchUpdateException;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
import org.postgresql.test.TestUtil;
import org.postgresql.util.PSQLException;
import junit.framework.TestCase;
import java.sql.*;
/* TODO tests that can be added to this test case
* - SQLExceptions chained to a BatchUpdateException
@@ -28,26 +24,19 @@
/*
* Test case for Statement.batchExecute()
*/
public class BatchExecuteTest extends TestCase
public class BatchExecuteTest extends BaseTest
{
private Connection con;
public BatchExecuteTest(String name)
{
super(name);
try
{
Class.forName("org.postgresql.Driver");
}
catch( Exception ex){}
}
// Set up the fixture for this testcase: a connection to a database with
// a table for this test.
protected void setUp() throws Exception
{
con = TestUtil.openDB();
super.setUp();
Statement stmt = con.createStatement();
// Drop the test table if it already exists for some reason. It is
@@ -65,12 +54,12 @@ protected void setUp() throws Exception
}
// Tear down the fixture for this test case.
protected void tearDown() throws Exception
protected void tearDown() throws SQLException
{
con.setAutoCommit(true);
TestUtil.dropTable(con, "testbatch");
TestUtil.closeDB(con);
super.tearDown();
}
public void testSupportsBatchUpdates() throws Exception
@@ -9,37 +9,33 @@
import java.sql.*;
import junit.framework.TestCase;
import org.postgresql.test.TestUtil;
/*
* Tests for using non-zero setFetchSize().
*/
public class CursorFetchTest extends TestCase
public class CursorFetchTest extends BaseTest
{
private Connection con;
public CursorFetchTest(String name)
{
super(name);
}
protected void setUp() throws Exception
{
con = TestUtil.openDB();
super.setUp();
TestUtil.createTable(con, "test_fetch", "value integer");
con.setAutoCommit(false);
}
protected void tearDown() throws Exception
protected void tearDown() throws SQLException
{
if (!con.getAutoCommit())
con.rollback();
con.setAutoCommit(true);
TestUtil.dropTable(con, "test_fetch");
TestUtil.closeDB(con);
super.tearDown();
}
protected void createRows(int count) throws Exception
@@ -11,6 +11,7 @@
import junit.framework.TestSuite;
import org.postgresql.test.CursorFetchBinaryTest;
import org.postgresql.test.TestUtil;
/*
@@ -64,13 +65,15 @@ public static TestSuite suite() throws Exception
// PreparedStatement
suite.addTestSuite(PreparedStatementTest.class);
suite.addTestSuite(PreparedStatementBinaryTest.class);
suite.addTestSuite(StatementTest.class);
// ServerSide Prepared Statements
suite.addTestSuite(ServerPreparedStmtTest.class);
// BatchExecute
suite.addTestSuite(BatchExecuteTest.class);
suite.addTestSuite(BatchExecuteBinaryTest.class);
// Other misc tests, based on previous problems users have had or specific
@@ -89,6 +92,7 @@ public static TestSuite suite() throws Exception
suite.addTestSuite(CallableStmtTest.class );
suite.addTestSuite(CursorFetchTest.class);
suite.addTestSuite(CursorFetchBinaryTest.class);
suite.addTestSuite(ServerCursorTest.class);
suite.addTestSuite(IntervalTest.class);
@@ -0,0 +1,16 @@
package org.postgresql.test.jdbc2;
import java.util.Properties;
public class PreparedStatementBinaryTest extends PreparedStatementTest {
public PreparedStatementBinaryTest(String name)
{
super(name);
}
@Override
protected void updateProperties(Properties props)
{
forceBinary(props);
}
}
Oops, something went wrong.

0 comments on commit faac288

Please sign in to comment.