Package com.vladmihalcea.flexypool.connection

Examples of com.vladmihalcea.flexypool.connection.Credentials


        when(connectionAcquiringStrategy.getConnection(connectionRequestContextArgumentCaptor.capture()))
                .thenReturn(connection);
        verify(connection, never()).getMetaData();
        flexyPoolDataSource.getConnection("username", "password").getMetaData();
        verify(connection, times(1)).getMetaData();
        Credentials credentials = connectionRequestContextArgumentCaptor.getValue().getCredentials();
        assertEquals("username", credentials.getUsername());
        assertEquals("password", credentials.getPassword());
        verify(overallConnectionAcquireTimer, times(1)).update(anyLong(), eq(TimeUnit.MILLISECONDS));
        verify(concurrentConnectionRequestCountHistogram, times(1)).update(1);
        verify(concurrentConnectionRequestCountHistogram, times(1)).update(0);
    }
View Full Code Here


    }

    @Test
    public void testGetConnectionWithCredentials() throws SQLException {
        ConnectionRequestContext connectionRequestContext = new ConnectionRequestContext.Builder()
                .setCredentials(new Credentials("username", "password")).build();
        when(dataSource.getConnection(eq("username"), eq("password"))).thenReturn(connection);
        assertSame(connection, poolAdapter.getConnection(connectionRequestContext));
        verify(timer, times(1)).update(anyLong(), eq(TimeUnit.MILLISECONDS));
    }
View Full Code Here

     */
    @Override
    public Connection getConnection(ConnectionRequestContext requestContext) throws SQLException {
        long startNanos = System.nanoTime();
        try {
            Credentials credentials = requestContext.getCredentials();
            return (credentials == null) ?
                    targetDataSource.getConnection() :
                    targetDataSource.getConnection(credentials.getUsername(), credentials.getPassword());
        } catch (SQLException e) {
            throw translateException(e);
        } catch (RuntimeException e) {
            throw translateException(e);
        } finally {
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Connection getConnection(final String username, final String password) throws SQLException {
        return getConnection(new ConnectionRequestContext.Builder()
                .setCredentials(new Credentials(username, password))
                .build());
    }
View Full Code Here

TOP

Related Classes of com.vladmihalcea.flexypool.connection.Credentials

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.