Search in sources :

Example 1 with CapybaraPortingLayerImpl

use of org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl in project acceptance-test-harness by jenkinsci.

the class MailService method assertMail.

/**
 * Checks that the mail has arrived.
 */
public void assertMail(final Pattern subject, String recipient, Pattern body) throws MessagingException, IOException {
    CapybaraPortingLayer hackish = new CapybaraPortingLayerImpl(World.get().getInjector());
    MimeMessage msg = hackish.waitFor().withMessage("Email whose subject matches: %s", subject).pollingEvery(5, TimeUnit.SECONDS).until(new MailArrives(subject));
    String actualRecipients = Joiner.on(' ').join(msg.getRecipients(TO));
    assertThat("recipient", actualRecipients, is(recipient));
    Object c = msg.getContent();
    if (c instanceof MimeMultipart) {
        MimeMultipart content = (MimeMultipart) c;
        c = content.getBodyPart(0).getContent();
    }
    assertThat(c.toString(), containsRegexp(body));
}
Also used : CapybaraPortingLayer(org.jenkinsci.test.acceptance.po.CapybaraPortingLayer) MimeMessage(javax.mail.internet.MimeMessage) MimeMultipart(javax.mail.internet.MimeMultipart) CapybaraPortingLayerImpl(org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl)

Example 2 with CapybaraPortingLayerImpl

use of org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl in project acceptance-test-harness by jenkinsci.

the class PluginManagerTest method uninstall_plugin.

@Test
@WithPlugins("gerrit-trigger")
public void uninstall_plugin() throws InterruptedException, ExecutionException {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    jenkins.getPluginManager().visit("installed");
    WebElement form = find(by.action("plugin/gerrit-trigger/uninstall"));
    form.submit();
    waitFor(form).until(CapybaraPortingLayerImpl::isStale);
    clickButton("Yes");
    jenkins.restart();
    jenkins.getPluginManager().visit("installed");
    assertThrows(NoSuchElementException.class, () -> find(by.url("plugin/gerrit-trigger")));
}
Also used : WebElement(org.openqa.selenium.WebElement) CapybaraPortingLayerImpl(org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

CapybaraPortingLayerImpl (org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl)2 MimeMessage (javax.mail.internet.MimeMessage)1 MimeMultipart (javax.mail.internet.MimeMultipart)1 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)1 CapybaraPortingLayer (org.jenkinsci.test.acceptance.po.CapybaraPortingLayer)1 Test (org.junit.Test)1 WebElement (org.openqa.selenium.WebElement)1