public class MockUtil extends Object
Caution: This class is not thread-safe.
Upon construction, this class automatically loads test systems and credentials from resource files
TEST_SYSTEMS_RESOURCE_FILE
and CREDENTIALS_RESOURCE_FILE
(appending the file extensions defined by
CONFIG_FILE_EXTENSIONS
). For examples of such files, refer to loadTestSystems(File)
and
loadCredentials(File)
.
In addition, test systems and credentials are read from Java system properties PROPERTY_TEST_SYSTEMS
and
PROPERTY_CREDENTIALS
. Both properties can be used to specify either the path to or the direct content of a
configuration file. For example, these can be specified via
mvn clean install -Dtest.systems="..." -Dtest.credentials="..."
where "..."
corresponds to
either the path to a configuration file or the content of such a file.
When specifying paths to test systems and credentials files, the file extension can be omitted (e.g.,
test/resources/systems
). In this case, this class will scan for the existence of the following files:
test/resources/systems.json
test/resources/systems.yaml
test/resources/systems.yml
Note that the order is arbitrary here since, if more than one matching file is found, an exception is thrown demanding to specify exactly one file. If test systems or credentials are specified as Java system properties while configuration files exist simultaneously within the the test resources folder, only Java system properties are loaded, thereby overriding configuration from files in the test resources folder.
Constructor and Description |
---|
MockUtil()
Instantiates a new instance of
MockUtil , invalidates caches, and resets Hystrix. |
Modifier and Type | Method and Description |
---|---|
void |
addCredentials(String systemAlias,
Credentials credentials)
Registers the given
Credentials to enable retrieval by its alias. |
void |
addDefaultErpSystem(ErpSystem erpSystem)
Adds and sets the default ERP system.
|
void |
addTestSystem(TestSystem<?> testSystem)
Registers the given
TestSystem to enable retrieval by its alias. |
void |
clearCredentials()
Clears all
Credentials . |
void |
clearDestinations()
Clears all previously mocked
Destination s. |
void |
clearKeyStores()
Clears all previously mocked
KeyStore s. |
void |
clearSecretStores()
Clears all previously mocked
SecretStore s. |
void |
clearTenants()
Clears all previously mocked
Tenant s. |
void |
clearTestSystems()
Clears all
TestSystem s. |
void |
clearUsers()
Clears all previously mocked
User s. |
Credentials |
getCredentials(String systemAlias)
Returns the credentials for the given alias.
|
Credentials |
getCredentials(TestSystem<?> testSystem) |
ErpSystem |
getErpSystem() |
ErpSystem |
getErpSystem(String systemAlias) |
TestSystem<?> |
getTestSystem(String systemAlias)
Returns the
TestSystem for the given alias. |
void |
loadCredentials(File file)
Loads credential configuration from the resource file with the given name.
|
void |
loadCredentials(String resourceFileName)
Delegates to
loadCredentials(File) and loads credential configuration from the resource file with the
given name. |
void |
loadTestSystems(File file)
Loads test system configuration from the given file.
|
void |
loadTestSystems(String resourceFileName)
Delegates to
loadTestSystems(File) and loads test system configuration from the resource file with the
given name. |
AuditLog |
mockAuditLog()
Mocks the
AuditLog , redirecting to DefaultLoggerAuditLog within tests. |
CloudPlatform |
mockCurrentCloudPlatform()
Mocks the current
CloudPlatform using application name MOCKED_CLOUD_APP_NAME |
CloudPlatform |
mockCurrentCloudPlatform(String applicationName) |
void |
mockCurrentLocales() |
void |
mockCurrentLocales(Locale locale,
Locale... additionalLocales) |
Tenant |
mockCurrentTenant() |
Tenant |
mockCurrentTenant(String tenantId) |
User |
mockCurrentUser() |
User |
mockCurrentUser(String userName) |
User |
mockCurrentUser(String userName,
Locale locale,
Collection<? extends Authorization> authorizations,
Map<String,? extends UserAttribute> attributes) |
void |
mockDefaults()
Mocks common defaults for testing, in particular:
facades that are used to realize Cloud platform abstractions,
the current
CloudPlatform ,
the current Locale ,
the current Tenant ,
the current User ,
the AuditLog
This method should be called as the first method of MockUtil in the test setup method annotated with
@BeforeClass . |
Destination |
mockDestination(MockDestination destination)
Mocks a destination based on the given
MockDestination . |
Destination |
mockDestination(String name,
String systemAlias)
Mocks a destination with a given name to the given system with the registered credentials.
|
Destination |
mockDestination(String name,
TestSystem<?> testSystem)
Mocks a destination with a given name to the given
TestSystem with the registered credentials. |
Destination |
mockDestination(String name,
URI uri)
Mocks a destination with a given name to redirect to the given
URI with no authentication. |
Destination |
mockDestination(String name,
URI uri,
AuthenticationType authenticationType,
ProxyType proxyType,
ProxyConfiguration proxyConfiguration,
List<Header> headers,
KeyStore trustStore,
String trustStorePassword,
Boolean isTrustingAllCertificates,
KeyStore keyStore,
String keyStorePassword,
Map<String,String> propertiesByName)
Mocks a destination based on the given parameters.
|
Destination |
mockDestination(String name,
URI uri,
Credentials credentials)
Mocks a destination with a given name to redirect to the given
URI with the given Credentials . |
Destination |
mockDestination(String name,
URI uri,
Credentials credentials,
ProxyConfiguration proxyConfiguration)
Mocks a destination with a given name to redirect to the given
URI with the given Credentials . |
Destination |
mockErpDestination()
Mocks an ERP
Destination by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName() . |
Destination |
mockErpDestination(ErpSystem erpSystem)
Mocks an ERP
Destination by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName() . |
Destination |
mockErpDestination(ErpSystem erpSystem,
Credentials credentials)
Mocks an ERP
Destination for the given ErpSystem and Credentials for destination name
ErpDestination.getDefaultName() . |
Destination |
mockErpDestination(MockErpDestination destination)
Mocks an ERP
Destination for the given MockErpDestination . |
Destination |
mockErpDestination(String systemAlias)
Mocks an ERP
Destination by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName() . |
Destination |
mockErpDestination(String destinationName,
ErpSystem erpSystem)
Mocks an ERP
Destination by redirecting to an actual ERP system for the given destination name. |
Destination |
mockErpDestination(String destinationName,
ErpSystem erpSystem,
Credentials credentials)
|
Destination |
mockErpDestination(String destinationName,
ErpSystem erpSystem,
Credentials credentials,
AuthenticationType authenticationType,
ProxyType proxyType,
ProxyConfiguration proxyConfiguration,
List<Header> headers,
KeyStore trustStore,
String trustStorePassword,
Boolean isTrustingAllCertificates,
KeyStore keyStore,
String keyStorePassword,
Map<String,String> propertiesByName)
Mocks an ERP
Destination for the given parameters. |
Destination |
mockErpDestination(String destinationName,
String systemAlias)
Mocks an ERP
Destination by redirecting to an actual ERP system for the given destination name. |
com.github.tomakehurst.wiremock.junit.WireMockRule |
mockErpServer()
Mocks an ERP
Destination with name ErpDestination.getDefaultName() and starts a mock server
pointing all calls against the ERP destination towards the mock server instance. |
com.github.tomakehurst.wiremock.junit.WireMockRule |
mockErpServer(SapClient sapClient)
Mocks an ERP
Destination with name ErpDestination.getDefaultName() and starts a mock server
pointing all calls against the ERP destination towards the mock server instance. |
com.github.tomakehurst.wiremock.junit.WireMockRule |
mockErpServer(SapClient sapClient,
String relativePath)
Mocks an ERP
Destination with name ErpDestination.getDefaultName() and starts a mock server
pointing all calls against the ERP destination towards the mock server instance. |
com.github.tomakehurst.wiremock.junit.WireMockRule |
mockErpServer(String destinationName,
SapClient sapClient,
String relativePath)
Mocks an ERP
Destination and starts a mock server pointing all calls against the ERP destination towards
the mock server instance. |
<T> T |
mockJndiLookup(Class<T> cls,
String name)
Mocks a JNDI lookup.
|
void |
mockJndiLookup(Object obj,
String name)
Mocks a JNDI lookup.
|
void |
mockKeyStore(String name,
SecretStore password,
KeyStore keyStore) |
void |
mockKeyStore(String name,
SecretStore password,
String keyStoreFileName,
String keyStoreType) |
void |
mockKeyStore(String name,
String password,
KeyStore keyStore) |
void |
mockKeyStore(String name,
String password,
String keyStoreFileName,
String keyStoreType) |
RfcDestination |
mockRfcDestination()
Mocks an
RfcDestination by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName() . |
RfcDestination |
mockRfcDestination(ErpSystem erpSystem)
Mocks an
RfcDestination by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName() . |
RfcDestination |
mockRfcDestination(ErpSystem erpSystem,
Credentials credentials)
Mocks an
RfcDestination for the given ErpSystem and Credentials for destination name
ErpDestination.getDefaultName() . |
RfcDestination |
mockRfcDestination(MockRfcDestination destination)
Mocks an
RfcDestination for the given MockRfcDestination . |
RfcDestination |
mockRfcDestination(String systemAlias)
Mocks an
RfcDestination by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName() . |
RfcDestination |
mockRfcDestination(String destinationName,
ErpSystem erpSystem)
Mocks an
RfcDestination by redirecting to an actual ERP system for the given destination name. |
RfcDestination |
mockRfcDestination(String destinationName,
ErpSystem erpSystem,
Credentials credentials)
|
RfcDestination |
mockRfcDestination(String destinationName,
ErpSystem erpSystem,
Credentials credentials,
Map<String,String> propertiesByName)
Mocks an
RfcDestination for the given parameters. |
RfcDestination |
mockRfcDestination(String destinationName,
String systemAlias)
Mocks an
RfcDestination by redirecting to an actual ERP system for the given destination name. |
void |
mockSecretStore(String name,
SecretStore secretStore) |
void |
mockSecretStore(String name,
String password) |
com.github.tomakehurst.wiremock.junit.WireMockRule |
mockServer(String destinationName)
Mocks a
Destination and starts a mock server pointing all calls against the destination towards the mock
server instance. |
com.github.tomakehurst.wiremock.junit.WireMockRule |
mockServer(String destinationName,
String relativePath)
Mocks a
Destination and starts a mock server pointing all calls against the destination towards the mock
server instance. |
Tenant |
mockTenant(String tenantId) |
User |
mockUser(String userName) |
User |
mockUser(String userName,
Locale locale,
Collection<? extends Authorization> authorizations,
Map<String,? extends UserAttribute> attributes) |
void |
removeCredentials(String systemAlias)
Unregisters the
Credentials for the given alias. |
void |
removeTestSystem(String systemAlias)
Unregisters the
TestSystem for the given alias. |
void |
removeTestSystem(TestSystem<?> testSystem)
Unregisters the given
TestSystem . |
RequestContextExecutor |
requestContextExecutor() |
void |
setCurrentTenant(String tenantId)
Sets the current
Tenant . |
void |
setCurrentUser(String userName)
Sets the current
User . |
MockUtil |
withProxy(ProxyConfiguration proxyConfiguration) |
public MockUtil()
MockUtil
, invalidates caches, and resets Hystrix.
Note: To avoid potential side effects, only one instance of MockUtil should exist within a test class. It is
therefore recommended to maintain an instance of this class as a static member of the test class. Example usage:
private static final MockUtil mockUtil = new MockUtil();
@BeforeClass
public static void beforeClass()
{
mockUtil.mockDefaults();
}
public MockUtil withProxy(@Nullable ProxyConfiguration proxyConfiguration)
public void mockDefaults()
CloudPlatform
,Locale
,Tenant
,User
,AuditLog
MockUtil
in the test setup method annotated with
@BeforeClass
.public void mockJndiLookup(Object obj, String name)
obj
- Object to be returned by the lookup.name
- Name that is used for the lookup.public <T> T mockJndiLookup(Class<T> cls, String name)
cls
- Class to be mocked.name
- Name that is used for the lookup.public CloudPlatform mockCurrentCloudPlatform()
CloudPlatform
using application name MOCKED_CLOUD_APP_NAME
public CloudPlatform mockCurrentCloudPlatform(String applicationName)
public void mockCurrentLocales()
public AuditLog mockAuditLog()
AuditLog
, redirecting to DefaultLoggerAuditLog
within tests.Mockito.spy(Object)
of the DefaultLoggerAuditLog
that logs are redirected to.public TestSystem<?> getTestSystem(String systemAlias)
TestSystem
for the given alias. By default, TestSystem
s are loaded from the system
property PROPERTY_TEST_SYSTEMS
and the test resource file
TEST_SYSTEMS_RESOURCE_FILE
(with extension .json/.yml for JSON/YAML format). For registering
additional TestSystem
s, use loadTestSystems(String)
or addTestSystem(TestSystem)
.public ErpSystem getErpSystem()
public ErpSystem getErpSystem(String systemAlias)
ErpSystem
for the given alias. Delegates to getTestSystem(String)
.public void loadTestSystems(String resourceFileName)
loadTestSystems(File)
and loads test system configuration from the resource file with the
given name. The file is assumed to be in JSON format and expected to be located in src/test/resources/
.resourceFileName
- The name of the file to be loaded from the resources folder.public void loadTestSystems(@Nullable File file)
"alias"
field must be unique.
Note: Configuration specified as Java system properties always overrides configuration loaded from files.
Example (YAML):
---
systems:
- alias: "ANY_SYSTEM"
uri: "https://any-system.com"
proxy: "http://my-proxy:8080"
erp:
default: "ERP_001"
systems:
- alias: "ERP_001"
uri: "https://my-erp.com"
systemId: "ERP" # optional, defaults to ""
sapClient: "001" # optional, defaults to default SAP client
locale: "en" # optional, defaults to English (US)
erpEdition: "cloud" # optional, defaults to "cloud"
proxy: "http://my-proxy:8080" # optional
applicationServer: "my-erp.com" # optional, defaults to URI host
instanceNumber: "00" # optional, defaults to "00"
Example (JSON):
{
"systems": [
{
"alias": "ANY_SYSTEM",
"uri": "https://any-system.com",
"proxy": "http://my-proxy:8080"
}
],
"erp": {
"default": "ERP_001",
"systems": [
{
"alias": "ERP_001",
"systemId": "ERP",
"sapClient": "001",
"locale": "en",
"erpEdition": "cloud",
"uri": "https://my-erp.com",
"proxy": "http://my-proxy:8080",
"applicationServer": "my-erp.com",
"instanceNumber": "00"
}
]
}
}
file
- The file to be loaded.public void addTestSystem(TestSystem<?> testSystem)
TestSystem
to enable retrieval by its alias. Replaces TestSystem
s that may
already exist for the given alias.public void removeTestSystem(TestSystem<?> testSystem)
TestSystem
.public void removeTestSystem(String systemAlias)
TestSystem
for the given alias.public void addDefaultErpSystem(ErpSystem erpSystem)
public void clearTestSystems()
TestSystem
s.public Credentials getCredentials(TestSystem<?> testSystem)
TestSystem
. Delegates to getCredentials(String)
.public Credentials getCredentials(String systemAlias)
Credentials
are loaded from the Java system
property PROPERTY_CREDENTIALS
and the test resource file
CREDENTIALS_RESOURCE_FILE
. For registering additional Credentials
, use
loadCredentials(String)
or addCredentials(String, Credentials)
.public void loadCredentials(String resourceFileName)
loadCredentials(File)
and loads credential configuration from the resource file with the
given name. The file is assumed to be in JSON format and expected to be located in /src/test/resources/
.resourceFileName
- The name of the file to be loaded from the resources folder.public void loadCredentials(@Nullable File file)
Note: Configuration specified as Java system properties always overrides configuration loaded from files.
Example (YAML):
---
credentials:
- alias: "ABC_001"
username: "(username)"
password: "(password)"
Example (JSON):
{
"credentials": [
{
"alias": "ABC_001",
"username": "(username)",
"password": "(password)"
}
]
}
file
- The file to be loaded.public void addCredentials(String systemAlias, Credentials credentials)
Credentials
to enable retrieval by its alias. Replaces Credentials
that may
already exist for the given alias.public void removeCredentials(String systemAlias)
Credentials
for the given alias.public void clearCredentials()
Credentials
.public Tenant mockCurrentTenant()
public void clearTenants()
Tenant
s.public User mockUser(String userName, @Nullable Locale locale, @Nullable Collection<? extends Authorization> authorizations, @Nullable Map<String,? extends UserAttribute> attributes)
public User mockCurrentUser()
public User mockCurrentUser(String userName, @Nullable Locale locale, @Nullable Collection<? extends Authorization> authorizations, @Nullable Map<String,? extends UserAttribute> attributes)
public void clearUsers()
User
s.public void mockSecretStore(String name, SecretStore secretStore)
public void mockKeyStore(String name, SecretStore password, KeyStore keyStore)
public void mockKeyStore(String name, SecretStore password, String keyStoreFileName, String keyStoreType)
public void mockKeyStore(String name, String password, String keyStoreFileName, String keyStoreType)
public void clearSecretStores()
SecretStore
s.public void clearKeyStores()
KeyStore
s.public Destination mockDestination(String name, String systemAlias)
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockDestination(String name, TestSystem<?> testSystem)
TestSystem
with the registered credentials.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockDestination(String name, URI uri)
URI
with no authentication.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockDestination(String name, URI uri, @Nullable Credentials credentials)
URI
with the given Credentials
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockDestination(String name, URI uri, @Nullable Credentials credentials, @Nullable ProxyConfiguration proxyConfiguration)
URI
with the given Credentials
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockDestination(String name, URI uri, @Nullable AuthenticationType authenticationType, @Nullable ProxyType proxyType, @Nullable ProxyConfiguration proxyConfiguration, @Nullable List<Header> headers, @Nullable KeyStore trustStore, @Nullable String trustStorePassword, @Nullable Boolean isTrustingAllCertificates, @Nullable KeyStore keyStore, @Nullable String keyStorePassword, @Nullable Map<String,String> propertiesByName)
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockDestination(MockDestination destination)
MockDestination
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public void clearDestinations()
Destination
s.public Destination mockErpDestination()
Destination
by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName()
.
The system that is used is either defined as property PROPERTY_ERP_ALIAS
or in the Java system
property PROPERTY_TEST_SYSTEMS
and the test resource file
TEST_SYSTEMS_RESOURCE_FILE
(with extension .json/.yml for JSON/YAML format).
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public Destination mockErpDestination(String systemAlias)
Destination
by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName()
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
systemAlias
- The alias of the ErpSystem
that should be used. Must not be null
.public Destination mockErpDestination(@Nullable ErpSystem erpSystem)
Destination
by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName()
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.public Destination mockErpDestination(@Nullable ErpSystem erpSystem, @Nullable Credentials credentials)
Destination
for the given ErpSystem
and Credentials
for destination name
ErpDestination.getDefaultName()
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.credentials
- The Credentials
to be used for accessing the system. If null
, they are resolved from
configuration files or explicit registration via addCredentials(String, Credentials)
.
Only adds the respective HTTP header for the given credentials if the header does not yet exist.public Destination mockErpDestination(@Nullable String destinationName, String systemAlias)
Destination
by redirecting to an actual ERP system for the given destination name.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.systemAlias
- The alias of the ErpSystem
that should be used. Must not be null
.public Destination mockErpDestination(@Nullable String destinationName, @Nullable ErpSystem erpSystem)
Destination
by redirecting to an actual ERP system for the given destination name.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.public Destination mockErpDestination(@Nullable String destinationName, @Nullable ErpSystem erpSystem, @Nullable Credentials credentials)
Destination
for the given destination name, ErpSystem
and Credentials
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.credentials
- The Credentials
to be used for accessing the system. If null
, they are resolved from
configuration files or explicit registration via addCredentials(String, Credentials)
.
Only adds the respective HTTP header for the given credentials if the header does not yet exist.public Destination mockErpDestination(@Nullable String destinationName, @Nullable ErpSystem erpSystem, @Nullable Credentials credentials, @Nullable AuthenticationType authenticationType, @Nullable ProxyType proxyType, @Nullable ProxyConfiguration proxyConfiguration, @Nullable List<Header> headers, @Nullable KeyStore trustStore, @Nullable String trustStorePassword, @Nullable Boolean isTrustingAllCertificates, @Nullable KeyStore keyStore, @Nullable String keyStorePassword, @Nullable Map<String,String> propertiesByName)
Destination
for the given parameters.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.credentials
- The Credentials
to be used for accessing the system. If null
, they are resolved from
configuration files or explicit registration via addCredentials(String, Credentials)
.
Only adds the respective HTTP header for the given credentials if the header does not yet exist.authenticationType
- The AuthenticationType
to be used.proxyType
- The ProxyType
to be used. If not null
, overrides the ProxyType
inferred from
the ErpSystem
.proxyConfiguration
- The ProxyConfiguration
to be used.headers
- Header
s to be used.trustStore
- The trust store to be used.trustStorePassword
- The trust store password to be used.isTrustingAllCertificates
- Decides whether all certificates are trusted.keyStore
- The KeyStore
to be used.keyStorePassword
- The KeyStore
password to be used.propertiesByName
- Properties of the Destination
by their name. If a property with the respective name is
provided, it will override pre-configured properties such as
ErpConfigContext.DEFAULT_SAP_CLIENT_PROPERTY
and
ErpConfigContext.DEFAULT_LOCALE_PROPERTY
.ErpConfigContext.DEFAULT_SAP_CLIENT_PROPERTY
,
ErpConfigContext.DEFAULT_LOCALE_PROPERTY
public Destination mockErpDestination(MockErpDestination destination)
Destination
for the given MockErpDestination
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public RequestContextExecutor requestContextExecutor()
RequestContextExecutor
that is pre-configured for testing.public RfcDestination mockRfcDestination()
RfcDestination
by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName()
.
The system that is used is either defined as property PROPERTY_ERP_ALIAS
or in the Java system
property PROPERTY_TEST_SYSTEMS
and the test resource file
TEST_SYSTEMS_RESOURCE_FILE
(with extension .json/.yml for JSON/YAML format).
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public RfcDestination mockRfcDestination(String systemAlias)
RfcDestination
by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName()
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
systemAlias
- The alias of the ErpSystem
that should be used. Must not be null
.public RfcDestination mockRfcDestination(@Nullable ErpSystem erpSystem)
RfcDestination
by redirecting to an actual ERP system for destination name
ErpDestination.getDefaultName()
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.public RfcDestination mockRfcDestination(@Nullable ErpSystem erpSystem, @Nullable Credentials credentials)
RfcDestination
for the given ErpSystem
and Credentials
for destination name
ErpDestination.getDefaultName()
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.credentials
- The Credentials
to be used for accessing the system. If null
, they are resolved from
configuration files or explicit registration via addCredentials(String, Credentials)
.public RfcDestination mockRfcDestination(@Nullable String destinationName, String systemAlias)
RfcDestination
by redirecting to an actual ERP system for the given destination name.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.systemAlias
- The alias of the ErpSystem
that should be used. Must not be null
.public RfcDestination mockRfcDestination(@Nullable String destinationName, @Nullable ErpSystem erpSystem)
RfcDestination
by redirecting to an actual ERP system for the given destination name.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.public RfcDestination mockRfcDestination(@Nullable String destinationName, @Nullable ErpSystem erpSystem, @Nullable Credentials credentials)
RfcDestination
for the given destination name, ErpSystem
and Credentials
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.credentials
- The Credentials
to be used for accessing the system. If null
, they are resolved from
configuration files or explicit registration via addCredentials(String, Credentials)
.public RfcDestination mockRfcDestination(@Nullable String destinationName, @Nullable ErpSystem erpSystem, @Nullable Credentials credentials, @Nullable Map<String,String> propertiesByName)
RfcDestination
for the given parameters.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
destinationName
- The name of the mocked destination. If null
, ErpDestination.getDefaultName()
is used.erpSystem
- The ErpSystem
to use for mocking. If null
, {getErpSystem()
is used.credentials
- The Credentials
to be used for accessing the system. If null
, they are resolved from
configuration files or explicit registration via addCredentials(String, Credentials)
.propertiesByName
- Properties of the RfcDestination
by their name. If a property with the respective name is
provided, it will override pre-configured properties such as
ErpConfigContext.DEFAULT_SAP_CLIENT_PROPERTY_RFC
and
ErpConfigContext.DEFAULT_LOCALE_PROPERTY_RFC
.ErpConfigContext.DEFAULT_SAP_CLIENT_PROPERTY
,
ErpConfigContext.DEFAULT_LOCALE_PROPERTY
public RfcDestination mockRfcDestination(MockRfcDestination destination)
RfcDestination
for the given MockRfcDestination
.
Note: This invalidates all caches to avoid stale entries within the
DestinationsRequestContextListener
.
public com.github.tomakehurst.wiremock.junit.WireMockRule mockServer(String destinationName, @Nullable String relativePath)
Destination
and starts a mock server pointing all calls against the destination towards the mock
server instance.public com.github.tomakehurst.wiremock.junit.WireMockRule mockServer(String destinationName)
Destination
and starts a mock server pointing all calls against the destination towards the mock
server instance.public com.github.tomakehurst.wiremock.junit.WireMockRule mockErpServer(@Nullable String destinationName, @Nullable SapClient sapClient, @Nullable String relativePath)
Destination
and starts a mock server pointing all calls against the ERP destination towards
the mock server instance.destinationName
- The name of the destination to be mocked. If null
, ErpDestination.getDefaultName()
is
used.sapClient
- The SapClient
to be set as a destination property of the mocked destination. If null
,
SapClient.DEFAULT
is used.relativePath
- An optional relative path to be appended to the ERP URI.public com.github.tomakehurst.wiremock.junit.WireMockRule mockErpServer(@Nullable SapClient sapClient, @Nullable String relativePath)
Destination
with name ErpDestination.getDefaultName()
and starts a mock server
pointing all calls against the ERP destination towards the mock server instance.sapClient
- The SapClient
to be set as a destination property of the mocked destination. If omitted,
SapClient.DEFAULT
is used.relativePath
- An optional relative path to be appended to the ERP URI.public com.github.tomakehurst.wiremock.junit.WireMockRule mockErpServer(@Nullable SapClient sapClient)
Destination
with name ErpDestination.getDefaultName()
and starts a mock server
pointing all calls against the ERP destination towards the mock server instance.sapClient
- The SapClient
to be set as a destination property of the mocked destination. If omitted,
SapClient.DEFAULT
is used.public com.github.tomakehurst.wiremock.junit.WireMockRule mockErpServer()
Destination
with name ErpDestination.getDefaultName()
and starts a mock server
pointing all calls against the ERP destination towards the mock server instance.Copyright © 2017 SAP SE. All rights reserved.