<commit_before>package org.jboss.hal.testsuite.test.configuration.messaging;

import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.dmr.ModelNode;
import org.jboss.hal.testsuite.category.Shared;
import org.jboss.hal.testsuite.cli.CliClient;
import org.jboss.hal.testsuite.cli.CliClientFactory;
import org.jboss.hal.testsuite.dmr.Dispatcher;
import org.jboss.hal.testsuite.dmr.ResourceAddress;
import org.jboss.hal.testsuite.dmr.ResourceVerifier;
import org.jboss.hal.testsuite.page.config.MessagingPage;
import org.jboss.hal.testsuite.util.ConfigUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

/**
 * Created by pcyprian on 9.9.15.
 */
@RunWith(Arquillian.class)
@Category(Shared.class)
public class MessagingProviderTestCase {
    private static final String NAME = "test-provider";
    private static final String SECURITYDOMAIN = "other";
    private static final String USER = "tester";
    private static final String PASSWORD = "<PASSWORD>";

    private ModelNode path = new ModelNode("/subsystem=messaging-activemq/server=" + NAME );
    private ModelNode domainPath = new ModelNode("/profile=full/subsystem=messaging-activemq/server=" + NAME);
    private ResourceAddress address;
    private static Dispatcher dispatcher;
    private static ResourceVerifier verifier;
    CliClient cliClient = CliClientFactory.getClient();

    @BeforeClass
    public static void setUp() {
        dispatcher = new Dispatcher();
        verifier  = new ResourceVerifier(dispatcher);
    }

    @AfterClass
    public static void tearDown() {
        dispatcher.close();
    }

    @Drone
    private WebDriver browser;
    @Page
    private MessagingPage page;

    @Before
    public void before() {
        if (ConfigUtils.isDomain()) {
            address = new ResourceAddress(domainPath);
        } else {
            address = new ResourceAddress(path);
        }
    }
    @After
    public void after() {
        cliClient.reload();
    }

    @Test
    @InSequence(0)
    public void addMessagingProvider() {
        page.navigateToMessagingProvider();
        page.makeNavigation();
        page.createProvider(NAME, true, SECURITYDOMAIN, USER, PASSWORD);

        verifier.verifyResource(address, true);
    }

    @Test
    @InSequence(1)
    public void removeMessagingProvider() {
        page.selectProvider(NAME);
        page.removeProvider();

        verifier.verifyResource(address, false);
    }
}<commit_msg>Stabilize, optimize and extend MessagingProviderTestCase.<commit_after>package org.jboss.hal.testsuite.test.configuration.messaging;

import org.apache.commons.io.IOUtils;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.hal.testsuite.category.Shared;
import org.jboss.hal.testsuite.creaper.ManagementClientProvider;
import org.jboss.hal.testsuite.creaper.ResourceVerifier;
import org.jboss.hal.testsuite.page.config.MessagingPage;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
import org.wildfly.extras.creaper.core.online.operations.Address;

/**
 * Created by pcyprian on 9.9.15.
 */
@RunWith(Arquillian.class)
@Category(Shared.class)
public class MessagingProviderTestCase {
    private static final String NAME = "test-provider";
    private static final String SECURITYDOMAIN = "other";
    private static final String USER = "tester";
    private static final String PASSWORD = "<PASSWORD>";
    private static final OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient();

    private Address address = Address.subsystem("messaging-activemq").and("server", NAME);

    @AfterClass
    public static void tearDown() {
        IOUtils.closeQuietly(client);
    }

    @Drone
    private WebDriver browser;
    @Page
    private MessagingPage page;

    @Test
    @InSequence(0)
    public void addMessagingProvider() throws Exception {
        page.navigateToMessagingProvider();
        page.makeNavigation();
        page.createProvider(NAME, true, SECURITYDOMAIN, USER, PASSWORD);

        new ResourceVerifier(address, client).verifyExists()
            .verifyAttribute("security-enabled", true)
            .verifyAttribute("security-domain", SECURITYDOMAIN)
            .verifyAttribute("cluster-user", USER)
            .verifyAttribute("cluster-password", PASSWORD);
    }

    @Test
    @InSequence(1)
    public void removeMessagingProvider() throws Exception {
        page.selectProvider(NAME);
        page.removeProvider();

        new ResourceVerifier(address, client).verifyDoesNotExist();
    }
}
{'fraction_non_alphanumeric': 0.10435449836946097, 'fraction_numerical': 0.002301937464032227, 'mean_word_length': 3.8774555659494854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3529073', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1520, 'n_words': 304}