Interface TestConnectionProviderSource<CONN_CONFIG extends org.projectnessie.versioned.persist.adapter.DatabaseConnectionConfig>

  • All Known Implementing Classes:
    AbstractTestConnectionProviderSource

    public interface TestConnectionProviderSource<CONN_CONFIG extends org.projectnessie.versioned.persist.adapter.DatabaseConnectionConfig>
    Manages all external resources (Docker containers, processes) and "internal" resources (network connections and pools) required for tests.

    There are two ways to choose a TestConnectionProviderSource implementation:

    1. In JUnit tests, reference the implementation class directly using the NessieExternalDatabase annotation.
    2. Via findCompatibleProviderSource(DatabaseAdapterConfig, DatabaseAdapterFactory, String) using a code snippet like this:
      
         DatabaseAdapterConfig config = ...;
         String providerSpec =
             adapter.indexOf(':') == -1
                 ? null
                 : adapter.substring(adapter.indexOf(':') + 1)
                     .toLowerCase(Locale.ROOT);
         TestConnectionProviderSource<DatabaseConnectionConfig> providerSource =
             findCompatibleProviderSource(
                 config, factory, providerSpec);
         providerSource
             .configureConnectionProviderConfigFromDefaults(
                 SystemPropertiesConfigurer
                     ::configureConnectionFromSystemProperties);
         try {
           providerSource.start();
         } catch (Exception e) {
           throw new RuntimeException(e);
         }
         connectionProvider = providerSource.getConnectionProvider();
       
    • Method Detail

      • isCompatibleWith

        boolean isCompatibleWith​(org.projectnessie.versioned.persist.adapter.DatabaseAdapterConfig adapterConfig,
                                 org.projectnessie.versioned.persist.adapter.DatabaseAdapterFactory<?,​?,​?,​?> databaseAdapterFactory)
      • createDefaultConnectionProviderConfig

        CONN_CONFIG createDefaultConnectionProviderConfig()
        Creates the default DatabaseConnectionConfig.
      • setConnectionProviderConfig

        void setConnectionProviderConfig​(CONN_CONFIG connectionProviderConfig)
        Set the configuration for the DatabaseConnectionProvider created when start() is invoked.
      • getConnectionProviderConfig

        CONN_CONFIG getConnectionProviderConfig()
      • getConnectionProvider

        org.projectnessie.versioned.persist.adapter.DatabaseConnectionProvider<CONN_CONFIG> getConnectionProvider()
        Returns the preconfigured connection provider.

        This method should be called after start().

      • start

        void start()
            throws java.lang.Exception
        Initialize/start the connection provider.

        Implementations start for example Docker containers or external processes and setup connection pools.

        Throws:
        java.lang.Exception
      • stop

        void stop()
           throws java.lang.Exception
        Stop the connection provider and release all held resources.

        Implementations for example tear down connection pools and stop example Docker containers or external processes.

        Throws:
        java.lang.Exception