use of com.axway.ats.agent.core.ComponentRepository in project ats-framework by Axway.
the class EnvironmentConfigurator method apply.
@Override
public void apply() throws ConfigurationException {
for (Properties dbProperties : dbPropertiesList) {
int dbConfigurationIndex = -1;
if (dbProperties.get(DB_CONFIGURATION_INDEX) != null) {
dbConfigurationIndex = (Integer) dbProperties.get(DB_CONFIGURATION_INDEX);
}
ComponentRepository componentRepository = ComponentRepository.getInstance();
ComponentEnvironment componentEnvironment;
try {
componentEnvironment = componentRepository.getComponentEnvironment(component);
} catch (NoSuchComponentException nsce) {
throw new ConfigurationException("Error changing environment configuration. CAUSE: " + nsce.getMessage());
}
int foundDbConfigurationIndex = 0;
for (EnvironmentUnit environmentUnit : componentEnvironment.getEnvironmentUnits()) {
if (environmentUnit instanceof DatabaseEnvironmentUnit) {
if (foundDbConfigurationIndex == dbConfigurationIndex) {
DatabaseEnvironmentUnit dbEnvironmentUnit = (DatabaseEnvironmentUnit) environmentUnit;
DbConnection dbConnection = dbEnvironmentUnit.getDbConnection();
// the database port is kept in a list of custom properties
Map<String, Object> customProperties = dbConnection.getCustomProperties();
// get the new configuration properties
String newDbHost = chooseNewProperty(dbProperties.getProperty(DB_HOST), dbConnection.getHost());
String newDbName = chooseNewProperty(dbProperties.getProperty(DB_NAME), dbConnection.getDb());
String newDbUserName = chooseNewProperty(dbProperties.getProperty(DB_USER_NAME), dbConnection.getUser());
String newDbUserPassword = chooseNewProperty(dbProperties.getProperty(DB_USER_PASSWORD), dbConnection.getPassword());
Object newDbPort = chooseDbPort(dbProperties.get(DB_PORT), customProperties.get(DbKeys.PORT_KEY));
// create a new connection object
customProperties.put(DbKeys.PORT_KEY, newDbPort);
DbConnection newDbConnection = DatabaseProviderFactory.createDbConnection(dbConnection.getDbType(), newDbHost, newDbName, newDbUserName, newDbUserPassword, customProperties);
// apply the changes
dbEnvironmentUnit.setDbConnection(newDbConnection);
log.info("Database configuration for index " + dbConfigurationIndex + " is changed. DbConnection: " + newDbConnection.getDescription());
return;
} else {
// still searching the exact database configuration
foundDbConfigurationIndex++;
}
}
}
throw new ConfigurationException("Database configuration with index " + dbConfigurationIndex + " is not available");
}
}
use of com.axway.ats.agent.core.ComponentRepository in project ats-framework by Axway.
the class Test_ActionMethodEnumArguments method setUpTest_ActionHandler.
@BeforeClass
public static void setUpTest_ActionHandler() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(ActionClassEnumArguments.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentRepository in project ats-framework by Axway.
the class Test_ActionMethodValidation method setUpTest_ActionHandler.
@BeforeClass
public static void setUpTest_ActionHandler() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(ActionClassForValidation.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentRepository in project ats-framework by Axway.
the class DisabledTest_RampUpLoaderMultipleInvocations method setUpTest_ActionInvoker.
@BeforeClass
public static void setUpTest_ActionInvoker() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(LoadTestActionClass.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentRepository in project ats-framework by Axway.
the class Test_LocalExecutor method setUpTest_LocalExecutor.
@BeforeClass
public static void setUpTest_LocalExecutor() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(ActionClassOne.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
Aggregations