org.wso2.carbon.automation.engine.FrameworkConstants Java Examples

The following examples show how to use org.wso2.carbon.automation.engine.FrameworkConstants. 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: JMSEndpointSuspensionViaVFSTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private boolean startBroker() {
    try {
        log.info("JMSServerController: Preparing to start JMS Broker: ");
        broker = new BrokerService();
        // configure the broker

        broker.setBrokerName("myBroker1");
        log.info(broker.getBrokerDataDirectory());
        broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator + broker
                .getBrokerDataDirectory());
        broker.setTransportConnectors(getTCPConnectors());
        broker.setPersistent(true);

        broker.start();
        log.info("JMSServerController: Broker is Successfully started. continuing tests");
        return true;
    } catch (Exception e) {
        log.error("JMSServerController: There was an error starting JMS broker: ", e);
        return false;
    }
}
 
Example #2
Source File: CustomTestServerManager.java    From product-iots with Apache License 2.0 6 votes vote down vote up
/**
 * This method is called for starting a Carbon server in preparation for execution of a
 * TestSuite
 * <p/>
 * Add the @BeforeSuite TestNG annotation in the method overriding this method
 * @param server : The server which needs to be start.
 * @return The CARBON_HOME
 * @throws java.io.IOException If an error occurs while copying the deployment artifacts into the
 *                             Carbon server
 */
public String startServer(String server)
        throws AutomationFrameworkException, IOException, XPathExpressionException {
    if(carbonHome == null) {
        if (carbonZip == null) {
            carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
        }
        if (carbonZip == null) {
            throw new IllegalArgumentException("carbon zip file cannot find in the given location");
        }
        carbonHome = carbonServer.setUpCarbonHome(carbonZip) + "/" + server;
        configureServer();
    }
    log.info("Carbon Home - " + carbonHome );
    if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) {
        this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND));
    } else {
        this.portOffset = 0;
    }
    carbonServer.startServerUsingCarbonHome(carbonHome, commandMap);
    return carbonHome;
}
 
Example #3
Source File: TestServerManager.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * This method is called for starting a Carbon server in preparation for execution of a
 * TestSuite
 * <p/>
 * Add the @BeforeSuite TestNG annotation in the method overriding this method
 *
 * @return The CARBON_HOME
 * @throws IOException If an error occurs while copying the deployment artifacts into the
 *                     Carbon server
 */
public String startServer()
        throws AutomationFrameworkException, IOException, XPathExpressionException {
    if (carbonHome == null) {
        if (carbonZip == null) {
            carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
        }
        if (carbonZip == null) {
            throw new IllegalArgumentException("carbon zip file cannot find in the given location");
        }
        carbonHome = carbonServer.setUpCarbonHome(carbonZip);
        configureServer();
    }
    log.info("Carbon Home - " + carbonHome);
    if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) {
        this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND));
    } else {
        this.portOffset = 0;
    }

    if (commandMap.get("runtimePath") != null) {
        this.runtimePath = commandMap.get("runtimePath");
    }
    carbonServer.startServerUsingCarbonHome(carbonHome, commandMap);
    return carbonHome;
}
 
Example #4
Source File: HumanTaskCreationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {

    init();  //init master class
    bpelPackageManagementClient = new BpelPackageManagementClient(backEndUrl, sessionCookie);
    humanTaskPackageManagementClient = new HumanTaskPackageManagementClient(backEndUrl, sessionCookie);
    requestSender = new RequestSender();
    initialize();

    //initialize HT Client API for Clerk1 user
    AutomationContext clerk1AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "clerk1");
    LoginLogoutClient clerk1LoginLogoutClient = new LoginLogoutClient(clerk1AutomationContext);
    String clerk1SessionCookie = clerk1LoginLogoutClient.login();

    clerk1HumanTaskClientApiClient = new HumanTaskClientApiClient(backEndUrl, clerk1SessionCookie);

    //initialize HT Client API for Manager1 user
    AutomationContext manager1AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "manager1");
    LoginLogoutClient manager1LoginLogoutClient = new LoginLogoutClient(manager1AutomationContext);
    String manager1SessionCookie = manager1LoginLogoutClient.login();
    manager1HumanTaskClientApiClient = new HumanTaskClientApiClient(backEndUrl, manager1SessionCookie);
}
 
