Java Code Examples for org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager

The following examples show how to use org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager. These examples are extracted from open source projects. 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
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {
    super.init();
    serverConfigurationManager = new ServerConfigurationManager(dssContext);
    serverConfigurationManager.applyConfiguration(new File(
            getResourceLocation() + File.separator + "config" + File.separator + "CARBON1352" + File.separator
                    + "axis2.xml"));
    List<File> sqlFileLis = new ArrayList<>();
    sqlFileLis.add(selectSqlFile("CreateTables.sql"));
    sqlFileLis.add(selectSqlFile("Offices.sql"));
    client = new SimpleHttpClient();
    headers = new HashMap<>();
    super.init();
    deployService(serviceName, createArtifact(
            getResourceLocation() + File.separator + "dbs" + File.separator + "rdbms" + File.separator + "h2"
                    + File.separator + "H2JsonSecureServiceTest.dbs", sqlFileLis));
    serviceEndPoint = getServiceUrlHttps("H2JsonSecureServiceTest") + "/";
}
 
Example 2
Source Project: micro-integrator   Source File: EventingSampleTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true, enabled = false)
public void initialize() throws Exception {
    super.init();
    String resourceFileLocation;
    feedURL = "https://mail.google.com/mail/feed/atom";
    mailCountBeforeTestStart = getMailCount(feedURL);
    modifiedTime = getModifiedTime(feedURL);
    eventingSampleStub = new EventingSampleStub(serverEpr);
    serverEpr = getServiceUrlHttp(serviceName);

    //        productCode = "code" + System.currentTimeMillis();
    productCode = "999";

    updateAxis2_ClientXML();
    new ServerConfigurationManager("DSS", TestUserMode.SUPER_TENANT_ADMIN).restartGracefully();

    super.init();
    resourceFileLocation = getResourceLocation();
    deployService(serviceName, new DataHandler(
            new URL("file:///" + resourceFileLocation + File.separator + "samples" + File.separator + "dbs"
                    + File.separator + "rdbms" + File.separator + "EventingSample.dbs")));
    log.info(serviceName + " uploaded");
}
 
Example 3
Source Project: product-ei   Source File: HumanTaskCoordinationTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Setting up Server and Apply new Configuration Files.
 *
 * @throws Exception
 */
@BeforeTest(alwaysRun = true)
public void setupTest() throws Exception {
	log.info("Initializing HumanTaskCoordination Test Case");
	init();
	requestSender = new RequestSender();
	userManagementClient = new UserManagementClient(backEndUrl, sessionCookie);
	log.info("Deploy ClaimsApprovalProcess and ClaimsApprovalTask artifacts");
	deployArtifact();
	log.info("Adding Users and Roles");
	addRoles();
	log.info("Enable HumanTask coordination and restarting server.");
	serverConfigurationManager = new ServerConfigurationManager(bpsServer);
	applyCoordinationConfig();
	setupTestClients();
}
 
Example 4
@BeforeClass
public void envSetup() throws Exception {
    init();
    final String artifactLocation = FrameworkPathUtil.getSystemResourceLocation() + File
            .separator
                                    + BPMNTestConstants.DIR_ARTIFACTS + File.separator
                                    + BPMNTestConstants.DIR_BPMN + File.separator
                                    + "testArtifactid-1.0.jar";

    ServerConfigurationManager Loader = new ServerConfigurationManager(bpsServer);
    File javaArtifact = new File(artifactLocation);
    Loader.copyToComponentLib(javaArtifact);
    Loader.restartForcefully();

    //reinitialising, as session cookies and other configuration which expired during restart is
    // needs to be reset
    init();
}
 
Example 5
Source Project: product-ei   Source File: DLCQueueTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the test case and changes the number of delivery attempts of a message to 1.
 *
 * @throws AutomationUtilException
 * @throws XPathExpressionException
 * @throws MalformedURLException
 */
