Package com.avanza.astrix.test
Class AstrixTestContext
- java.lang.Object
-
- com.avanza.astrix.test.AstrixTestContext
-
- All Implemented Interfaces:
com.avanza.astrix.context.Astrix,com.avanza.astrix.context.AstrixContext,java.lang.AutoCloseable
public class AstrixTestContext extends java.lang.Object implements com.avanza.astrix.context.AstrixContext
-
-
Constructor Summary
Constructors Constructor Description AstrixTestContext(com.avanza.astrix.config.MapConfigSource configSource, java.lang.Class<? extends TestApi>... testApis)AstrixTestContext(java.lang.Class<? extends TestApi>... testApis)Deprecated.Please useAstrixTestContext(MapConfigSource, Class[])
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddestroy()com.avanza.astrix.context.AstrixContextgetAstrixContext()<T> TgetBean(java.lang.Class<T> serviceBean)<T> TgetBean(java.lang.Class<T> serviceBean, java.lang.String qualifier)com.avanza.astrix.config.MapConfigSourcegetConfigSource()java.lang.StringgetConfigSourceId()The configSourceId might be used to retrieve the ConfigSource instance usingGlobalConfigSourceRegistry.getConfigSource(String)java.lang.StringgetServiceRegistryUri()<T extends TestApi>
TgetTestApi(java.lang.Class<T> testApi)<T> voidregisterProxy(java.lang.Class<T> service)<T> voidregisterProxy(java.lang.Class<T> service, java.lang.String qualifier)voidresetProxies()voidresetTestApis()voidsetConfigurationProperty(java.lang.String settingName, java.lang.String value)<T> voidsetProxyState(java.lang.Class<T> type, java.lang.String qualifier, T mock)Sets the proxy state for a given proxy in the service registry.<T> voidsetProxyState(java.lang.Class<T> type, T mock)Sets the proxy state for a given proxy in the service registry.<T> TwaitForBean(java.lang.Class<T> type, long timeoutMillis)<T> TwaitForBean(java.lang.Class<T> type, java.lang.String qualifier, long timeoutMillis)
-
-
-
Constructor Detail
-
AstrixTestContext
@Deprecated @SafeVarargs public AstrixTestContext(java.lang.Class<? extends TestApi>... testApis)
Deprecated.Please useAstrixTestContext(MapConfigSource, Class[])
-
AstrixTestContext
@SafeVarargs public AstrixTestContext(com.avanza.astrix.config.MapConfigSource configSource, java.lang.Class<? extends TestApi>... testApis)
-
-
Method Detail
-
getConfigSourceId
public java.lang.String getConfigSourceId()
The configSourceId might be used to retrieve the ConfigSource instance usingGlobalConfigSourceRegistry.getConfigSource(String)- Returns:
- the configSourceId for the associated ConfigSource.
-
getConfigSource
public com.avanza.astrix.config.MapConfigSource getConfigSource()
-
getServiceRegistryUri
public java.lang.String getServiceRegistryUri()
- Returns:
- the serviceUri for the associated service-registry.
-
waitForBean
public <T> T waitForBean(java.lang.Class<T> type, long timeoutMillis) throws java.lang.InterruptedException- Specified by:
waitForBeanin interfacecom.avanza.astrix.context.Astrix- Throws:
java.lang.InterruptedException
-
waitForBean
public <T> T waitForBean(java.lang.Class<T> type, java.lang.String qualifier, long timeoutMillis) throws java.lang.InterruptedException- Specified by:
waitForBeanin interfacecom.avanza.astrix.context.Astrix- Throws:
java.lang.InterruptedException
-
getBean
public <T> T getBean(java.lang.Class<T> serviceBean)
- Specified by:
getBeanin interfacecom.avanza.astrix.context.Astrix
-
getBean
public <T> T getBean(java.lang.Class<T> serviceBean, java.lang.String qualifier)- Specified by:
getBeanin interfacecom.avanza.astrix.context.Astrix
-
destroy
public void destroy()
- Specified by:
destroyin interfacecom.avanza.astrix.context.AstrixContext
-
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
registerProxy
public <T> void registerProxy(java.lang.Class<T> service)
- Parameters:
service- - The qualified bean type to register a proxy for- See Also:
AstrixRuleContext.registerProxy(Class)
-
registerProxy
public <T> void registerProxy(java.lang.Class<T> service, java.lang.String qualifier)- Parameters:
service- - The qualified bean type to register a proxy forqualifier- - The qualifier of the bean type to register a proxy for- See Also:
AstrixRuleContext.registerProxy(Class)
-
setProxyState
public <T> void setProxyState(java.lang.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, seeAstrixRuleContext.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(java.lang.Class<T> type, java.lang.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, seeAstrixRuleContext.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 formock- - 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(java.lang.Class<T> testApi)
-
resetTestApis
public void resetTestApis()
-
setConfigurationProperty
public void setConfigurationProperty(java.lang.String settingName, java.lang.String value)
-
-