Example #5
Source File: JMSEndpointSuspensionViaVFSTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private boolean startBroker() {
    try {
        log.info("JMSServerController: Preparing to start JMS Broker: " );
        broker = new BrokerService();
        // configure the broker

        broker.setBrokerName("myBroker1");
        log.info(broker.getBrokerDataDirectory());
        broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) +
                File.separator + broker.getBrokerDataDirectory());
        broker.setTransportConnectors(getTCPConnectors());
        broker.setPersistent(true);

        broker.start();
        log.info("JMSServerController: Broker is Successfully started. continuing tests");
        return true;
    } catch (Exception e) {
        log.error(
                "JMSServerController: There was an error starting JMS broker: ", e);
        return false;
    }
}
 
Example #6
Source File: QueueUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes before a test method. Removes users of admin group if exists. Adds new roles
 * with permissions.
 *
 * @throws Exception
 */
@BeforeMethod(alwaysRun = true)
public void initialize() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);

    String[] createPubSubUsers = new String[]{"authUser1", "authUser2"};
    String[] pubSubUsers = new String[]{"authUser3", "authUser4"};
    String[] noPermissionUsers = new String[]{"authUser5"};
    String[] allUsers =
            new String[]{"authUser1", "authUser2", "authUser3", "authUser4", "authUser5"};

    // Logging into user management as admin
    userManagementClient = new UserManagementClient(backendURL, "admin", "admin");

    // Removing admin permission for all users
    userManagementClient.updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, allUsers);

    // Adding roles along with users
    userManagementClient
            .addRole(CREATE_PUB_SUB_QUEUE_ROLE, createPubSubUsers, new String[]{ADD_QUEUE_PERMISSION});
    userManagementClient.addRole(PUB_SUB_QUEUE_ROLE, pubSubUsers, new String[]{});
    userManagementClient.addRole(NO_PERMISSION_QUEUE_ROLE, noPermissionUsers, new String[]{});
}
 
Example #7
Source File: TopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes before a test method. Removes users of admin group if exists. Adds new roles with
 * permissions.
 *
 * @throws Exception
 */
@BeforeMethod(alwaysRun = true)
public void initialize() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);

    String[] createPubSubUsers = new String[]{"authUser1", "authUser2"};
    String[] pubSubUsers = new String[]{"authUser3", "authUser4"};
    String[] noPermissionUsers = new String[]{"authUser5"};
    String[] allUsers =
            new String[]{"authUser1", "authUser2", "authUser3", "authUser4", "authUser5"};

    // Logging into user management as admin
    userManagementClient = new UserManagementClient(backendURL, "admin", "admin");

    // Removing admin permission for all users
    userManagementClient.updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, allUsers);

    // Adding roles along with users if roles does not exist.
    userManagementClient
            .addRole(CREATE_PUB_SUB_TOPIC_ROLE, createPubSubUsers, new String[]{ADD_TOPIC_PERMISSION});
    userManagementClient.addRole(PUB_SUB_TOPIC_ROLE, pubSubUsers, new String[]{});
    userManagementClient.addRole(NO_PERMISSION_TOPIC_ROLE, noPermissionUsers, new String[]{});
}
 
Example #8
Source File: SubTopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes before a test method. Removes users of admin group if exists. Adds new roles with
 * permissions.
 *
 * @throws Exception
 */
