Package org.teiid.client

Examples of org.teiid.client.DQP


        }
        }
      }
     
      this.csr.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
      DQP dqpProxy = proxyService(DQP.class, this.dqpCore, LogConstants.CTX_DQP);
      this.csr.registerClientService(DQP.class, dqpProxy, LogConstants.CTX_DQP);
      Admin adminProxy = proxyService(Admin.class, admin, LogConstants.CTX_ADMIN_API);
      this.csr.registerClientService(Admin.class, adminProxy, LogConstants.CTX_ADMIN_API);
     
      ClientServiceRegistryImpl jdbcCsr = new ClientServiceRegistryImpl();
View Full Code Here


      service.exceptionMethod();
      fail("exception expected"); //$NON-NLS-1$
    } catch (TeiidProcessingException e) {
     
    }
    DQP dqp = connection.getService(DQP.class);
    try {
      ResultsFuture<?> future = dqp.begin();
      future.get();
      fail("exception expected"); //$NON-NLS-1$
    } catch (Exception e) {
      assertTrue(e.getMessage().indexOf("Component not found:") != -1); //$NON-NLS-1$
    }
View Full Code Here

   * @throws Exception
   */
  @Test public void testBatchedUpdateExecution() throws Exception {
    // Build up a fake connection instance for use with the prepared statement
    ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
    DQP dqp = Mockito.mock(DQP.class);
    ServerConnection serverConn = Mockito.mock(ServerConnection.class);
    LogonResult logonResult = Mockito.mock(LogonResult.class);
   
    // stub methods
    Mockito.stub(conn.getServerConnection()).toReturn(serverConn);
    Mockito.stub(serverConn.getLogonResult()).toReturn(logonResult);
    Mockito.stub(logonResult.getTimeZone()).toReturn(TimeZone.getDefault());

    // a dummy result message that is specific to this test case
    ResultsFuture<ResultsMessage> results = new ResultsFuture<ResultsMessage>();
    Mockito.stub(dqp.executeRequest(Matchers.anyLong(), (RequestMessage)Matchers.anyObject())).toReturn(results);
    ResultsMessage rm = new ResultsMessage();
    rm.setResults(new List<?>[] {Arrays.asList(0), Arrays.asList(0), Arrays.asList(0)});
    rm.setUpdateResult(true);
    results.getResultsReceiver().receiveResults(rm);
    Mockito.stub(conn.getDQP()).toReturn(dqp);
View Full Code Here

    }
 
  static ResultSetImpl helpTestBatching(StatementImpl statement, int fetchSize, int batchLength,
      int totalLength) throws InterruptedException, ExecutionException,
      TeiidProcessingException, SQLException, TimeoutException {
    DQP dqp = statement.getDQP();
    if (dqp == null) {
      dqp = mock(DQP.class);
      stub(statement.getDQP()).toReturn(dqp);
    }
    stub(statement.getFetchSize()).toReturn(fetchSize);
    for (int i = batchLength; i < totalLength; i += batchLength) {
      //forward requests
      ResultsFuture<ResultsMessage> nextBatch = mock(ResultsFuture.class);
      stub(nextBatch.get(Matchers.anyLong(), (TimeUnit)Matchers.anyObject())).toReturn(exampleResultsMsg4(i + 1, Math.min(batchLength, totalLength - i), fetchSize, i + batchLength >= totalLength));
      stub(dqp.processCursorRequest(REQUEST_ID, i + 1, fetchSize)).toReturn(nextBatch);
     
      if (i + batchLength < totalLength) {
        //backward requests
        ResultsFuture<ResultsMessage> previousBatch = mock(ResultsFuture.class);
        stub(previousBatch.get(Matchers.anyLong(), (TimeUnit)Matchers.anyObject())).toReturn(exampleResultsMsg4(i - batchLength + 1, i, fetchSize, false));
        stub(dqp.processCursorRequest(REQUEST_ID, i, fetchSize)).toReturn(previousBatch);
      }
    }
   
    ResultsMessage msg = exampleResultsMsg4(1, batchLength, fetchSize, batchLength == totalLength);
    return new ResultSetImpl(msg, statement, new ResultSetMetaDataImpl(new MetadataProvider(DeferredMetadataProvider.loadPartialMetadata(msg.getColumnNames(), msg.getDataTypes()))), 0);
View Full Code Here

@SuppressWarnings("nls")
public class TestStatement {

  @Test public void testBatchExecution() throws Exception {
    ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
    DQP dqp = Mockito.mock(DQP.class);
    ResultsFuture<ResultsMessage> results = new ResultsFuture<ResultsMessage>();
    Mockito.stub(dqp.executeRequest(Mockito.anyLong(), (RequestMessage)Mockito.anyObject())).toReturn(results);
    ResultsMessage rm = new ResultsMessage();
    rm.setResults(new List<?>[] {Arrays.asList(1), Arrays.asList(2)});
    rm.setUpdateResult(true);
    results.getResultsReceiver().receiveResults(rm);
    Mockito.stub(conn.getDQP()).toReturn(dqp);
View Full Code Here

 
  @Test public void testAsynchTimeout() throws Exception {
    ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
    StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    statement.setQueryTimeoutMS(1);
    DQP dqp = Mockito.mock(DQP.class);
    Mockito.stub(statement.getDQP()).toReturn(dqp);
    ResultsFuture<ResultsMessage> future = new ResultsFuture<ResultsMessage>();
    Mockito.stub(dqp.executeRequest(Mockito.anyLong(), (RequestMessage) Mockito.anyObject())).toReturn(future);
    statement.submitExecute("select 'hello world'");
    Thread.sleep(100);
    Mockito.verify(dqp).cancelRequest(0);
  }
View Full Code Here

        super(name);
    }
   
    public static ConnectionImpl getMMConnection() {
      ServerConnection mock = mock(ServerConnection.class);
      DQP dqp = mock(DQP.class);
      try {
      stub(dqp.start((XidImpl)Mockito.anyObject(), Mockito.anyInt(), Mockito.anyInt())).toAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          return ResultsFuture.NULL_FUTURE;
        }
      });
      stub(dqp.rollback((XidImpl)Mockito.anyObject())).toAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          return ResultsFuture.NULL_FUTURE;
        }
      });
      stub(dqp.rollback()).toAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          return ResultsFuture.NULL_FUTURE;
        }
      });
View Full Code Here

TOP

Related Classes of org.teiid.client.DQP

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.