Class TemporaryDatabasePostgreSQL

    • Field Detail

      • MAX_DATABASE_DROP_ATTEMPTS

        protected static final int MAX_DATABASE_DROP_ATTEMPTS
        See Also:
        Constant Field Values
      • TEMPLATE_DATABASE_NAME_PREFIX

        public static final java.lang.String TEMPLATE_DATABASE_NAME_PREFIX
        See Also:
        Constant Field Values
      • LIQUIBASE_RELATIVE_PATH

        public static final java.lang.String LIQUIBASE_RELATIVE_PATH
        See Also:
        Constant Field Values
    • Constructor Detail

      • TemporaryDatabasePostgreSQL

        public TemporaryDatabasePostgreSQL()
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • TemporaryDatabasePostgreSQL

        public TemporaryDatabasePostgreSQL​(java.lang.String testDatabase)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • TemporaryDatabasePostgreSQL

        public TemporaryDatabasePostgreSQL​(java.lang.String testDatabase,
                                           boolean useExisting)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • TemporaryDatabasePostgreSQL

        public TemporaryDatabasePostgreSQL​(java.lang.String testDatabase,
                                           java.lang.String driver,
                                           java.lang.String url,
                                           java.lang.String adminUser,
                                           java.lang.String adminPassword)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • TemporaryDatabasePostgreSQL

        public TemporaryDatabasePostgreSQL​(java.lang.String testDatabase,
                                           java.lang.String driver,
                                           java.lang.String urlBase,
                                           java.lang.String adminUser,
                                           java.lang.String adminPassword,
                                           boolean useExisting)
                                    throws TemporaryDatabaseException
        Throws:
        TemporaryDatabaseException
    • Method Detail

      • countRows

        public int countRows​(java.lang.String sql,
                             java.lang.Object... values)
        Specified by:
        countRows in interface TemporaryDatabase
      • getIntegrationTestTemplateDatabaseName

        public java.lang.String getIntegrationTestTemplateDatabaseName()
                                                                throws java.lang.Throwable
        Throws:
        java.lang.Throwable
      • getDatabaseName

        protected static java.lang.String getDatabaseName​(java.lang.Object hashMe)
      • setupBlame

        protected static void setupBlame​(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                                         java.lang.String blame)
      • dumpThreads

        public static void dumpThreads()
      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Specified by:
        getConnection in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • update

        public void update​(java.lang.String stmt,
                           java.lang.Object... values)
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String username,
                                                 java.lang.String password)
                                          throws java.sql.SQLException
        Specified by:
        getConnection in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • getLogWriter

        public java.io.PrintWriter getLogWriter()
                                         throws java.sql.SQLException
        Specified by:
        getLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        getLogWriter in interface javax.sql.DataSource
        Specified by:
        getLogWriter in interface javax.sql.XADataSource
        Throws:
        java.sql.SQLException
      • setLogWriter

        public void setLogWriter​(java.io.PrintWriter out)
                          throws java.sql.SQLException
        Specified by:
        setLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        setLogWriter in interface javax.sql.DataSource
        Specified by:
        setLogWriter in interface javax.sql.XADataSource
        Throws:
        java.sql.SQLException
      • setLoginTimeout

        public void setLoginTimeout​(int seconds)
                             throws java.sql.SQLException
        Specified by:
        setLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        setLoginTimeout in interface javax.sql.DataSource
        Specified by:
        setLoginTimeout in interface javax.sql.XADataSource
        Throws:
        java.sql.SQLException
      • getLoginTimeout

        public int getLoginTimeout()
                            throws java.sql.SQLException
        Specified by:
        getLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        getLoginTimeout in interface javax.sql.DataSource
        Specified by:
        getLoginTimeout in interface javax.sql.XADataSource
        Throws:
        java.sql.SQLException
      • getParentLogger

        public java.util.logging.Logger getParentLogger()
                                                 throws java.sql.SQLFeatureNotSupportedException
        Specified by:
        getParentLogger in interface javax.sql.CommonDataSource
        Throws:
        java.sql.SQLFeatureNotSupportedException
      • getAdminDataSource

        public javax.sql.DataSource getAdminDataSource()
      • getAdminXADataSource

        public javax.sql.XADataSource getAdminXADataSource()
      • getDataSource

        public javax.sql.DataSource getDataSource()
      • getXADataSource

        public javax.sql.XADataSource getXADataSource()
      • unwrap

        public <T> T unwrap​(java.lang.Class<T> iface)
                     throws java.sql.SQLException
        Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

        If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.

        Specified by:
        unwrap in interface java.sql.Wrapper
        Parameters:
        iface - A Class defining an interface that the result must implement.
        Returns:
        an object that implements the interface. May be a proxy for the actual implementing object.
        Throws:
        java.sql.SQLException - If no object found that implements the interface
        Since:
        1.6
      • isWrapperFor

        public boolean isWrapperFor​(java.lang.Class<?> iface)
                             throws java.sql.SQLException
        Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.
        Specified by:
        isWrapperFor in interface java.sql.Wrapper
        Parameters:
        iface - a Class defining an interface.
        Returns:
        true if this implements the interface or directly or indirectly wraps an object that does.
        Throws:
        java.sql.SQLException - if an error occurs while determining whether this is a wrapper for an object with the given interface.
        Since:
        1.6
      • getXAConnection

        public javax.sql.XAConnection getXAConnection()
                                               throws java.sql.SQLException
        Specified by:
        getXAConnection in interface javax.sql.XADataSource
        Throws:
        java.sql.SQLException
      • getXAConnection

        public javax.sql.XAConnection getXAConnection​(java.lang.String user,
                                                      java.lang.String password)
                                               throws java.sql.SQLException
        Specified by:
        getXAConnection in interface javax.sql.XADataSource
        Throws:
        java.sql.SQLException
      • generateLiquibaseHash

        public java.lang.String generateLiquibaseHash()
                                               throws java.security.NoSuchAlgorithmException,
                                                      java.io.IOException,
                                                      java.lang.Exception,
                                                      liquibase.exception.ChangeLogParseException,
                                                      liquibase.exception.LiquibaseException
        Throws:
        java.security.NoSuchAlgorithmException
        java.io.IOException
        java.lang.Exception
        liquibase.exception.ChangeLogParseException
        liquibase.exception.LiquibaseException
      • createIntegrationTestTemplateDatabase

        protected void createIntegrationTestTemplateDatabase​(java.lang.String dbName)
                                                      throws java.lang.ClassNotFoundException,
                                                             MigrationException,
                                                             java.lang.Throwable,
                                                             java.sql.SQLException
        Throws:
        java.lang.ClassNotFoundException
        MigrationException
        java.lang.Throwable
        java.sql.SQLException