@BeforeMethod(alwaysRun = true)
public void initialize() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);

    String[] createPubSubUsers = new String[]{"authUser1", "authUser2"};
    String[] pubSubUsers = new String[]{"authUser3", "authUser4"};
    String[] noPermissionUsers = new String[]{"authUser5"};
    String[] allUsers =
            new String[]{"authUser1", "authUser2", "authUser3", "authUser4", "authUser5"};

    // Logging into user management as admin
    userManagementClient = new UserManagementClient(backendURL, "admin", "admin");

    // Removing admin permission for all users
    userManagementClient.updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, allUsers);

    // Adding roles along with users if roles does not exist.
    userManagementClient
            .addRole(CREATE_PUB_SUB_TOPIC_ROLE, createPubSubUsers, new String[]{ADD_TOPIC_PERMISSION});
    userManagementClient.addRole(PUB_SUB_TOPIC_ROLE, pubSubUsers, new String[]{});
    userManagementClient.addRole(NO_PERMISSION_TOPIC_ROLE, noPermissionUsers, new String[]{});
}
 
Example #9
Source File: ESServerManager.java    From product-es with Apache License 2.0 5 votes vote down vote up
/**
 * This method is called for starting a Carbon server in preparation for execution of a
 * TestSuite
 * <p/>
 * Add the @BeforeSuite TestNG annotation in the method overriding this method
 *
 * @return The CARBON_HOME
 * @throws java.io.IOException If an error occurs while copying the deployment artifacts into the
 *                             Carbon server
 */
protected String startServer() throws Exception {
    if (carbonZip == null) {
        carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
    }
    if (carbonZip == null) {
        throw new IllegalArgumentException("carbon zip file cannot find in the given location");
    }
    carbonHome = carbonServer.setUpCarbonHome(carbonZip);
    log.info("Carbon Home - " + carbonHome);
    setupTestResources();
    carbonServer.startServerUsingCarbonHome(carbonHome, commandMap);
    return carbonHome;
}
 
Example #10
Source File: JMSBroker.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to set initial broker configurations.
 *
 * @throws Exception if there is an error setting TransportConnectors
 */
private void setInitialConfigurations() throws Exception {
    log.info("JMSServerController: Preparing to start JMS Broker: " + serverName);
    broker = new BrokerService();
    broker.setBrokerName(serverName);
    log.info(broker.getBrokerDataDirectory());
    broker.setDataDirectory(
            System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator + broker.getBrokerDataDirectory());
    broker.setTransportConnectors(transportConnectors);
    broker.setPersistent(true);
}
 
Example #11
Source File: JMSBroker.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to set initial broker configurations.
 *
 * @throws Exception if there is an error setting TransportConnectors
 */
private void setInitialConfigurations() throws Exception {
    log.info("JMSServerController: Preparing to start JMS Broker: " + serverName);
    broker = new BrokerService();
    broker.setBrokerName(serverName);
    log.info(broker.getBrokerDataDirectory());
    broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator
            + broker.getBrokerDataDirectory());
    broker.setTransportConnectors(transportConnectors);
    broker.setPersistent(true);
}
 
Example #12
Source File: TopicPermissionTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a topic by giving topic creation rights to the user.
 * 1. User is in a role with no permissions.
 * 2. Admin gives permissions to the role to create topics and for logging in.
 * 3. User creates a topic.
 * 4. Validates whether topic is created.
 *
 * @throws XPathExpressionException
 * @throws IOException
 * @throws UserAdminUserAdminException
 */
@Test(groups = {"wso2.mb", "topic"})
public void createTopicPermissionTestCase() throws XPathExpressionException, IOException, UserAdminUserAdminException {
    String topicName = "topicCreationPermission";

    AutomationContext authAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY,
                                                                                "topicAuthUser");
    User contextUser = authAutomationContext.getContextTenant().getContextUser();

    String[] createPermissionUser = new String[]{contextUser.getUserNameWithoutDomain()};

    // Logging into user management as admin
    UserManagementClient userManagementClient =
            new UserManagementClient(super.backendURL, "admin", "admin");

    // Removing admin permission for user
    userManagementClient.updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, createPermissionUser);

    // Adding roles along with users
    userManagementClient
            .addRole(CREATE_TOPIC_PERMISSION_ROLE, createPermissionUser, new String[]{ADD_TOPIC_PERMISSION, LOGIN_PERMISSION});

    driver.get(getLoginURL());
    LoginPage loginPage = new LoginPage(driver);
    // Logging in to the the management console
    HomePage homePage = loginPage.loginAs(contextUser.getUserNameWithoutDomain(), contextUser.getPassword());

    TopicAddPage topicAddPage =
            homePage.getTopicAddPage("home.mb.topics.add.without.queue.xpath");

    // Creating a topic by the user and check whether valid dialog pop up is shown
    Assert.assertEquals(topicAddPage.addTopic(topicName), true);

    TopicsBrowsePage topicsBrowsePage = homePage.getTopicsBrowsePage("home.mb.topics.browse.without.queue.xpath");

    // Checks whether topic is created in the browsing page
    Assert.assertEquals(topicsBrowsePage.isTopicPresent(topicName), true);
}
 
