Java Code Examples for org.wso2.carbon.automation.engine.context.AutomationContext#getConfigurationValue()

The following examples show how to use org.wso2.carbon.automation.engine.context.AutomationContext#getConfigurationValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MailToTransportUtil.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Read automation.xml to set email credentials to relevant variables.
 */
public static void readXMLforEmailCredentials() throws ESBMailTransportIntegrationTestException {
    try {

        AutomationContext automationContext = new AutomationContext();
        automationContext.getConfigurationNodeList(EMAIL_CREDENTIAL_PARENT_XPATH);

        sender = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_SENDER_XPATH);
        senderPassword = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_SENDER_PASSWORD_XPATH)
                .toCharArray();
        receiver = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_RECEIVER_XPATH);
        receiverPassword = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_RECEIVER_PASSWORD_XPATH)
                .toCharArray();
        domain = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_DOMAIN_XPATH);

    } catch (XPathExpressionException e) {
        log.error("Error when getting value from automation.xml ", e);
        throw new ESBMailTransportIntegrationTestException("Error when getting value from automation.xml ", e);
    }
}
 
Example 2
Source File: StoreAndForwardWithEmptyMessageBodyTesCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public void init() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    String databaseName = System.getProperty("basedir") + File.separator + "target" + File.separator +
            "testdb_store" + new Random().nextInt();
    JDBC_URL = JDBC_URL + databaseName + ";DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE";
    h2DatabaseManager = new H2DataBaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    h2DatabaseManager.executeUpdate("CREATE TABLE IF NOT EXISTS JDBC_MESSAGE_STORE(\n" +
            "indexId BIGINT(20) NOT NULL AUTO_INCREMENT,\n" +
            "msg_id VARCHAR(200) NOT NULL ,\n" +
            "message BLOB NOT NULL,\n" +
            "PRIMARY KEY ( indexId )\n" +
            ")");
    logViewer = new LogViewerClient(context.getContextUrls().getBackEndUrl(), sessionCookie);
    super.init();
}
 
Example 3
Source File: JDBCMessageStoreProcRESTTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void init() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    DATASOURCE_NAME = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_NAME);
    DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    JDBC_DRIVER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DRIVER_CLASS_NAME);
    serverConfigurationManager = new ServerConfigurationManager(context);
    copyJDBCDriverToClassPath();
    mySqlDatabaseManager = new MySqlDatabaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    mySqlDatabaseManager.executeUpdate("DROP DATABASE IF EXISTS WSO2SampleDBForAutomation");

    super.init();

    headers.put("Test-Header-Field", "TestHeaderValue");

    logViewer = new LogViewerClient(contextUrls.getBackEndUrl(),getSessionCookie());
}
 
Example 4
Source File: JDBCMessageProcessorTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void init() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    DATASOURCE_NAME = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_NAME);
    DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    JDBC_DRIVER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DRIVER_CLASS_NAME);
    serverConfigurationManager = new ServerConfigurationManager(context);
    copyJDBCDriverToClassPath();
    mySqlDatabaseManager = new MySqlDatabaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    mySqlDatabaseManager.executeUpdate("DROP DATABASE IF EXISTS WSO2SampleDBForAutomation");

    super.init();

}
 
Example 5
Source File: MailToTransportUtil.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Read automation.xml to set email credentials to relevant variables.
 */
public static void readXMLforEmailCredentials()
        throws ESBMailTransportIntegrationTestException {
    try {

        AutomationContext automationContext = new AutomationContext();
        automationContext.getConfigurationNodeList(EMAIL_CREDENTIAL_PARENT_XPATH);

        sender = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_SENDER_XPATH);
        senderPassword = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_SENDER_PASSWORD_XPATH).toCharArray();
        receiver = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_RECEIVER_XPATH);
        receiverPassword = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_RECEIVER_PASSWORD_XPATH).toCharArray();
        domain = automationContext.getConfigurationValue(EMAIL_CREDENTIAL_DOMAIN_XPATH);

    } catch (XPathExpressionException e) {
        log.error("Error when getting value from automation.xml ", e);
        throw new ESBMailTransportIntegrationTestException("Error when getting value from automation.xml ", e);
    }
}
 
