Class AstrixTestContext

  • All Implemented Interfaces:
    com.avanza.astrix.context.Astrix, com.avanza.astrix.context.AstrixContext, AutoCloseable

    public class AstrixTestContext
    extends Object
    implements com.avanza.astrix.context.AstrixContext
    • Method Detail

      • getConfigSourceId

        public String getConfigSourceId()
        The configSourceId might be used to retrieve the ConfigSource instance using GlobalConfigSourceRegistry.getConfigSource(String)
        Returns:
        the configSourceId for the associated ConfigSource.
      • getConfigSource

        public com.avanza.astrix.config.MapConfigSource getConfigSource()
      • getServiceRegistryUri

        public String getServiceRegistryUri()
        Returns:
        the serviceUri for the associated service-registry.
      • getBean

        public <T> T getBean​(Class<T> serviceBean)
        Specified by:
        getBean in interface com.avanza.astrix.context.Astrix
      • getBean

        public <T> T getBean​(Class<T> serviceBean,
                             String qualifier)
        Specified by:
        getBean in interface com.avanza.astrix.context.Astrix
      • destroy

        public void destroy()
        Specified by:
        destroy in interface com.avanza.astrix.context.AstrixContext
      • registerProxy

        public <T> void registerProxy​(Class<T> service,
                                      String qualifier)
        Parameters:
        service - - The qualified bean type to register a proxy for
        qualifier - - The qualifier of the bean type to register a proxy for
        See Also:
        AstrixRuleContext.registerProxy(Class)
      • setProxyState

        public <T> void setProxyState​(Class<T> type,
                                      T mock)
        Sets the proxy state for a given proxy in the service registry. If no proxy has bean registered before it will be created with the given initial state, see AstrixRuleContext.registerProxy(Class) for more details. When a service-provider is proxied it allows fast switching of the given provider between different test-runs, without restarting the entire test environment.
        Parameters:
        type - - The api to register a provider for.
        mock - - The instance to delegate all invocations to the given api to. Might be null in which case a ServiceUnavailableException will be thrown when the service is invoked.
      • setProxyState

        public <T> void setProxyState​(Class<T> type,
                                      String qualifier,
                                      T mock)
        Sets the proxy state for a given proxy in the service registry. If no proxy has bean registered before it will be created with the given initial state, see AstrixRuleContext.registerProxy(Class) for more details. When a service-provider is proxied it allows fast switching of the given provider between different test-runs, without restarting the entire test environment.
        Parameters:
        type - - The api to register a provider for.
        qualifier - - The qualifier for the service bean to register a provider for
        mock - - The instance to delegate all invocations to the given api to. Might be null in which case a ServiceUnavailableException will be thrown when the service is invoked.
      • resetProxies

        public void resetProxies()
      • getAstrixContext

        public com.avanza.astrix.context.AstrixContext getAstrixContext()
      • getTestApi

        public <T extends TestApi> T getTestApi​(Class<T> testApi)
      • resetTestApis

        public void resetTestApis()
      • setConfigurationProperty

        public void setConfigurationProperty​(String settingName,
                                             String value)