Example #13
Source File: HumanTaskCoordinationTest.java    From product-ei with 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 #14
Source File: TestServerManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void setUpCarbonHome(String deploymentDirectory, String registryDir)
        throws IOException, AutomationFrameworkException {
    if (carbonZip == null) {
        carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
    }
    if (carbonZip == null) {
        throw new IllegalArgumentException("carbon zip file cannot find in the given location");
    }
    carbonHome = carbonServer.setUpCarbonHome(carbonZip, commandMap.get("startupScript"));
    configureServer(deploymentDirectory, registryDir);
}
 
Example #15
Source File: TopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Runs a test case where a consumer and publisher is created and published with a given user
 * key from the automation.xml. Subscriber get unsubscribe after receiving expected message count.
 *
 * @param userKey         The user key mentioned in the automation.xml for a specific user.
 * @param destinationName The destination name of the topic.
 * @throws XPathExpressionException
 * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientConfigurationException
 * @throws IOException
 * @throws javax.jms.JMSException
 * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientException
 * @throws javax.naming.NamingException
 */
private void createPublishSubscribeAndUnsubscribeFromUser(String userKey, String destinationName)
        throws XPathExpressionException, AndesClientConfigurationException, IOException,
        JMSException, AndesClientException, NamingException {
    long sendCount = 10L;
    long expectedCount = 10L;

    AutomationContext userAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, userKey);
    User contextUser = userAutomationContext.getContextTenant().getContextUser();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration
            consumerConfig =
            new AndesJMSConsumerClientConfiguration( getAMQPPort(),
                    contextUser.getUserNameWithoutDomain(), contextUser.getPassword(),
                    ExchangeType.TOPIC, destinationName);
    consumerConfig.setMaximumMessagesToReceived(expectedCount);
    consumerConfig.setUnSubscribeAfterEachMessageCount(expectedCount);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig =
            new AndesJMSPublisherClientConfiguration( getAMQPPort(),
                    contextUser.getUserNameWithoutDomain(), contextUser.getPassword(),
                    ExchangeType.TOPIC, destinationName);
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    consumerClient.startClient();

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    publisherClient.startClient();

    AndesClientUtils
            .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);

    // Evaluating
    Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " +
            "failed for user : " + contextUser.getUserNameWithoutDomain());
    Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " +
            "receiving failed for user : " + contextUser.getUserNameWithoutDomain());
}
 
Example #16
Source File: TopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Runs a test case where a consumer and publisher is created and published with a given user
 * key from the automation.xml.
 *
 * @param userKey         The user key mentioned in the automation.xml for a specific user.
 * @param destinationName The destination name of the topic.
 * @throws XPathExpressionException
 * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientConfigurationException
 * @throws IOException
 * @throws javax.jms.JMSException
 * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientException
 * @throws javax.naming.NamingException
 */