Example 6
Source File: RDBMSConnectionManager.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Get database connection.
 * @return database connection
 * @throws XPathExpressionException
 * @throws ClassNotFoundException
 * @throws SQLException
 */
public static Connection getConnection() throws XPathExpressionException, ClassNotFoundException, SQLException {

    AutomationContext automationContext = new AutomationContext("MB_Cluster", TestUserMode.SUPER_TENANT_ADMIN);

    String url = automationContext.getConfigurationValue("//datasources/datasource[@name=\'mbCluster\']/url");
    String username = automationContext.getConfigurationValue
            ("//datasources/datasource[@name=\'mbCluster\']/username");
    String password = automationContext.getConfigurationValue
            ("//datasources/datasource[@name=\'mbCluster\']/password");
    String driverName = automationContext.getConfigurationValue
            ("//datasources/datasource[@name=\'mbCluster\']/driverClassName");

    Class.forName(driverName);
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
}
 
Example 7
Source File: StoreAndForwardWithEmptyMessageBodyTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public void init() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    String dbPassword = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    String dbUser = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    String databaseName =
            System.getProperty("basedir") + File.separator + "target" + File.separator + "testdb_store"
                    + new Random().nextInt();
    JDBC_URL = JDBC_URL + databaseName + ";DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE";
    h2DatabaseManager = new H2DataBaseManager(JDBC_URL, dbUser, dbPassword);
    h2DatabaseManager.executeUpdate(
            "CREATE TABLE IF NOT EXISTS JDBC_MESSAGE_STORE(\n" + "indexId BIGINT(20) NOT NULL AUTO_INCREMENT,\n"
                    + "msg_id VARCHAR(200) NOT NULL ,\n" + "message BLOB NOT NULL,\n" + "PRIMARY KEY ( indexId )\n"
                    + ")");
    carbonLogReader = new CarbonLogReader();
}
 
Example 8
Source File: JDBCMessageProcessorTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void init() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    DATASOURCE_NAME = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_NAME);
    DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    JDBC_DRIVER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DRIVER_CLASS_NAME);
    serverConfigurationManager = new ServerConfigurationManager(context);
    copyJDBCDriverToClassPath();
    mySqlDatabaseManager = new MySqlDatabaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    mySqlDatabaseManager.executeUpdate("DROP DATABASE IF EXISTS WSO2SampleDBForAutomation");

    super.init();

}
 
Example 9
Source File: DBReportMediatorTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    String DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    String DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    String JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    String databasePath = getDBPath("testdb_dbreport");

    JDBC_URL = JDBC_URL + databasePath + ";AUTO_SERVER=TRUE";
    h2DataBaseManager = new H2DataBaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    h2DataBaseManager.executeUpdate("CREATE TABLE company(price double, name varchar(20))");
    super.init();
}
 
Example 10
Source File: DBLookupMediatorTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    String DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    String JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    String DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    String databasePath = getDBPath("testdb_dblookup");
    JDBC_URL = JDBC_URL + databasePath + ";AUTO_SERVER=TRUE";
    h2DatabaseManager = new H2DataBaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    h2DatabaseManager.executeUpdate("CREATE TABLE IF NOT EXISTS company(price double, name varchar(20))");
    super.init();
}
 
Example 11
Source File: IOTServerExtension.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Override
public void initiate() {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, IOT_CORE_PORT_OFFSET);
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment =
                automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);

    } catch (XPathExpressionException e) {
        throw new RuntimeException("Error while initiating test environment", e);
    }
}
 
Example 12
Source File: AnalyticsServerExtension.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Override
public void initiate() {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, ANALYTICS_PORT_OFFSET);
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment =
                automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);

    } catch (XPathExpressionException e) {
        throw new RuntimeException("Error while initiating test environment", e);
    }
}
 
Example 13
Source File: BrokerServerExtension.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Override
public void initiate() throws AutomationFrameworkException {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "3");
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment =
                automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);

    } catch (XPathExpressionException e) {
        handleException("Error while initiating test environment", e);
    }
}
 
