Package org.teiid.jdbc

Examples of org.teiid.jdbc.CallableStatementImpl



public class TestCallableStatement extends TestCase {
 
  public void testWasNull() throws Exception {
    CallableStatementImpl mmcs = getCallableStatement();
   
    Map<Integer, Integer> params = new HashMap<Integer, Integer>();
    mmcs.outParamIndexMap = params;
    params.put(Integer.valueOf(1), Integer.valueOf(1));
    params.put(Integer.valueOf(2), Integer.valueOf(2));
    ResultSetImpl rs = Mockito.mock(ResultSetImpl.class);
    mmcs.resultSet = rs;
    Mockito.stub(rs.getOutputParamValue(1)).toReturn(null);
    Mockito.stub(rs.getOutputParamValue(2)).toReturn(Boolean.TRUE);
    mmcs.getBoolean(1);
    assertTrue(mmcs.wasNull());
    assertTrue(mmcs.getBoolean(2));
    assertFalse(mmcs.wasNull());
  }
View Full Code Here


    assertTrue(mmcs.getBoolean(2));
    assertFalse(mmcs.wasNull());
  }
 
  public void testGetOutputParameter() throws Exception {
    CallableStatementImpl mmcs = getCallableStatement();
   
    RequestMessage request = new RequestMessage();
    request.setExecutionId(1);
    ResultsMessage resultsMsg = new ResultsMessage(request);
    List[] results = new List[] {Arrays.asList(null, null, null), Arrays.asList(null, 1, 2)};
    resultsMsg.setResults(results);
    resultsMsg.setColumnNames(new String[] { "IntNum", "Out1", "Out2" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    resultsMsg.setDataTypes(new String[] { JDBCSQLTypeInfo.INTEGER, JDBCSQLTypeInfo.INTEGER, JDBCSQLTypeInfo.INTEGER });
    resultsMsg.setFinalRow(results.length);
    resultsMsg.setLastRow(results.length);
    resultsMsg.setFirstRow(1);
    resultsMsg.setParameters(Arrays.asList(new ParameterInfo(ParameterInfo.RESULT_SET, 1), new ParameterInfo(ParameterInfo.OUT, 1), new ParameterInfo(ParameterInfo.OUT, 1)));
    mmcs.createResultSet(resultsMsg);
    assertEquals(1, mmcs.getInt(1));
    assertEquals(2, mmcs.getInt(2));
  }
View Full Code Here

    assertEquals(1, mmcs.getInt(1));
    assertEquals(2, mmcs.getInt(2));
  }
 
  public void testUnknownIndex() throws Exception {
    CallableStatementImpl mmcs = getCallableStatement();
   
    mmcs.outParamIndexMap = new HashMap<Integer, Integer>();
   
    try {
      mmcs.getBoolean(0);
      fail("expected exception"); //$NON-NLS-1$
    } catch (IllegalArgumentException e) {
      assertEquals("Parameter is not found at index 0.", e.getMessage());
    }
  }
View Full Code Here

    ServerConnection sc = Mockito.mock(ServerConnection.class);
   
    Mockito.stub(sc.getLogonResult()).toReturn(new LogonResult());
    Mockito.stub(conn.getServerConnection()).toReturn(sc);
   
    CallableStatementImpl mmcs = new CallableStatementImpl(conn, "{?=call x(?)}", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    return mmcs;
  }
View Full Code Here

TOP

Related Classes of org.teiid.jdbc.CallableStatementImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.