private void createPublishAndSubscribeFromUser(String userKey, String destinationName)
        throws XPathExpressionException, AndesClientConfigurationException, IOException,
               JMSException, AndesClientException, NamingException {
    long sendCount = 10L;
    long expectedCount = 10L;

    AutomationContext userAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, userKey);
    User contextUser = userAutomationContext.getContextTenant().getContextUser();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration
            consumerConfig =
            new AndesJMSConsumerClientConfiguration( getAMQPPort(),
                            contextUser.getUserNameWithoutDomain(), contextUser.getPassword(),
                            ExchangeType.TOPIC, destinationName);
    consumerConfig.setMaximumMessagesToReceived(expectedCount);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig =
            new AndesJMSPublisherClientConfiguration( getAMQPPort(),
                    contextUser.getUserNameWithoutDomain(), contextUser.getPassword(),
                    ExchangeType.TOPIC, destinationName);
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    consumerClient.startClient();

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    publisherClient.startClient();

    AndesClientUtils
            .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);

    // Evaluating
    Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " +
                                  "failed for user : " + contextUser.getUserNameWithoutDomain());
    Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " +
                        "receiving failed for user : " + contextUser.getUserNameWithoutDomain());
}
 
Example #17
Source File: SubTopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Runs a test case where a consumer and publisher is created and published with a given user
 * key from the automation.xml.
 *
 * @param topicConsumeUser user defined in automation.xml for consume from a topic.
 * @param topicPublishUser user defined in automation.xml for publish to a topic.
 * @param destinationName topic destination.
 * @throws XPathExpressionException
 * @throws AndesClientConfigurationException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
private void createPublishAndSubscribeFromUsers(String topicConsumeUser, String topicPublishUser,
                                                String destinationName)
        throws XPathExpressionException, AndesClientConfigurationException, IOException,
        JMSException, AndesClientException, NamingException {

    long sendCount = 100L;
    long expectedCount = 100L;

    // get context for topic consume user
    AutomationContext topicConsumeUserAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, topicConsumeUser);
    User consumeUser = topicConsumeUserAutomationContext.getContextTenant().getContextUser();

    // get context for topic publisher user
    AutomationContext topicPublishUserAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, topicPublishUser);
    User publishUser = topicPublishUserAutomationContext.getContextTenant().getContextUser();


    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration
            consumerConfig =
            new AndesJMSConsumerClientConfiguration( getAMQPPort(),
                    consumeUser.getUserNameWithoutDomain(), consumeUser.getPassword(),
                    ExchangeType.TOPIC, destinationName);
    consumerConfig.setMaximumMessagesToReceived(expectedCount);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig =
            new AndesJMSPublisherClientConfiguration( getAMQPPort(),
                    publishUser.getUserNameWithoutDomain(), publishUser.getPassword(),
                    ExchangeType.TOPIC, destinationName);
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    consumerClient.startClient();

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    publisherClient.startClient();

    AndesClientUtils
            .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);

        // Evaluating
        Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " +
                "failed for user : " + consumeUser.getUserNameWithoutDomain());
        Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " +
                "receiving failed for user : " + publishUser.getUserNameWithoutDomain());
}
 
Example #18
Source File: QueuePermissionTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a queue by giving queue creation rights to the user.
 * 1. User is in a role with no permissions.
 * 2. Admin gives permissions to the role to create queues and for logging in.
 * 3. User creates a queue.
 * 4. Validates whether queue is created.
 *
 * @throws IOException
 * @throws UserAdminUserAdminException
 * @throws XPathExpressionException
 */
@Test(groups = {"wso2.mb", "queue"})
public void createQueuePermissionTestCase() throws IOException, UserAdminUserAdminException,
        XPathExpressionException {
    String queueName = "queueCreationPermission";

    AutomationContext authAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY,
                                                                            "queueAuthUser");
    User contextUser = authAutomationContext.getContextTenant().getContextUser();

    String[] createPermissionUsers = new String[]{contextUser.getUserNameWithoutDomain()};

    // Logging into user management as admin
    UserManagementClient userManagementClient =
            new UserManagementClient(backendURL, "admin", "admin");

    // Removing admin permission for user
    userManagementClient
            .updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, createPermissionUsers);

    // Adding roles along with user
    userManagementClient.addRole(CREATE_QUEUE_PERMISSION_ROLE, createPermissionUsers,
                                                            new String[]{ADD_QUEUE_PERMISSION, LOGIN_PERMISSION});

    driver.get(getLoginURL());
    LoginPage loginPage = new LoginPage(driver);

    // Logging in to the the management console
    HomePage homePage = loginPage.loginAs(contextUser.getUserNameWithoutDomain(), contextUser.getPassword());

    QueueAddPage queueAddPage = homePage.getQueueAddPage();

    // Creating a queue by the user and check whether valid dialog pop up is shown
    Assert.assertEquals(queueAddPage.addQueue(queueName), true);
    QueuesBrowsePage queuesBrowsePage = homePage.getQueuesBrowsePage();

    // Checks whether queue is created in the browsing page
    Assert.assertEquals(queuesBrowsePage.isQueuePresent(queueName), true);

}
 