Example 14
Source File: DBlookupMediatorTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    AutomationContext automationContext = new AutomationContext();
    DB_PASSWORD = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_PASSWORD);
    JDBC_URL = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_URL);
    DB_USER = automationContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DB_USER_NAME);
    String databaseName = System.getProperty("basedir") + File.separator + "target" + File.separator +
            "testdb_dblookp" + new Random().nextInt();
    JDBC_URL = JDBC_URL + databaseName + ";AUTO_SERVER=TRUE";
    h2DatabaseManager = new H2DataBaseManager(JDBC_URL, DB_USER, DB_PASSWORD);
    h2DatabaseManager.executeUpdate("CREATE TABLE IF NOT EXISTS company(price double, name varchar(20))");
    super.init();
}
 
Example 15
Source File: PPaaSIntegrationTest.java    From product-private-paas with Apache License 2.0 5 votes vote down vote up
public PPaaSIntegrationTest() throws Exception {
    ppaasAutomationCtx = new AutomationContext("PPAAS", "ppaas-001", TestUserMode.SUPER_TENANT_ADMIN);
    adminUsername = ppaasAutomationCtx
            .getConfigurationValue("/automation/userManagement/superTenant/tenant/admin/user/userName");
    adminPassword = ppaasAutomationCtx
            .getConfigurationValue("/automation/userManagement/superTenant/tenant/admin/user/password");
    restClient = new RestClient(ppaasAutomationCtx.getContextUrls().getWebAppURL(),
            ppaasAutomationCtx.getContextUrls().getWebAppURLHttps(), adminUsername, adminPassword);
    String mockIaaSEndpoint = ppaasAutomationCtx.getContextUrls().getWebAppURL() + "/mock-iaas/api";
    mockIaasApiClient = new IntegrationMockClient(mockIaaSEndpoint);
    log.info("Mock IaaS endpoint URL: " + mockIaaSEndpoint);
}
 
Example 16
Source File: BrokerServerExtension.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@Override
public void initiate() {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, BROKER_PORT_OFFSET);
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment =
                automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);

    } catch (XPathExpressionException e) {
        throw new RuntimeException("Error while initiating test environment", e);
    }
}
 
Example 17
Source File: RabbitMQTestUtils.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public static RabbitMQServer getRabbitMQServerInstance()
        throws XPathExpressionException, RabbitMQTransportException {
    AutomationContext automationContext = new AutomationContext();
    String rabbitMQHome = automationContext.getConfigurationValue(RABBITMQ_HOME_XPATH);
    return new RabbitMQServer(rabbitMQHome);
}
 
Example 18
Source File: RabbitMQTestUtils.java    From product-ei with Apache License 2.0 4 votes vote down vote up
public static RabbitMQServer getRabbitMQServerInstance() throws XPathExpressionException, RabbitMQTransportException {
    AutomationContext automationContext = new AutomationContext();
    String rabbitMQHome = automationContext.getConfigurationValue(RABBITMQ_HOME_XPATH);
    return new RabbitMQServer(rabbitMQHome);
}
 
Example 19
Source File: RabbitMQTestUtils.java    From product-ei with Apache License 2.0 2 votes vote down vote up
/**
 * Helper method to get rabbitMQ home path
 *
 * @return rabbitMQHome
 * @throws XPathExpressionException
 * @throws RabbitMQTransportException
 */
public static String getRabbitmqHomePath() throws XPathExpressionException, RabbitMQTransportException {
    AutomationContext automationContext = new AutomationContext();
    String rabbitMQHome = automationContext.getConfigurationValue(RABBITMQ_HOME_XPATH);
    return rabbitMQHome;
}
 
Example 20
Source File: RabbitMQTestUtils.java    From micro-integrator with Apache License 2.0 2 votes vote down vote up
/**
 * Helper method to get rabbitMQ home path
 *
 * @return rabbitMQHome
 * @throws XPathExpressionException
 * @throws RabbitMQTransportException
 */
public static String getRabbitmqHomePath() throws XPathExpressionException, RabbitMQTransportException {
    AutomationContext automationContext = new AutomationContext();
    String rabbitMQHome = automationContext.getConfigurationValue(RABBITMQ_HOME_XPATH);
    return rabbitMQHome;
}