@BeforeClass()
public void initialize() throws AutomationUtilException, XPathExpressionException, IOException,
                                                                                            ConfigurationException {
    super.init();

    // Updating the redelivery attempts to 1 to speed up the test case.
    super.serverManager = new ServerConfigurationManager(mbServer);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2"
                                        + File.separator + "broker" + File.separator + "conf" + File.separator
                                        + "broker.xml";
    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);
    // Changing "maximumRedeliveryAttempts" value to "1" in broker.xml
    configurationEditor.updateProperty(AndesConfiguration.TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "1");
    // Restarting server
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 6
Source Project: product-ei   Source File: LZ4UITestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Enabling compression to verify decompression and reducing the maximum content chunk size, to create more content chunks
 * from compressed content, to check chunk data retrieval.
 * Increase the managementConsole/maximumMessageDisplayLength to match the large message size that is tested.
 *
 * @throws XPathExpressionException
 * @throws java.io.IOException
 * @throws org.apache.commons.configuration.ConfigurationException
 * @throws org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException
 */
@BeforeClass
public void setupConfiguration() throws AutomationUtilException, XPathExpressionException, IOException,
        ConfigurationException {

    super.serverManager = new ServerConfigurationManager(mbServer);

    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2"
                                        + File.separator + "broker" + File.separator + "conf" + File.separator
                                        + "broker.xml";

    log.info("DEFAULT_MB_CONFIG_PATH : " + defaultMBConfigurationPath);

    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

    configurationEditor.updateProperty(AndesConfiguration
            .MANAGEMENT_CONSOLE_MAX_DISPLAY_LENGTH_FOR_MESSAGE_CONTENT, String.valueOf(MESSAGE_SIZE_IN_BYTES + 1));
    configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_ALLOW_COMPRESSION, "true");
    configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_MAX_CONTENT_CHUNK_SIZE, "100");

    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 7
Source Project: product-ei   Source File: PurgeMessagesTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set values TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS = 1 and
 * ANDES_ACK_WAIT_TIMEOUT_PROPERTY = 1
 * so that the time taken for the massages to get moved into DLC is at a minimum
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException,
        ConfigurationException, SAXException, XMLStreamException, LoginAuthenticationExceptionException,
        URISyntaxException, AutomationUtilException {
    ;
    super.serverManager = new ServerConfigurationManager(automationContext);

    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() +
            File.separator + "wso2" + File.separator + "broker" + File.separator + "conf" + File.separator + "broker.xml";

    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

    //Set values TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS = 1 and
    //ANDES_ACK_WAIT_TIMEOUT_PROPERTY = 1
    //so that the time taken for the massages to get moved into DLC is at a minimum
    configurationEditor.updateProperty(AndesConfiguration
            .TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "1");
    System.setProperty(AndesClientConstants.ANDES_ACK_WAIT_TIMEOUT_PROPERTY, "1");

    //andesAdminClient.deleteQueue(DLCQueueUtils.identifyTenantInformationAndGenerateDLCString(TEST_QUEUE_PURGE));
    //We should restart the server witht he new configuration values
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 8
/**
 * Initializing test case
 *
 * @throws XPathExpressionException
 */
@BeforeClass(alwaysRun = true)
public void init() throws XPathExpressionException, IOException, AutomationUtilException, ConfigurationException {
    super.init(TestUserMode.SUPER_TENANT_USER);

    // Updating the redelivery attempts to 1 to speed up the test case.
    super.serverManager = new ServerConfigurationManager(automationContext);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2" +
                                        File.separator + "broker" + File.separator + "conf" + File.separator +
                                        "broker.xml";
    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

    // Changing "maximumRedeliveryAttempts" value to "1" in broker.xml
    configurationEditor.updateProperty(AndesConfiguration.TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "1");
    // Restarting server
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);

    // Get current "AndesAckWaitTimeOut" system property.
    defaultAndesAckWaitTimeOut = System.getProperty(AndesClientConstants.ANDES_ACK_WAIT_TIMEOUT_PROPERTY);

    // Setting system property "AndesAckWaitTimeOut" for andes
    System.setProperty(AndesClientConstants.ANDES_ACK_WAIT_TIMEOUT_PROPERTY, "3000");
}
 
