core.PluginManagerTest.java Source code

Java tutorial

Introduction

Here is the source code for core.PluginManagerTest.java

Source

/*
 * The MIT License
 *
 * Copyright (c) Red Hat, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package core;

import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.po.PluginManager;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.openqa.selenium.WebElement;

import java.util.concurrent.ExecutionException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeTrue;

public class PluginManagerTest extends AbstractJUnitTest {

    @Test
    @Issue("JENKINS-36239")
    public void reproduce() throws Exception {
        PluginManager pm = jenkins.getPluginManager();
        pm.checkForUpdates();
        pm.open();
    }

    @Test
    @WithPlugins("gerrit-trigger")
    public void uninstall_plugin() throws InterruptedException, ExecutionException {
        assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
        jenkins.getPluginManager().visit("installed");
        check(find(by.url("plugin/gerrit-trigger")), false);
        WebElement form = find(by.action("plugin/gerrit-trigger/uninstall"));
        form.submit();
        jenkins.restart();
        jenkins.getPluginManager().visit("installed");
        WebElement trigger = find(by.url("plugin/gerrit-trigger"));
        assertFalse(trigger.isSelected());
    }
}