Package org.teiid.net

Examples of org.teiid.net.ServerConnection


     * @return Connection object created
     * @throws SQLException if it is unable to establish a connection to the server.
     */
    public ConnectionImpl connect(String url, Properties info) throws TeiidSQLException {

        ServerConnection serverConn;
    try {
      serverConn = SocketServerConnectionFactory.getInstance().getConnection(info);
    } catch (TeiidException e) {
      throw TeiidSQLException.create(e);
    }
View Full Code Here


     * @throws SQLException if it is unable to establish a connection
     */
    public ConnectionImpl connect(String url, Properties info)
        throws TeiidSQLException {
        try {
          ServerConnection sc = createServerConnection(info);
      return new ConnectionImpl(sc, info, url);
    } catch (TeiidRuntimeException e) {
      throw TeiidSQLException.create(e);
    } catch (ConnectionException e) {
      throw TeiidSQLException.create(e);
View Full Code Here

      } catch (InvocationTargetException e) {
        Exception ex = ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class);
        if (ex == null) {
          ex = ExceptionUtil.getExceptionOfType(e, CommunicationException.class);
          if (ex instanceof SingleInstanceCommunicationException) {
            ServerConnection sc = proxiedConnection.getServerConnection();
            if (!sc.isOpen(ServerConnection.PING_INTERVAL)) {
              ex = null;
            }
          }
        }
        if (ex != null) {
View Full Code Here

   */
  @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);
View Full Code Here

   * @return an instance of TestableMMPreparedStatement
   * @throws SQLException
   */
  protected PreparedStatementImpl getMMPreparedStatement(final String sql) throws SQLException {
    ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
    ServerConnection serverConn = Mockito.mock(ServerConnection.class);
    LogonResult logonResult = Mockito.mock(LogonResult.class);
   
    Mockito.stub(conn.getServerConnection()).toReturn(serverConn);
    Mockito.stub(serverConn.getLogonResult()).toReturn(logonResult);
    Mockito.stub(logonResult.getTimeZone()).toReturn(TimeZone.getDefault());

    return getMMPreparedStatement(conn, sql);
  }
View Full Code Here

    public TestConnection(String name) {
        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;
        }
      });
    } catch (XATransactionException e) {
      throw new RuntimeException(e);
    }
      stub(mock.getService(DQP.class)).toReturn(dqp);
      Properties props = new Properties();
      props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
      props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
      props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
      stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
      return new ConnectionImpl(mock, props, serverUrl);
    }
View Full Code Here

    }
  }

  private CallableStatementImpl getCallableStatement() throws SQLException {
    ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
    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.net.ServerConnection

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.