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

import org.apache.commons.lang3.RandomStringUtils;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.dmr.ModelNode;
import org.jboss.hal.testsuite.creaper.ManagementClientProvider;
import org.jboss.hal.testsuite.creaper.ResourceVerifier;
import org.jboss.hal.testsuite.fragment.config.undertow.UndertowFragment;
import org.jboss.hal.testsuite.page.config.UndertowPage;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.wildfly.extras.creaper.core.CommandFailedException;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
import org.wildfly.extras.creaper.core.online.operations.Address;
import org.wildfly.extras.creaper.core.online.operations.OperationException;
import org.wildfly.extras.creaper.core.online.operations.Operations;
import org.wildfly.extras.creaper.core.online.operations.admin.Administration;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public abstract class UndertowTestCaseAbstract {

    protected static OnlineManagementClient client;
    protected static UndertowOperations undertowOps;
    protected static Operations operations;
    protected static Administration administration;

    protected static final Address UNDERTOW_ADDRESS = Address.subsystem("undertow");

    //shared valid values
    protected static final int NUMERIC_VALID = 25;
    protected static final long NUMERIC_VALID_LONG = 25L;
    protected static final String NUMERIC_INVALID = "25fazf";


    @Drone
    protected WebDriver browser;

    @Page
    protected UndertowPage page;

    @BeforeClass
    public static void mainSetUp() throws IOException, CommandFailedException, TimeoutException, InterruptedException {
        client = ManagementClientProvider.createOnlineManagementClient();
        operations = new Operations(client);
        administration = new Administration(client);
        undertowOps = new UndertowOperations(client);
    }

    @AfterClass
    public static void mainTearDown() throws InterruptedException, IOException, TimeoutException, OperationException, CommandFailedException {
        try {
            undertowOps.cleanupReferences();
            administration.restartIfRequired();
            administration.reloadIfRequired();
        } finally {
            client.close();
        }
    }

    protected void editTextAndVerify(Address address, String attributeName, String value) throws Exception {
        page.getConfigFragment().editTextAndSave(attributeName, value);
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editTextAndVerify(Address address, String attributeName, int value) throws Exception {
        page.getConfigFragment().editTextAndSave(attributeName, String.valueOf(value));
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editTextAndVerify(Address address, String attributeName, long value) throws Exception {
        page.getConfigFragment().editTextAndSave(attributeName, String.valueOf(value));
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editTextAndVerify(Address address, String attributeName) throws Exception {
        editTextAndVerify(address, attributeName, "undertow_" + attributeName + RandomStringUtils.randomAlphabetic(4));
    }

    protected void editCheckboxAndVerify(Address address, String attributeName, Boolean value) throws Exception {
        page.getConfigFragment().editCheckboxAndSave(attributeName, value);
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editCheckboxAndVerify(Address address, String identifier, String attributeName, Boolean value) throws Exception {
        page.getConfigFragment().editCheckboxAndSave(identifier, value);
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }<commit_msg>Clean reload required after each Undertow test.<commit_after>package org.jboss.hal.testsuite.test.configuration.undertow;

import org.apache.commons.lang3.RandomStringUtils;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.dmr.ModelNode;
import org.jboss.hal.testsuite.creaper.ManagementClientProvider;
import org.jboss.hal.testsuite.creaper.ResourceVerifier;
import org.jboss.hal.testsuite.fragment.config.undertow.UndertowFragment;
import org.jboss.hal.testsuite.page.config.UndertowPage;
import org.jboss.hal.testsuite.util.Console;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.wildfly.extras.creaper.core.CommandFailedException;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
import org.wildfly.extras.creaper.core.online.operations.Address;
import org.wildfly.extras.creaper.core.online.operations.OperationException;
import org.wildfly.extras.creaper.core.online.operations.Operations;
import org.wildfly.extras.creaper.core.online.operations.admin.Administration;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public abstract class UndertowTestCaseAbstract {

    protected static OnlineManagementClient client;
    protected static UndertowOperations undertowOps;
    protected static Operations operations;
    protected static Administration administration;

    protected static final Address UNDERTOW_ADDRESS = Address.subsystem("undertow");

    //shared valid values
    protected static final int NUMERIC_VALID = 25;
    protected static final long NUMERIC_VALID_LONG = 25L;
    protected static final String NUMERIC_INVALID = "25fazf";


    @Drone
    protected WebDriver browser;

    @Page
    protected UndertowPage page;

    @BeforeClass
    public static void mainSetUp() throws IOException, CommandFailedException, TimeoutException, InterruptedException {
        client = ManagementClientProvider.createOnlineManagementClient();
        operations = new Operations(client);
        administration = new Administration(client);
        undertowOps = new UndertowOperations(client);
    }

    @AfterClass
    public static void mainTearDown() throws InterruptedException, IOException, TimeoutException, OperationException, CommandFailedException {
        try {
            undertowOps.cleanupReferences();
            administration.restartIfRequired();
            administration.reloadIfRequired();
        } finally {
            client.close();
        }
    }

    @After
    public void disposeOfReloadRequiredWindow() throws InterruptedException, TimeoutException, IOException {
        Console.withBrowser(browser).dismissReloadRequiredWindowIfPresent();
        administration.reloadIfRequired();
    }

    protected void editTextAndVerify(Address address, String attributeName, String value) throws Exception {
        page.getConfigFragment().editTextAndSave(attributeName, value);
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editTextAndVerify(Address address, String attributeName, int value) throws Exception {
        page.getConfigFragment().editTextAndSave(attributeName, String.valueOf(value));
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editTextAndVerify(Address address, String attributeName, long value) throws Exception {
        page.getConfigFragment().editTextAndSave(attributeName, String.valueOf(value));
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editTextAndVerify(Address address, String attributeName) throws Exception {
        editTextAndVerify(address, attributeName, "undertow_" + attributeName + RandomStringUtils.randomAlphabetic(4));
    }

    protected void editCheckboxAndVerify(Address address, String attributeName, Boolean value) throws Exception {
        page.getConfigFragment().editCheckboxAndSave(attributeName, value);
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }

    protected void editCheckboxAndVerify(Address address, String identifier, String attributeName, Boolean value) throws Exception {
        page.getConfigFragment().editCheckboxAndSave(identifier, value);
        new ResourceVerifier(address, client).verifyAttribute(attributeName, value);
    }
{'fraction_non_alphanumeric': 0.08122411412793373, 'fraction_numerical': 0.0018407731247123793, 'mean_word_length': 4.783765801729873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3408691', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2182, 'n_words': 480}