Search in sources :

Example 1 with JenkinsLogger

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

the class SupportCorePluginTest method emptyLogger.

@Issue("JENKINS-27669")
@Test
public void emptyLogger() throws Exception {
    JenkinsLogger logger = jenkins.createLogger("test", Collections.singletonMap("", Level.ALL));
    assertFalse(logger.isEmpty());
}
Also used : JenkinsLogger(org.jenkinsci.test.acceptance.po.JenkinsLogger) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 2 with JenkinsLogger

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

the class DiskUsage method reloaded.

public static Matcher<DiskUsage> reloaded() {
    return new Matcher<DiskUsage>("disk usage reloaded") {

        private Exception cause;

        @Override
        public boolean matchesSafely(DiskUsage item) {
            JenkinsLogger logger = item.getJenkins().getLogger("all");
            try {
                logger.waitForLogged(Pattern.compile("Finished Project disk usage. \\d+ ms"));
                return true;
            } catch (TimeoutException ex) {
                // v0.22 and newer
                cause = ex;
            }
            try {
                logger.waitForLogged(Pattern.compile("Finished Calculation of builds disk usage.*"));
                logger.waitForLogged(Pattern.compile("Finished Calculation of job directories.*"));
                logger.waitForLogged(Pattern.compile("Finished Calculation of workspace usage.*"));
                return true;
            } catch (TimeoutException ex) {
                cause = ex;
                return false;
            }
        }

        @Override
        public void describeMismatchSafely(DiskUsage item, Description dsc) {
            dsc.appendText(cause.getMessage());
        }
    };
}
Also used : Description(org.hamcrest.Description) Matcher(org.jenkinsci.test.acceptance.Matcher) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException) JenkinsLogger(org.jenkinsci.test.acceptance.po.JenkinsLogger) TimeoutException(org.openqa.selenium.TimeoutException)

Example 3 with JenkinsLogger

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

the class PlotPluginTest method no_exception_visit_plot_page.

/**
 * Test if NumberFormatException is logged only if a non-zero length string is found in the data set.
 * Fix introduced in plot@1.10
 */
@Test
@Issue("JENKINS-25849")
public void no_exception_visit_plot_page() {
    job.configure();
    job.copyResource(resource(csvWithStringsFilePath));
    PlotPublisher pub = job.addPublisher(PlotPublisher.class);
    Plot plot = pub.getPlot(1);
    plot.setGroup("My group");
    plot.setTitle("My plot");
    plot.addDataSeries(CsvDataSeries.class, csvWithStringsFileName);
    job.save();
    job.startBuild().shouldSucceed();
    job.visit("plot");
    assertThatBuildHasPlot("My plot", "My group");
    JenkinsLogger jLog = job.getJenkins().getLogger("all");
    Pattern p1 = Pattern.compile(EMPTY_STRING, Pattern.DOTALL);
    Pattern p2 = Pattern.compile(NON_EMPTY_STRING, Pattern.DOTALL);
    assertThat("NumberFormatException was logged for empty string.", jLog.hasLogged(p1), is(false));
    assertThat("NumberFormatException was not logged for non empty string.", jLog.hasLogged(p2), is(true));
}
Also used : Pattern(java.util.regex.Pattern) JenkinsLogger(org.jenkinsci.test.acceptance.po.JenkinsLogger) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

JenkinsLogger (org.jenkinsci.test.acceptance.po.JenkinsLogger)3 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)2 Test (org.junit.Test)2 Issue (org.jvnet.hudson.test.Issue)2 Pattern (java.util.regex.Pattern)1 Description (org.hamcrest.Description)1 Matcher (org.jenkinsci.test.acceptance.Matcher)1 NoSuchElementException (org.openqa.selenium.NoSuchElementException)1 TimeoutException (org.openqa.selenium.TimeoutException)1