gt:         int testIntFlag = toSerialize.getBlobSendChunkSize() + 1;
context: /*
    Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  
    The MySQL Connector/J is licensed under the terms of the GPLv2
    <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
    There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
    this software, see the FOSS License Exception
    <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
  
    This program is free software; you can redistribute it and/or modify it under the terms
    of the GNU General Public License as published by the Free Software Foundation; version 2
    of the License.
  
    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., 51 Franklin St, Fifth
    Floor, Boston, MA 02110-1301  USA
  
   */
  
  package testsuite.regression;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.lang.reflect.Method;
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.Hashtable;
  import java.util.concurrent.Callable;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.Name;
  import javax.naming.NameParser;
  import javax.naming.RefAddr;
  import javax.naming.Reference;
  import javax.naming.spi.ObjectFactory;
  import javax.sql.ConnectionPoolDataSource;
  import javax.sql.DataSource;
  import javax.sql.PooledConnection;
  import javax.sql.XAConnection;
  import javax.transaction.xa.XAException;
  import javax.transaction.xa.XAResource;
  import javax.transaction.xa.Xid;
  
  import com.mysql.jdbc.ConnectionProperties;
  import com.mysql.jdbc.MySQLConnection;
  import com.mysql.jdbc.NonRegisteringDriver;
  import com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker;
  import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
  import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
  import com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory;
  import com.mysql.jdbc.jdbc2.optional.MysqlXADataSource;
  import com.mysql.jdbc.jdbc2.optional.MysqlXid;
  
  import testsuite.BaseTestCase;
  import testsuite.simple.DataSourceTest;
  
  /**
   * Tests fixes for bugs related to datasources.
   */
  public class DataSourceRegressionTest extends BaseTestCase {
  
      public final static String DS_DATABASE_PROP_NAME = "com.mysql.jdbc.test.ds.db";
  
      public final static String DS_HOST_PROP_NAME = "com.mysql.jdbc.test.ds.host";
  
      public final static String DS_PASSWORD_PROP_NAME = "com.mysql.jdbc.test.ds.password";
  
      public final static String DS_PORT_PROP_NAME = "com.mysql.jdbc.test.ds.port";
  
      public final static String DS_USER_PROP_NAME = "com.mysql.jdbc.test.ds.user";
  
      private Context ctx;
  
      private File tempDir;
  
      /**
       * Creates a new DataSourceRegressionTest suite for the given test name
       * 
       * @param name
       *            the name of the testcase to run.
       */
      public DataSourceRegressionTest(String name) {
          super(name);
      }
  
      /**
       * Runs all test cases in this test suite
       * 
       * @param args
       */
      public static void main(String[] args) {
          junit.textui.TestRunner.run(DataSourceTest.class);
      }
  
      /**
       * Sets up this test, calling registerDataSource() to bind a DataSource into
       * JNDI, using the FSContext JNDI provider from Sun
       * 
       * @throws Exception
       *             if an error occurs.
       */
      @Override
      public void setUp() throws Exception {
          super.setUp();
          createJNDIContext();
      }
  
      /**
       * Un-binds the DataSource, and cleans up the filesystem
       * 
       * @throws Exception
       *             if an error occurs
       */
      @Override
      public void tearDown() throws Exception {
          this.ctx.unbind(this.tempDir.getAbsolutePath() + "/test");
          this.ctx.unbind(this.tempDir.getAbsolutePath() + "/testNoUrl");
          this.ctx.close();
          this.tempDir.delete();
  
          super.tearDown();
      }
  
      /**
       * Tests fix for BUG#4808- Calling .close() twice on a PooledConnection
       * causes NPE.
       * 
       * @throws Exception
       *             if an error occurs.
       */
      public void testBug4808() throws Exception {
          MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
          ds.setURL(BaseTestCase.dbUrl);
          PooledConnection closeMeTwice = ds.getPooledConnection();
          closeMeTwice.close();
          closeMeTwice.close();
  
      }
  
      /**
       * Tests fix for Bug#3848, port # alone parsed incorrectly
       * 
       * @throws Exception
       *             ...
       */
      public void testBug3848() throws Exception {
          String jndiName = "/testBug3848";
  
          String databaseName = System.getProperty(DS_DATABASE_PROP_NAME);
          String userName = System.getProperty(DS_USER_PROP_NAME);
          String password = System.getProperty(DS_PASSWORD_PROP_NAME);
          String port = System.getProperty(DS_PORT_PROP_NAME);
  
          // Only run this test if at least one of the above are set
          if ((databaseName != null) || (userName != null) || (password != null) || (port != null)) {
              MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
  
              if (databaseName != null) {
                  ds.setDatabaseName(databaseName);
              }
  
              if (userName != null) {
                  ds.setUser(userName);
              }
  
              if (password != null) {
                  ds.setPassword(password);
              }
  
              if (port != null) {
                  ds.setPortNumber(Integer.parseInt(port));
              }
  
              bindDataSource(jndiName, ds);
  
              ConnectionPoolDataSource boundDs = null;
  
              try {
                  boundDs = (ConnectionPoolDataSource) lookupDatasourceInJNDI(jndiName);
  
                  assertTrue("Datasource not bound", boundDs != null);
  
                  Connection dsConn = null;
  
                  try {
                      dsConn = boundDs.getPooledConnection().getConnection();
                  } finally {
                      if (dsConn != null) {
                          dsConn.close();
                      }
                  }
              } finally {
                  if (boundDs != null) {
                      this.ctx.unbind(jndiName);
                  }
              }
          }
      }
  
      /**
       * Tests that we can get a connection from the DataSource bound in JNDI
       * during test setup
       * 
       * @throws Exception
       *             if an error occurs
       */
      public void testBug3920() throws Exception {
          String jndiName = "/testBug3920";
  
          String databaseName = System.getProperty(DS_DATABASE_PROP_NAME);
          String userName = System.getProperty(DS_USER_PROP_NAME);
          String password = System.getProperty(DS_PASSWORD_PROP_NAME);
          String port = System.getProperty(DS_PORT_PROP_NAME);
          String serverName = System.getProperty(DS_HOST_PROP_NAME);
  
          // Only run this test if at least one of the above are set
          if ((databaseName != null) || (serverName != null) || (userName != null) || (password != null) || (port != null)) {
              MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
  
              if (databaseName != null) {
                  ds.setDatabaseName(databaseName);
              }
  
              if (userName != null) {
                  ds.setUser(userName);
              }
  
              if (password != null) {
                  ds.setPassword(password);
              }
  
              if (port != null) {
                  ds.setPortNumber(Integer.parseInt(port));
              }
  
              if (serverName != null) {
                  ds.setServerName(serverName);
              }
  
              bindDataSource(jndiName, ds);
  
              ConnectionPoolDataSource boundDs = null;
  
              try {
                  boundDs = (ConnectionPoolDataSource) lookupDatasourceInJNDI(jndiName);
  
                  assertTrue("Datasource not bound", boundDs != null);
  
                  Connection dsCon = null;
                  Statement dsStmt = null;
  
                  try {
                      dsCon = boundDs.getPooledConnection().getConnection();
                      dsStmt = dsCon.createStatement();
                      dsStmt.executeUpdate("DROP TABLE IF EXISTS testBug3920");
                      dsStmt.executeUpdate("CREATE TABLE testBug3920 (field1 varchar(32))");
  
                      assertTrue("Connection can not be obtained from data source", dsCon != null);
                  } finally {
                      if (dsStmt != null) {
                          dsStmt.executeUpdate("DROP TABLE IF EXISTS testBug3920");
  
                          dsStmt.close();
                      }
                      if (dsCon != null) {
                          dsCon.close();
                      }
                  }
              } finally {
                  if (boundDs != null) {
                      this.ctx.unbind(jndiName);
                  }
              }
          }
      }
  
      /**
       * Tests fix for BUG#19169 - ConnectionProperties (and thus some
       * subclasses) are not serializable, even though some J2EE containers
       * expect them to be.
       * 
       * @throws Exception
       *             if the test fails.
       */
      public void testBug19169() throws Exception {
          MysqlDataSource toSerialize = new MysqlDataSource();
          toSerialize.setZeroDateTimeBehavior("convertToNull");
  
          boolean testBooleanFlag = !toSerialize.getAllowLoadLocalInfile();
          toSerialize.setAllowLoadLocalInfile(testBooleanFlag);
  
  