Example #19
Source File: QueueUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Runs a test case where a consumer and publisher is created and published with a given user
 * key from the automation.xml.
 *
 * @param userKey         The user key mentioned in the automation.xml for a specific user.
 * @param destinationName The destination name of the queue.
 * @throws XPathExpressionException
 * @throws AndesClientConfigurationException
 * @throws IOException
 * @throws JMSException
 * @throws AndesClientException
 * @throws NamingException
 */
private void createPublishAndSubscribeFromUser(String userKey, String destinationName)
        throws XPathExpressionException, AndesClientConfigurationException, IOException,
               JMSException, AndesClientException, NamingException {
    long sendCount = 10L;
    long expectedCount = 10L;

    AutomationContext userAutomationContext =
            new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, userKey);
    User contextUser = userAutomationContext.getContextTenant().getContextUser();

    // Creating a consumer client configuration
    AndesJMSConsumerClientConfiguration
            consumerConfig =
            new AndesJMSConsumerClientConfiguration(getAMQPPort(),
                    contextUser.getUserNameWithoutDomain(), contextUser.getPassword(),
                    ExchangeType.QUEUE, destinationName);
    consumerConfig.setMaximumMessagesToReceived(expectedCount);
    consumerConfig.setAsync(false);

    // Creating a publisher client configuration
    AndesJMSPublisherClientConfiguration publisherConfig =
            new AndesJMSPublisherClientConfiguration(getAMQPPort(),
                    contextUser.getUserNameWithoutDomain(), contextUser.getPassword(),
                    ExchangeType.QUEUE, destinationName);
    publisherConfig.setNumberOfMessagesToSend(sendCount);

    // Creating clients
    AndesClient consumerClient = new AndesClient(consumerConfig, true);
    consumerClient.startClient();

    AndesClient publisherClient = new AndesClient(publisherConfig, true);
    publisherClient.startClient();

    AndesClientUtils
            .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME);

    // Evaluating
    Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " +
                                "failed for user : " + contextUser.getUserNameWithoutDomain());
    Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " +
                         "receiving failed for user : " + contextUser.getUserNameWithoutDomain());
}
 
