Skip to content

Commit

Permalink
test: avoid modifying global sendBufferSize and receiveBufferSize in …
Browse files Browse the repository at this point in the history
…SendRecvBufferSizeTest
  • Loading branch information
vlsi committed Jun 1, 2022
1 parent ee9c603 commit 82dbbe4
Showing 1 changed file with 16 additions and 14 deletions.
Expand Up @@ -5,45 +5,47 @@

package org.postgresql.test.jdbc3;

import org.postgresql.PGProperty;
import org.postgresql.test.TestUtil;
import org.postgresql.test.jdbc2.BaseTest4;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class SendRecvBufferSizeTest {
public class SendRecvBufferSizeTest extends BaseTest4 {

private Connection conn;
@Override
protected void updateProperties(Properties props) {
super.updateProperties(props);
PGProperty.SEND_BUFFER_SIZE.set(props, "1024");
PGProperty.RECEIVE_BUFFER_SIZE.set(props, "1024");
}

@Before
public void setUp() throws Exception {
System.setProperty("sendBufferSize", "1024");
System.setProperty("receiveBufferSize", "1024");

conn = TestUtil.openDB();
Statement stmt = conn.createStatement();
stmt.execute("CREATE TEMP TABLE hold(a int)");
super.setUp();
TestUtil.createTable(con, "hold", "a int");
Statement stmt = con.createStatement();
stmt.execute("INSERT INTO hold VALUES (1)");
stmt.execute("INSERT INTO hold VALUES (2)");
stmt.close();
}

@After
public void tearDown() throws SQLException {
Statement stmt = conn.createStatement();
stmt.execute("DROP TABLE hold");
stmt.close();
TestUtil.closeDB(conn);
TestUtil.dropTable(con, "hold");
super.tearDown();
}

// dummy test
@Test
public void testSelect() throws SQLException {
Statement stmt = conn.createStatement();
Statement stmt = con.createStatement();
stmt.execute("select * from hold");
stmt.close();
}
Expand Down

0 comments on commit 82dbbe4

Please sign in to comment.