Example 9
/**
 * Set topicMessageDeliveryStrategy to DISCARD_ALLOWED so that broker will simulate an acknowledgement
 * if some subscribers are slow to acknowledge the message
 *
 * @throws XPathExpressionException
 * @throws IOException
 * @throws ConfigurationException
 * @throws SAXException
 * @throws XMLStreamException
 * @throws LoginAuthenticationExceptionException
 * @throws URISyntaxException
 * @throws AutomationUtilException
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException,
		ConfigurationException, SAXException, XMLStreamException, LoginAuthenticationExceptionException,
		URISyntaxException, AutomationUtilException {

	super.serverManager = new ServerConfigurationManager(automationContext);
	String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() +
										File.separator + "wso2" + File.separator + "broker" + File.separator +
										"conf" + File.separator + "broker.xml";

	ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

	configurationEditor.updateProperty(AndesConfiguration
			.PERFORMANCE_TUNING_TOPIC_MESSAGE_DELIVERY_STRATEGY, "DISCARD_ALLOWED");

	configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_ACK_HANDLING_MAX_UNACKED_MESSAGES,
			"200");

	configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);

}
 
Example 10
/**
 * Prepare environment for durable topic subscription with same client Id tests
 *
 * @throws Exception
 */
@BeforeClass
public void prepare() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_USER);

    super.serverManager = new ServerConfigurationManager(automationContext);

    // Replace the broker.xml with the allowSharedTopicSubscriptions configuration enabled under amqp
    // and restarts the server.
    super.serverManager.applyConfiguration(new File(FrameworkPathUtil.getSystemResourceLocation() + File.separator +
            "artifacts" + File.separator + "mb" + File.separator + "config" + File.separator +
            "allowSharedTopicSubscriptionsConfig" + File.separator + "broker.xml"),
            new File(ServerConfigurationManager.getCarbonHome() + File.separator + "wso2" +
                     File.separator + "broker" + File.separator + "conf" + File.separator + "broker.xml"),
                                           true, true);

}
 
Example 11
Source Project: product-ei   Source File: LZ4CompressionTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set allowCompression to true so that broker will compress messages before storing into the database, and
 * reduce maximum content chunk size to 100 from default value (65500); to create more content chunks
 * from compressed content, to check chunk data retrieval.
 *
 * @throws XPathExpressionException
 * @throws java.io.IOException
 * @throws org.apache.commons.configuration.ConfigurationException
 * @throws org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException, ConfigurationException,
        AutomationUtilException {

    super.serverManager = new ServerConfigurationManager(automationContext);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2" +
                                        File.separator + "broker" + File.separator + "conf" + File.separator +
                                        "broker.xml";

    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

    configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_ALLOW_COMPRESSION, "true");
    configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_MAX_CONTENT_CHUNK_SIZE, "100");

    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 12