Example #20
Source File: HumanTaskPeopleAssignment.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
	init();  //init master class
	humanTaskPackageManagementClient = new HumanTaskPackageManagementClient(backEndUrl, sessionCookie);
	requestSender = new RequestSender();
	initialize();

	//initialize HT Client API for Clerk1 user
	AutomationContext clerk1AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
			FrameworkConstants.SUPER_TENANT_KEY, "clerk1");
	LoginLogoutClient clerk1LoginLogoutClient = new LoginLogoutClient(clerk1AutomationContext);
	String clerk1SessionCookie = clerk1LoginLogoutClient.login();

	clerk1Client = new HumanTaskClientApiClient(backEndUrl, clerk1SessionCookie);


	//initialize HT Client API for Clerk2 user
	AutomationContext clerk2AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
			FrameworkConstants.SUPER_TENANT_KEY, "clerk2");
	LoginLogoutClient clerk2LoginLogoutClient = new LoginLogoutClient(clerk2AutomationContext);
	String clerk2SessionCookie = clerk2LoginLogoutClient.login();

	clerk2Client = new HumanTaskClientApiClient(backEndUrl, clerk2SessionCookie);


	//initialize HT Client API for Clerk3 user
	AutomationContext clerk3AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
			FrameworkConstants.SUPER_TENANT_KEY, "clerk3");
	LoginLogoutClient clerk3LoginLogoutClient = new LoginLogoutClient(clerk3AutomationContext);
	String clerk3SessionCookie = clerk3LoginLogoutClient.login();

	clerk3Client = new HumanTaskClientApiClient(backEndUrl, clerk3SessionCookie);

	//initialize HT Client API for Clerk4 user
	AutomationContext clerk4AutomationContext =
			new AutomationContext("BPS", "bpsServerInstance0001", FrameworkConstants.SUPER_TENANT_KEY, "clerk4");
	LoginLogoutClient clerk4LoginLogoutClient = new LoginLogoutClient(clerk4AutomationContext);
	String clerk4SessionCookie = clerk4LoginLogoutClient.login();

	clerk4Client = new HumanTaskClientApiClient(backEndUrl, clerk4SessionCookie);

	//initialize HT Client API for Clerk5 user
	AutomationContext clerk5AutomationContext =
			new AutomationContext("BPS", "bpsServerInstance0001", FrameworkConstants.SUPER_TENANT_KEY, "clerk5");
	LoginLogoutClient clerk5LoginLogoutClient = new LoginLogoutClient(clerk5AutomationContext);
	String clerk5SessionCookie = clerk5LoginLogoutClient.login();

	clerk5Client = new HumanTaskClientApiClient(backEndUrl, clerk5SessionCookie);

	//initialize HT Client API for Clerk6 user
	AutomationContext clerk6AutomationContext =
			new AutomationContext("BPS", "bpsServerInstance0001", FrameworkConstants.SUPER_TENANT_KEY, "clerk6");
	LoginLogoutClient clerk6LoginLogoutClient = new LoginLogoutClient(clerk6AutomationContext);
	String clerk6SessionCookie = clerk6LoginLogoutClient.login();

	clerk6Client = new HumanTaskClientApiClient(backEndUrl, clerk6SessionCookie);

	//initialize HT Client API for Manager1 user
	AutomationContext manager1AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
			FrameworkConstants.SUPER_TENANT_KEY, "manager1");
	LoginLogoutClient manager1LoginLogoutClient = new LoginLogoutClient(manager1AutomationContext);
	String manager1SessionCookie = manager1LoginLogoutClient.login();
	manager1Client = new HumanTaskClientApiClient(backEndUrl, manager1SessionCookie);

	//initialize HT Client API for Manager2 user
	AutomationContext manager2AutomationContext =
			new AutomationContext("BPS", "bpsServerInstance0001", FrameworkConstants.SUPER_TENANT_KEY, "manager2");
	LoginLogoutClient manager2LoginLogoutClient = new LoginLogoutClient(manager2AutomationContext);
	String manager2SessionCookie = manager2LoginLogoutClient.login();
	manager2Client = new HumanTaskClientApiClient(backEndUrl, manager2SessionCookie);

	//initialize HT Client API for Manager3 user
	AutomationContext manager3AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
			FrameworkConstants.SUPER_TENANT_KEY, "manager3");
	LoginLogoutClient manager3LoginLogoutClient = new LoginLogoutClient(manager3AutomationContext);
	String manager3SessionCookie = manager3LoginLogoutClient.login();
	manager3Client = new HumanTaskClientApiClient(backEndUrl, manager3SessionCookie);
}
 
Example #21
Source File: CustomTestServerManager.java    From product-iots with Apache License 2.0 4 votes vote down vote up
/**
 * This method is called for starting a Carbon server in preparation for execution of a
 * TestSuite
 * <p/>
 * Add the @BeforeSuite TestNG annotation in the method overriding this method
 *
 * @param server : The server which needs to be start.
 * @return The CARBON_HOME
 * @throws IOException If an error occurs while copying the deployment artifacts into the
 *                     Carbon server
 */
