Search in sources :

Example 11 with DatabaseEnvironmentUnit

use of com.axway.ats.environment.database.DatabaseEnvironmentUnit in project ats-framework by Axway.

the class MockDbEnvironmentUnit method testChangingDbPort.

@Test
public void testChangingDbPort() throws ConfigurationException, ComponentAlreadyDefinedException {
    Properties properties = new Properties();
    properties.put(EnvironmentConfigurator.DB_CONFIGURATION_INDEX, 0);
    properties.put(EnvironmentConfigurator.DB_PORT, 1234);
    EnvironmentConfigurator environmentConfigurator = new EnvironmentConfigurator(COMPONENT_NAME, Arrays.asList(properties));
    environmentConfigurator.apply();
    DatabaseEnvironmentUnit dbEnvUnit = (DatabaseEnvironmentUnit) testComponent.getEnvironments().get(0).getEnvironmentUnits().get(0);
    assertEquals(1234, dbEnvUnit.getDbConnection().getCustomProperties().get(DbKeys.PORT_KEY));
}
Also used : DatabaseEnvironmentUnit(com.axway.ats.environment.database.DatabaseEnvironmentUnit) Properties(java.util.Properties) Test(org.junit.Test)

Example 12 with DatabaseEnvironmentUnit

use of com.axway.ats.environment.database.DatabaseEnvironmentUnit in project ats-framework by Axway.

the class MockDbEnvironmentUnit method testChangingDbPassword.

@Test
public void testChangingDbPassword() throws ConfigurationException, ComponentAlreadyDefinedException {
    Properties properties = new Properties();
    properties.put(EnvironmentConfigurator.DB_CONFIGURATION_INDEX, 0);
    properties.put(EnvironmentConfigurator.DB_USER_PASSWORD, "new_test_password");
    EnvironmentConfigurator environmentConfigurator = new EnvironmentConfigurator(COMPONENT_NAME, Arrays.asList(properties));
    environmentConfigurator.apply();
    DatabaseEnvironmentUnit dbEnvUnit = (DatabaseEnvironmentUnit) testComponent.getEnvironments().get(0).getEnvironmentUnits().get(0);
    assertEquals("new_test_password", dbEnvUnit.getDbConnection().getPassword());
}
Also used : DatabaseEnvironmentUnit(com.axway.ats.environment.database.DatabaseEnvironmentUnit) Properties(java.util.Properties) Test(org.junit.Test)

Example 13 with DatabaseEnvironmentUnit

use of com.axway.ats.environment.database.DatabaseEnvironmentUnit in project ats-framework by Axway.

the class MockDbEnvironmentUnit method testChangingDbName.

@Test
public void testChangingDbName() throws ConfigurationException, ComponentAlreadyDefinedException {
    Properties properties = new Properties();
    properties.put(EnvironmentConfigurator.DB_CONFIGURATION_INDEX, 0);
    properties.put(EnvironmentConfigurator.DB_NAME, "new_test_dbName");
    EnvironmentConfigurator environmentConfigurator = new EnvironmentConfigurator(COMPONENT_NAME, Arrays.asList(properties));
    environmentConfigurator.apply();
    DatabaseEnvironmentUnit dbEnvUnit = (DatabaseEnvironmentUnit) testComponent.getEnvironments().get(0).getEnvironmentUnits().get(0);
    assertEquals("new_test_dbName", dbEnvUnit.getDbConnection().getDb());
}
Also used : DatabaseEnvironmentUnit(com.axway.ats.environment.database.DatabaseEnvironmentUnit) Properties(java.util.Properties) Test(org.junit.Test)

Example 14 with DatabaseEnvironmentUnit

use of com.axway.ats.environment.database.DatabaseEnvironmentUnit in project ats-framework by Axway.

the class Test_ConfigurationParser method checkDbEnvironmentUnit_OracleSID.

@Test
public void checkDbEnvironmentUnit_OracleSID() throws Exception {
    InputStream descriptorFileStream = Test_ConfigurationParser.class.getResourceAsStream("descriptor_oracle.xml");
    ConfigurationParser configParser = new ConfigurationParser();
    configParser.parse(descriptorFileStream, jarFileAbsolutePath);
    assertEquals(DatabaseEnvironmentUnit.class, configParser.getEnvironments().get(0).getEnvironmentUnits().get(0).getClass());
    DatabaseEnvironmentUnit dbUnit = (DatabaseEnvironmentUnit) configParser.getEnvironments().get(0).getEnvironmentUnits().get(0);
    Map<String, Object> customDbConnectionProperties = dbUnit.getDbConnection().getCustomProperties();
    // check SID
    assertEquals("some_sid", customDbConnectionProperties.get(OracleKeys.SID_KEY));
    // check that the URL is right (using the SID correctly)
    assertEquals("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SID=some_sid)))", dbUnit.getDbConnection().getURL());
}
Also used : InputStream(java.io.InputStream) DatabaseEnvironmentUnit(com.axway.ats.environment.database.DatabaseEnvironmentUnit) Test(org.junit.Test)

Aggregations

DatabaseEnvironmentUnit (com.axway.ats.environment.database.DatabaseEnvironmentUnit)14 Test (org.junit.Test)11 Properties (java.util.Properties)6 ArrayList (java.util.ArrayList)5 DbTable (com.axway.ats.environment.database.model.DbTable)4 BaseTest (com.axway.ats.environment.BaseTest)3 EnvironmentUnit (com.axway.ats.environment.EnvironmentUnit)3 InputStream (java.io.InputStream)3 DbConnection (com.axway.ats.core.dbaccess.DbConnection)2 DirectoryEnvironmentUnit (com.axway.ats.environment.file.DirectoryEnvironmentUnit)2 FileEnvironmentUnit (com.axway.ats.environment.file.FileEnvironmentUnit)2 ComponentEnvironment (com.axway.ats.agent.core.ComponentEnvironment)1 ComponentRepository (com.axway.ats.agent.core.ComponentRepository)1 AgentException (com.axway.ats.agent.core.exceptions.AgentException)1 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1