/**
 * Set topicMessageDeliveryStrategy to SLOWEST_SUB_RATE_TOPIC so that broker will deliver the messages
 *
 * @throws XPathExpressionException
 * @throws java.io.IOException
 * @throws org.apache.commons.configuration.ConfigurationException
 * @throws org.xml.sax.SAXException
 * @throws javax.xml.stream.XMLStreamException
 * @throws org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException
 * @throws java.net.URISyntaxException
 * @throws org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException,
		ConfigurationException, SAXException, XMLStreamException, LoginAuthenticationExceptionException,
		URISyntaxException, AutomationUtilException {

	super.serverManager = new ServerConfigurationManager(automationContext);
	String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2" +
										File.separator + "broker" + File.separator + "conf" + File.separator +
										"broker.xml";

	ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

	configurationEditor.updateProperty(AndesConfiguration
			.PERFORMANCE_TUNING_TOPIC_MESSAGE_DELIVERY_STRATEGY, "SLOWEST_SUB_RATE");

	//reduce this to 200 from default value (1000) so that delivery strategy is effective fast
	configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_ACK_HANDLING_MAX_UNACKED_MESSAGES,
			"2");

	configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);

}
 
Example 13
Source Project: product-ei   Source File: DLCMessageExpiryTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set topicMessageDeliveryStrategy to DISCARD_ALLOWED so that broker will simulate an acknowledgement
 * if some subscribers are slow to acknowledge the message
 *
 * @throws XPathExpressionException
 * @throws IOException
 * @throws ConfigurationException
 * @throws SAXException
 * @throws XMLStreamException
 * @throws LoginAuthenticationExceptionException
 * @throws URISyntaxException
 * @throws AutomationUtilException
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException,
        ConfigurationException, SAXException, XMLStreamException, LoginAuthenticationExceptionException,
        URISyntaxException, AutomationUtilException {
    super.serverManager = new ServerConfigurationManager(automationContext);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() +
                                        File.separator + "wso2" + File.separator + "broker" + File.separator +
                                        "conf" + File.separator + "broker.xml";
    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);
    configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_PRE_DELIVERY_EXPIRY_DELETION_INTERVAL,
            "60");
    configurationEditor.updateProperty(AndesConfiguration
            .PERFORMANCE_TUNING_PERIODIC_EXPIRY_MESSAGE_DELETION_INTERVAL, "60");
    configurationEditor.updateProperty(AndesConfiguration.TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "1");
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
    // Get current "AndesAckWaitTimeOut" system property.
    defaultAndesAckWaitTimeOut = System.getProperty(AndesClientConstants.ANDES_ACK_WAIT_TIMEOUT_PROPERTY);
    // Setting system property "AndesAckWaitTimeOut" for andes
    System.setProperty(AndesClientConstants.ANDES_ACK_WAIT_TIMEOUT_PROPERTY, "3000");
}
 
Example 14
Source Project: product-ei   Source File: MessageContentTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set allowCompression to false, so that broker won't compress messages
 *
 * @throws XPathExpressionException
 * @throws java.io.IOException
 * @throws org.apache.commons.configuration.ConfigurationException
 * @throws org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException, ConfigurationException,
        AutomationUtilException {

    super.serverManager = new ServerConfigurationManager(automationContext);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2" +
                                        File.separator + "broker" + File.separator + "conf" + File.separator +
                                        "broker.xml";

    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

    configurationEditor.updateProperty(AndesConfiguration.PERFORMANCE_TUNING_ALLOW_COMPRESSION, "false");

    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 15
Source Project: product-ei   Source File: AMQPSessionRecoverTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set values TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS = 3 and
 * ANDES_ACK_WAIT_TIMEOUT_PROPERTY = 10000
 * so that once a message is seen by application for 3 times it goes to DLC
 * and ack timeout is out of the equation
 */
@BeforeClass
public void setupConfiguration() throws XPathExpressionException, IOException,
        ConfigurationException, SAXException, XMLStreamException, LoginAuthenticationExceptionException,
        URISyntaxException, AutomationUtilException {

    super.serverManager = new ServerConfigurationManager(automationContext);

    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() +
            File.separator + "wso2" + File.separator + "broker" + File.separator + "conf" + File.separator + "broker.xml";

    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);

    configurationEditor.updateProperty(AndesConfiguration
            .TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "3");
    System.setProperty(AndesClientConstants.ANDES_ACK_WAIT_TIMEOUT_PROPERTY, "10000");

    //We should restart the server with the new configuration values
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 16
Source Project: product-ei   Source File: CARBON15261JsonFormatterTest.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    serverConfigurationManager = new ServerConfigurationManager(dssContext);
    serverConfigurationManager.applyConfiguration(new File(getResourceLocation() + File.separator + "config" +
                                                           File.separator + "CARBON1352" + File.separator +
                                                           "axis2.xml"));
    List<File> sqlFileLis = new ArrayList<>();
    sqlFileLis.add(selectSqlFile("CreateTables.sql"));
    sqlFileLis.add(selectSqlFile("Offices.sql"));
    client = new SimpleHttpClient();
    headers = new HashMap<>();
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    deployService(serviceName, createArtifact(getResourceLocation() + File.separator + "dbs" + File.separator +
                                              "rdbms" + File.separator + "h2" + File.separator +
                                              "H2JsonSecureServiceTest.dbs", sqlFileLis));
    serviceEndPoint = getServiceUrlHttps("H2JsonSecureServiceTest") + "/";
}
 
