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

The following examples show how to use org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager. 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: CARBON15261JsonFormatterTest.java    From product-ei with 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 #2
Source File: PerMessageAcknowledgementsTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: DiscardAllowedMsgDeliveryStrategyTestCase.java    From product-ei with 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_TOPIC_MESSAGE_DELIVERY_STRATEGY, "DISCARD_ALLOWED");

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

	configurationEditor.applyUpdatedConfigurationAndRestartServer(serverManager);

}
 
Example #4
Source File: DurableTopicSubscriptionWithSameClientIdTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #5
Source File: LZ4CompressionTestCase.java    From product-ei with 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 #6
Source File: SlowestSubscriptionRateMsgDeliveryStrategyTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #7
Source File: CARBON15261JsonFormatterTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: MessageContentTestCase.java    From product-ei with 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 #9
Source File: AMQPSessionRecoverTestCase.java    From product-ei with 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 #10
Source File: DLCMessageExpiryTestCase.java    From product-ei with 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 #11
Source File: EventingSampleTestCase.java    From product-ei with 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 #12
Source File: XssCsrfSkipPatternsTestCase.java    From product-ei with 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 #13
Source File: XssCsrfSkipPatternsTestCase.java    From product-ei with 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 #14
Source File: HTTPXMLMessageTestCase.java    From product-cep with 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 #15
Source File: CarbonMetricsTestCase.java    From product-cep with 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 #16
Source File: Wso2EventTestCase.java    From product-cep with 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 #17
Source File: StormManagerServiceTestCase.java    From product-cep with 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 #18
Source File: RestResourceLifeCycleManagementTestCase.java    From product-es with Apache License 2.0 6 votes vote down vote up
@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 #19
Source File: EventingSampleTestCase.java    From micro-integrator with 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 #20
Source File: HumanTaskCoordinationTest.java    From product-ei with 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 #21
Source File: LZ4UITestCase.java    From product-ei with 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 #22
Source File: DLCQueueTestCase.java    From product-ei with 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 #23
Source File: JavaServiceTaskDeploymentUndeploymentTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@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 #24
Source File: PurgeMessagesTestCase.java    From product-ei with 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 #25
Source File: DeactivatedCappMPBehaviourOnRestartTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init();
    context = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN);
    serverConfigurationManager = new ServerConfigurationManager(context);
    axis2Server = new SampleAxis2Server("test_axis2_server_9001.xml");
    axis2Server.deployService(SampleAxis2Server.SIMPLE_STOCK_QUOTE_SERVICE);
    axis2Server.start();
    uploadCapp(carFileName, new DataHandler(new FileDataSource(new File(
            getESBResourceLocation() + File.separator + "car" + File.separator + carFileName))));
    isProxyDeployed(PROXY_SERVICE_NAME);
}
 
Example #26
Source File: DS1063EmailUsernameTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@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 #27
Source File: EmailUtil.java    From product-es with Apache License 2.0 5 votes vote down vote up
/**
 * Update user profile for particular user in order to enable e-mail subscription.
 *
 * @param automationContext
 * @param backendURL        URL of the server.
 * @param session           session cookie obtained after logging in.
 * @throws UserProfileMgtServiceClient
 * @throws IOException
 * @throws XPathExpressionException
 * @throws AutomationUtilException
 */
public static void updateProfileAndEnableEmailConfiguration(AutomationContext automationContext, String backendURL,
        String session)
        throws UserProfileMgtServiceUserProfileExceptionException, IOException, XPathExpressionException,
        AutomationUtilException {
    UserProfileMgtServiceClient userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, session);
    File axis2File = new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "axis2.xml");
    UserProfileDTO profile = new UserProfileDTO();
    profile.setProfileName("default");

    UserFieldDTO lastName = new UserFieldDTO();
    lastName.setClaimUri("http://wso2.org/claims/lastname");
    lastName.setFieldValue("GregUserFirstName");

    UserFieldDTO givenName = new UserFieldDTO();
    givenName.setClaimUri("http://wso2.org/claims/givenname");
    givenName.setFieldValue("GregUserLastName");

    UserFieldDTO email = new UserFieldDTO();
    email.setClaimUri("http://wso2.org/claims/emailaddress");
    email.setFieldValue(emailAddress);

    UserFieldDTO[] fields = new UserFieldDTO[3];
    fields[0] = lastName;
    fields[1] = givenName;
    fields[2] = email;

    profile.setFieldValues(fields);

    userProfileMgtClient
            .setUserProfile(automationContext.getContextTenant().getContextUser().getUserName(), profile);

    // apply new axis2.xml configuration
    ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(automationContext);
    serverConfigurationManager.applyConfiguration(axis2File);
}
 
Example #28
Source File: RegistryConfiguratorTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.greg")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public void testSetupServerEnvironment() throws Exception {

    copyResources();
    copyJarFiles();
    editConfigurationFiles();
    updateRegistry();
    addResourceFileToRegistry();
    ServerConfigurationManager serverConfigurationManager =
            new ServerConfigurationManager(automationContext);
    serverConfigurationManager.restartGracefully();
    Thread.sleep(12000);

}
 
Example #29
Source File: EmailUtil.java    From product-es with Apache License 2.0 5 votes vote down vote up
/**
 * Update user profile for particular user in order to enable e-mail subscription.
 *
 * @param automationContext
 * @param backendURL        URL of the server.
 * @param session           session cookie obtained after logging in.
 * @throws UserProfileMgtServiceClient
 * @throws IOException
 * @throws XPathExpressionException
 * @throws AutomationUtilException
 */
public static void updateProfileAndEnableEmailConfiguration(AutomationContext automationContext, String backendURL,
        String session)
        throws UserProfileMgtServiceUserProfileExceptionException, IOException, XPathExpressionException,
        AutomationUtilException {
    UserProfileMgtServiceClient userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, session);
    File axis2File = new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "axis2.xml");
    UserProfileDTO profile = new UserProfileDTO();
    profile.setProfileName("default");

    UserFieldDTO lastName = new UserFieldDTO();
    lastName.setClaimUri("http://wso2.org/claims/lastname");
    lastName.setFieldValue("GregUserFirstName");

    UserFieldDTO givenName = new UserFieldDTO();
    givenName.setClaimUri("http://wso2.org/claims/givenname");
    givenName.setFieldValue("GregUserLastName");

    UserFieldDTO email = new UserFieldDTO();
    email.setClaimUri("http://wso2.org/claims/emailaddress");
    email.setFieldValue(emailAddress);

    UserFieldDTO[] fields = new UserFieldDTO[3];
    fields[0] = lastName;
    fields[1] = givenName;
    fields[2] = email;

    profile.setFieldValues(fields);

    userProfileMgtClient
            .setUserProfile(automationContext.getContextTenant().getContextUser().getUserName(), profile);

    // apply new axis2.xml configuration
    ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(automationContext);
    serverConfigurationManager.applyConfiguration(axis2File);
}
 
Example #30
Source File: RegistryConfiguratorTestCase.java    From product-es with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.greg")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public void testSetupServerEnvironment() throws Exception {

    copyResources();
    copyJarFiles();
    editConfigurationFiles();
    updateRegistry();
    addResourceFileToRegistry();
    ServerConfigurationManager serverConfigurationManager =
            new ServerConfigurationManager(automationContext);
    serverConfigurationManager.restartGracefully();
    Thread.sleep(12000);

}