public synchronized String startServer(String server)
        throws AutomationFrameworkException, IOException, XPathExpressionException, InterruptedException {
    if (carbonHome == null) {
        if (carbonZip == null) {
            carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
        }
        if (carbonZip == null) {
            throw new IllegalArgumentException("carbon zip file cannot find in the given location");
        }
        String extractedDir = getExistingExtractedDir();
        if (server.equalsIgnoreCase("core")) {
            if (extractedDir == null) {
                carbonHome = carbonServer.setUpCarbonHome(carbonZip);
            } else {
                carbonHome = extractedDir;
            }
            // Deploy the plugins.
            String[] cmdArray = new String[] { "mvn", "clean", "install", "-f", "device-plugins-deployer.xml"};
            Runtime.getRuntime().exec(cmdArray, null, new File(carbonHome + File.separator + "samples"));
            Thread.sleep(15000);
        } else if (server.equalsIgnoreCase("analytics") || server.equalsIgnoreCase("broker")) {
            if (extractedDir == null) {
                carbonHome = carbonServer.setUpCarbonHome(carbonZip) + File.separator + "wso2" + File.separator + server;
            } else {
                carbonHome = extractedDir + File.separator + "wso2" + File.separator + server;
            }
        } else {
            throw new IllegalArgumentException("Unsupported server type provided - " + server);
        }
        configureServer();
    }
    log.info("Carbon Home - " + carbonHome);
    if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) {
        this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND));
    } else {
        this.portOffset = 0;
    }

    carbonServer.startServerUsingCarbonHome(carbonHome, commandMap);
    return carbonHome;
}
 
Example #22
Source File: HumanTaskXpathExtensionsTest.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Setup the test environment.
 * @throws Exception
 */
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    init();  //init master class
    humanTaskPackageManagementClient = new HumanTaskPackageManagementClient(backEndUrl, sessionCookie);
    requestSender = new RequestSender();
    initialize();

    //initialize HT Client API for Clerk1 user
    AutomationContext clerk1AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "clerk1");
    LoginLogoutClient clerk1LoginLogoutClient = new LoginLogoutClient(clerk1AutomationContext);
    String clerk1SessionCookie = clerk1LoginLogoutClient.login();

    clerk1Client = new HumanTaskClientApiClient(backEndUrl, clerk1SessionCookie);

    //initialize HT Client API for Clerk2 user
    AutomationContext clerk2AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "clerk2");
    LoginLogoutClient clerk2LoginLogoutClient = new LoginLogoutClient(clerk2AutomationContext);
    String clerk2SessionCookie = clerk2LoginLogoutClient.login();

    clerk2Client = new HumanTaskClientApiClient(backEndUrl, clerk2SessionCookie);

    //initialize HT Client API for Clerk3 user
    AutomationContext clerk3AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "clerk3");
    LoginLogoutClient clerk3LoginLogoutClient = new LoginLogoutClient(clerk3AutomationContext);
    String clerk3SessionCookie = clerk3LoginLogoutClient.login();

    clerk3Client = new HumanTaskClientApiClient(backEndUrl, clerk3SessionCookie);

    //initialize HT Client API for Manager1 user
    AutomationContext manager1AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "manager1");
    LoginLogoutClient manager1LoginLogoutClient = new LoginLogoutClient(manager1AutomationContext);
    String manager1SessionCookie = manager1LoginLogoutClient.login();
    manager1Client = new HumanTaskClientApiClient(backEndUrl, manager1SessionCookie);

    //initialize HT Client API for Manager3 user
    AutomationContext manager3AutomationContext = new AutomationContext("BPS", "bpsServerInstance0001",
            FrameworkConstants.SUPER_TENANT_KEY, "manager3");
    LoginLogoutClient manager3LoginLogoutClient = new LoginLogoutClient(manager3AutomationContext);
    String manager3SessionCookie = manager3LoginLogoutClient.login();
    manager3Client = new HumanTaskClientApiClient(backEndUrl, manager3SessionCookie);

    createTask();

}