Example 17
Source Project: product-ei   Source File: EventingSampleTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true, enabled = false)
    public void initialize() throws Exception {
        super.init(userMode);
        String resourceFileLocation;
        feedURL = "https://mail.google.com/mail/feed/atom";
        mailCountBeforeTestStart = getMailCount(feedURL);
        modifiedTime = getModifiedTime(feedURL);
        eventingSampleStub = new EventingSampleStub(serverEpr);
        serverEpr = getServiceUrlHttp(serviceName);

//        productCode = "code" + System.currentTimeMillis();
        productCode = "999";

        updateAxis2_ClientXML();
        new ServerConfigurationManager("DSS", TestUserMode.SUPER_TENANT_ADMIN).restartGracefully();

        super.init();
        resourceFileLocation = getResourceLocation();
        deployService(serviceName,
                      new DataHandler(new URL("file:///" + resourceFileLocation +
                                              File.separator + "samples" + File.separator +
                                              "dbs" + File.separator + "rdbms" + File.separator +
                                              "EventingSample.dbs")));
        log.info(serviceName + " uploaded");
    }
 
Example 18
Source Project: product-ei   Source File: XssCsrfSkipPatternsTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Configures ESB as required for the test case.
 *
 * @throws Exception if an error occurs while configuring ESB
 */
private void changeESBConfiguration() throws Exception {

    String carbonHome = CarbonUtils.getCarbonHome();
    carbonXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "carbon.xml");
    File configuredCarbonXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "carbon-security.xml");

    catalinaXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "tomcat"
            + File.separator + "catalina-server.xml");

    File configuredCatalinaXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "catalina-server-security.xml");

    scm = new ServerConfigurationManager(context);
    scm.applyConfigurationWithoutRestart(configuredCarbonXML, carbonXML, true);
    scm.applyConfigurationWithoutRestart(configuredCatalinaXML, catalinaXML, true);
    scm.restartGracefully();
    super.init();
}
 
Example 19
Source Project: product-ei   Source File: XssCsrfSkipPatternsTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Resets the configuration changes done to what was there before.
 *
 * @throws Exception if an error occurs while applying previous configurations
 */
private void resetESBConfiguration() throws Exception {

    String carbonHome = CarbonUtils.getCarbonHome();
    carbonXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "carbon.xml");
    File configuredCarbonXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "carbon-default.xml");

    catalinaXML = new File(
            carbonHome + File.separator + "conf" + File.separator + "tomcat"
            + File.separator + "catalina-server.xml");
    File configuredCatalinaXML = new File(
            getESBResourceLocation() + File.separator + "XssCsrfSkipPatterns" + File.separator
            + "catalina-server-default.xml");

    scm = new ServerConfigurationManager(context);
    scm.applyConfigurationWithoutRestart(configuredCarbonXML, carbonXML, true);
    scm.applyConfigurationWithoutRestart(configuredCatalinaXML, catalinaXML, true);
    scm.restartGracefully();
}
 
Example 20
Source Project: product-cep   Source File: HTTPXMLMessageTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init()
        throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    serverManager = new ServerConfigurationManager(cepServer);

    try {
        String warFilePath = FrameworkPathUtil.getSystemResourceLocation() +
                             "artifacts" + File.separator + "CEP" + File.separator + "war"
                             + File.separator;

        webAppDirectoryPath = FrameworkPathUtil.getCarbonHome() + File.separator + "repository" + File.separator +
                              "deployment" + File.separator + "server" + File.separator + "webapps" + File.separator;
        FileManager.copyResourceToFileSystem(warFilePath + webAppFileName, webAppDirectoryPath, webAppFileName);
        Thread.sleep(5000);
    } catch (Exception e) {
        throw new RemoteException("Exception caught when deploying the war file into CEP server", e);
    }

    String loggedInSessionCookie = new LoginLogoutClient(cepServer).login();
    eventProcessorAdminServiceClient = configurationUtil.getEventProcessorAdminServiceClient(backendURL, loggedInSessionCookie);
    eventStreamManagerAdminServiceClient = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL, loggedInSessionCookie);
    eventReceiverAdminServiceClient = configurationUtil.getEventReceiverAdminServiceClient(backendURL, loggedInSessionCookie);
    eventPublisherAdminServiceClient = configurationUtil.getEventPublisherAdminServiceClient(backendURL, loggedInSessionCookie);
}
 
