예제 #1
0
  @Test
  public void testDisableLocalTransations() throws Exception {
    ServerConnection mock = Mockito.mock(ServerConnection.class);
    DQP dqp = Mockito.mock(DQP.class);
    Mockito.stub(mock.getService(DQP.class)).toReturn(dqp);
    ConnectionImpl conn = new ConnectionImpl(mock, new Properties(), "x");
    StatementImpl statement =
        new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    assertTrue(conn.getAutoCommit());
    statement.execute("set disablelocaltxn true");
    assertFalse(statement.execute("start transaction")); // $NON-NLS-1$
    conn.beginLocalTxnIfNeeded();
    assertFalse(conn.isInLocalTxn());

    statement.execute("set disablelocaltxn false");
    assertFalse(statement.execute("start transaction")); // $NON-NLS-1$
    conn.beginLocalTxnIfNeeded();
    assertTrue(conn.isInLocalTxn());
  }