<commit_before>/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2015, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.jboss.hal.testsuite.test.configuration.picketlink.federation;

import static org.jboss.hal.testsuite.test.configuration.picketlink.federation.UtilFedName.*;

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

import org.apache.commons.io.IOUtils;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.hal.testsuite.creaper.ManagementClientProvider;
import org.jboss.hal.testsuite.page.config.FederationPage;
import org.jboss.hal.testsuite.test.configuration.picketlink.federation.UtilFedInputChecker.InputType;
import org.jboss.hal.testsuite.util.ConfigUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
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.admin.Administration;

/**
 * Created by pjelinek on Nov 18, 2015
 */
public abstract class AbstractFederationTestCase {

    protected static final OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient();
    protected static final FederationOperations federationOps = new FederationOperations(client);
    protected static final Administration adminOps = new Administration(client);
    protected UtilFedName name = new UtilFedName(this);

    @Drone
    protected WebDriver browser;

    @Page
    protected FederationPage page;

    @BeforeClass
    public static final void beforeClass() throws IOException, InterruptedException, TimeoutException {
        if (changeSubsystem()) {
            federationOps.addSubsystem();
        }
    }

    @AfterClass
    public static final void afterClass() throws IOException, InterruptedException, TimeoutException {
        if (changeSubsystem()) {
            federationOps.removeSubsystem();
        }
        IOUtils.closeQuietly(client);
    }

    protected final void setupFederation() throws IOException, OperationException {
        federationOps.addFederation(name.getFederation());
        federationOps.addIdp(name.getFederation(), name.getIdp(), name.get(Key.URL), SD_OTHER);
    }<commit_msg>Cleanup server state after Picketlink tests when system property federation.already.enabled is set to true.<commit_after>/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2015, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.jboss.hal.testsuite.test.configuration.picketlink.federation;

import static org.jboss.hal.testsuite.test.configuration.picketlink.federation.UtilFedName.*;

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

import org.apache.commons.io.IOUtils;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.hal.testsuite.creaper.ManagementClientProvider;
import org.jboss.hal.testsuite.page.config.FederationPage;
import org.jboss.hal.testsuite.test.configuration.picketlink.federation.UtilFedInputChecker.InputType;
import org.jboss.hal.testsuite.util.ConfigUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
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.admin.Administration;

/**
 * Created by pjelinek on Nov 18, 2015
 */
public abstract class AbstractFederationTestCase {

    protected static final OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient();
    protected static final FederationOperations federationOps = new FederationOperations(client);
    protected static final Administration adminOps = new Administration(client);
    protected UtilFedName name = new UtilFedName(this);

    @Drone
    protected WebDriver browser;

    @Page
    protected FederationPage page;

    @BeforeClass
    public static final void beforeClass() throws IOException, InterruptedException, TimeoutException {
        if (changeSubsystem()) {
            federationOps.addSubsystem();
        }
    }

    @AfterClass
    public static final void afterClass() throws IOException, InterruptedException, TimeoutException {
        if (changeSubsystem()) {
            federationOps.removeSubsystem();
        } else {
            adminOps.reloadIfRequired();
        }
        IOUtils.closeQuietly(client);
    }

    protected final void setupFederation() throws IOException, OperationException {
        federationOps.addFederation(name.getFederation());
        federationOps.addIdp(name.getFederation(), name.getIdp(), name.get(Key.URL), SD_OTHER);
    }
{'fraction_non_alphanumeric': 0.08175459049839696, 'fraction_numerical': 0.006703584960652871, 'mean_word_length': 4.370109546165884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2150333', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1806, 'n_words': 567}