Example 21
Source Project: product-cep   Source File: CarbonMetricsTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    serverManager = new ServerConfigurationManager(cepServer);
    serverManager.applyConfiguration(
            new File(getTestArtifactLocation() + CEPIntegrationTestConstants.RELATIVE_PATH_TO_TEST_ARTIFACTS +
                    ARTIFACTS_FOLDER + File.separator + "carbon.xml"),
            new File(ServerConfigurationManager.getCarbonHome() + File.separator + "repository" + File.separator +
                    "conf" + File.separator + "carbon.xml"),
            true,
            true);

    sessionCookie = getSessionCookie();
    eventSimulatorAdminServiceClient = configurationUtil
            .getEventSimulatorAdminServiceClient(backendURL, sessionCookie);
    eventStreamManagerAdminServiceClient = configurationUtil
            .getEventStreamManagerAdminServiceClient(backendURL, sessionCookie);
    eventPublisherAdminServiceClient = configurationUtil
            .getEventPublisherAdminServiceClient(backendURL, sessionCookie);
    eventReceiverAdminServiceClient = configurationUtil
            .getEventReceiverAdminServiceClient(backendURL, sessionCookie);
    eventProcessorAdminServiceClient = configurationUtil
            .getEventProcessorAdminServiceClient(backendURL, sessionCookie);
}
 
Example 22
Source Project: product-cep   Source File: Wso2EventTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init()
        throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    try {
        serverManager = new ServerConfigurationManager(cepServer);
    } catch (MalformedURLException e) {
        throw new RemoteException("Malformed URL exception thrown when initializing ActiveMQ broker", e);
    }

    String loggedInSessionCookie = getSessionCookie();

    eventReceiverAdminServiceClient = configurationUtil.getEventReceiverAdminServiceClient(backendURL,
                                                                                           loggedInSessionCookie);
    eventStreamManagerAdminServiceClient = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL,
                                                                                                     loggedInSessionCookie);
    eventPublisherAdminServiceClient = configurationUtil.getEventPublisherAdminServiceClient(backendURL,
                                                                                             loggedInSessionCookie);
}
 
Example 23
Source Project: product-cep   Source File: StormManagerServiceTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    log.info("Initializing CEP server to act as storm manager");

    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    serverConfigManager = new ServerConfigurationManager(cepServer);

    log.info("Replacing " + EVENT_PROCESSING_FILE);
    String eventProcessingFileLocation = RESOURCE_LOCATION + File.separator + EVENT_PROCESSING_FILE;
    String cepEventProcessorFileLocation = CARBON_HOME + File.separator + "repository" + File.separator
            + "conf" + File.separator + EVENT_PROCESSING_FILE;
    serverConfigManager.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation), new File(cepEventProcessorFileLocation), true);

    log.info("Replacing " + AXIS2_XML_FILE);
    String axis2FileLocation = RESOURCE_LOCATION + File.separator + AXIS2_XML_FILE;
    String cepAxis2FileLocation = CARBON_HOME + File.separator + "repository" + File.separator + "conf"
            + File.separator + "axis2" + File.separator + AXIS2_XML_FILE;
    serverConfigManager.applyConfigurationWithoutRestart(new File(axis2FileLocation), new File(cepAxis2FileLocation), true);

    log.info("Restarting CEP server");
    serverConfigManager.restartGracefully();
    // Waiting for the server to restart
    Thread.sleep(5000);

    log.info("Initialization completed");
}
 
Example 24
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init(userMode);
    genericRestClient = new GenericRestClient();
    publisherUrl = automationContext.getContextUrls()
            .getSecureServiceUrl().replace("services", "publisher/apis");
    manageGenericArtifactAdminServiceClient =
            new ManageGenericArtifactAdminServiceClient(backendURL, sessionCookie);
    lifeCycleAdminServiceClient = new LifeCycleManagementClient(backendURL, sessionCookie);
    resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, sessionCookie);
    serverConfigurationManager = new ServerConfigurationManager(automationContext);
    resourcePath = FrameworkPathUtil.getSystemResourceLocation()
                   + "artifacts" + File.separator + "GREG" + File.separator;
    resourceRegistryPath = "/_system/governance/repository/components" +
                           "/org.wso2.carbon.governance/types/updated-serviceLC.rxt";
    lifeCycleName = "ServiceLifeCycleLC2";
    restServiceResourcePath = "/_system/governance/trunk/restservices/1.0.0/testservice1234";
}
 
Example 25
@BeforeClass(alwaysRun = true)
public void serviceDeployment() throws Exception {

    super.init();
    List<File> sqlFileLis = new ArrayList<File>();
    sqlFileLis.add(selectSqlFile("CreateEmailUsersTable.sql"));
    deployService(serviceName, createArtifact(
            getResourceLocation() + File.separator + "samples" + File.separator + "dbs" + File.separator + "rdbms"
                    + File.separator + serviceName + ".dbs", sqlFileLis));

    backendUrl = dssContext.getContextUrls().getBackEndUrl();

    /* login to the server as super user and add user with email user name for the test case */
    userManagementClient = new UserManagementClient(backendUrl, sessionCookie);

    userManagementClient.addRole("sampleRole", new String[] {}, new String[] { "admin" });
    userManagementClient
            .addUser("[email protected]", "test123", new String[] { "sampleRole" }, "emailUserProfile");

    serverConfigurationManager = new ServerConfigurationManager(dssContext);
    serverConfigurationManager.copyToComponentLib(new File(
            getResourceLocation() + File.separator + "jar" + File.separator + "msgContextHandler-1.0.0.jar"));

    String carbonHome = System.getProperty("carbon.home");
    File sourceFile = new File(
            getResourceLocation() + File.separator + "serverConfigs" + File.separator + "axis2.xml");
    File destinationFile = new File(
            carbonHome + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2.xml");

    serverConfigurationManager
            .applyConfiguration(sourceFile, destinationFile);//this will restart the server as well
    LoginLogoutClient loginLogoutClient = new LoginLogoutClient(dssContext);
    sessionCookie = loginLogoutClient.login();

    serviceEndPoint = getServiceUrlHttp(serviceName);

}
 
Example 26
Source Project: product-ei   Source File: HumanTaskCoordinationTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Setup
 *
 * @throws Exception
 */
private void setupTestClients() throws Exception {
	init();
	requestSender.waitForProcessDeployment(backEndUrl + HumanTaskTestConstants.CLAIM_APPROVAL_PROCESS_SERVICE);
	requestSender.waitForProcessDeployment(backEndUrl + HumanTaskTestConstants.CLAIM_SERVICE);
	log.info("BPEL and Humantask services are up and running");
	// Need to re-initialize since we have restarted the server
	bpelPackageManagementClient = new BpelPackageManagementClient(backEndUrl, sessionCookie);
	humanTaskPackageManagementClient = new HumanTaskPackageManagementClient(backEndUrl, sessionCookie);
	instanceManagementClient = new BpelInstanceManagementClient(backEndUrl, sessionCookie);
	log.info("Server setting up completed ...!!!");
	serverConfigurationManager = new ServerConfigurationManager(bpsServer);

	//initialize HT Client API for Clerk1 and manager1 user
	AutomationContext clerk1AutomationContext =
			new AutomationContext("BPS", "bpsServerInstance0001", FrameworkConstants.SUPER_TENANT_KEY,
			                      HumanTaskTestConstants.CLERK1_USER);
	LoginLogoutClient clerk1LoginLogoutClient = new LoginLogoutClient(clerk1AutomationContext);
	String clerk1SessionCookie = clerk1LoginLogoutClient.login();
	clerk1HumanTaskClientApiClient = new HumanTaskClientApiClient(backEndUrl, clerk1SessionCookie);

	AutomationContext manager1AutomationContext =
			new AutomationContext("BPS", "bpsServerInstance0001", FrameworkConstants.SUPER_TENANT_KEY,
			                      HumanTaskTestConstants.MANAGER1_USER);
	LoginLogoutClient manager1LoginLogoutClient = new LoginLogoutClient(manager1AutomationContext);
	String manager1SessionCookie = manager1LoginLogoutClient.login();
	manager1HumanTaskClientApiClient = new HumanTaskClientApiClient(backEndUrl, manager1SessionCookie);

}
 
Example 27
Source Project: product-ei   Source File: DLCReRouteAllTestCase.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes test. This class will initialize web driver and
 * restart server with altered broker.xml
 *
 * @throws AutomationUtilException
 * @throws XPathExpressionException
 * @throws IOException
 */
@BeforeClass()
public void initialize() throws AutomationUtilException, XPathExpressionException, IOException, ConfigurationException {
    super.init();

    super.serverManager = new ServerConfigurationManager(mbServer);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2" +
                                        File.separator + "broker" + File.separator + "conf" + File.separator +
                                        "broker.xml";
    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);
    // Changing "maximumRedeliveryAttempts" value to "2" in broker.xml
    configurationEditor.updateProperty(AndesConfiguration.TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "1");
    // Restarting server
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 28
Source Project: product-ei   Source File: DLCDurableTopicTestCase.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes test. This class will initialize web driver and
 * restart server with altered broker.xml
 *
 * @throws AutomationUtilException
 * @throws XPathExpressionException
 * @throws IOException
 */
@BeforeClass()
public void initialize() throws AutomationUtilException, XPathExpressionException, IOException, ConfigurationException {
    super.init();

    super.serverManager = new ServerConfigurationManager(mbServer);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2"
                                        + File.separator + "broker" + File.separator + "conf" + File.separator
                                        + "broker.xml";
    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);
    // Changing "maximumRedeliveryAttempts" value to "2" in broker.xml
    configurationEditor.updateProperty(AndesConfiguration.TRANSPORTS_AMQP_MAXIMUM_REDELIVERY_ATTEMPTS, "2");
    // Restarting server
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 29
/**
 * Initializes the test case and modifying broker.xml to allow shared subscriptions.
 *
 * @throws AutomationUtilException
 * @throws XPathExpressionException
 * @throws MalformedURLException
 */
@BeforeClass()
public void initialize() throws Exception {
    super.init();

    super.serverManager = new ServerConfigurationManager(mbServer);
    String defaultMBConfigurationPath = ServerConfigurationManager.getCarbonHome() + File.separator + "wso2"
                                        + File.separator + "broker" + File.separator + "conf" + File.separator
                                        + "broker.xml";
    ConfigurationEditor configurationEditor = new ConfigurationEditor(defaultMBConfigurationPath);
    // Changing "allowSharedSubscription" value to "true" in broker.xml
    configurationEditor.updateProperty(AndesConfiguration.ALLOW_SHARED_SHARED_SUBSCRIBERS, "true");
    // Restarting server
    configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);
}
 
Example 30
Source Project: product-ei   Source File: MBIntegrationBaseTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Restart the testing MB server in In-Memory H2 database mode by applying In-Memory database configurations
 * in andes-virtualhosts-H2-mem.xml file.
 *
 * @throws Exception
 */
protected void restartServerWithH2MemMode() throws Exception {
    serverManager = new ServerConfigurationManager(automationContext);

    // Replace the broker.xml with the new configuration and restarts the server.
    serverManager.applyConfiguration(new File(FrameworkPathUtil.getSystemResourceLocation() + File.separator +
                    "artifacts" + File.separator + "mb" + File.separator + "config" + File.separator +
                    "broker.xml"),
            new File(ServerConfigurationManager.getCarbonHome() +
                    File.separator + "repository" + File.separator + "conf" + File.separator + "broker.xml"),
            true, true);
}