Search in sources :

Example 6 with StringContains

use of org.hamcrest.core.StringContains in project cactoos by yegor256.

the class LoggingOutputTest method logWriteToLargeTextFile.

@Test
@SuppressWarnings("unchecked")
public void logWriteToLargeTextFile() throws Exception {
    final Logger logger = new FakeLogger();
    final Path temp = this.folder.newFolder("ccts-1").toPath();
    final Path path = temp.resolve("x/y/z/file.txt");
    try (OutputStream output = new LoggingOutput(new OutputTo(path), "text file", logger).stream()) {
        new LengthOf(new TeeInput(new ResourceOf("org/cactoos/large-text.txt"), new OutputTo(output))).value();
    }
    new Assertion<>("Must log write and close operations to text file", logger.toString(), new AllOf<>(new IsNot<String>(new StringContains("Written 16384 byte(s) to text file")), new StringContains("Written 74536 byte(s) to text file"), new StringContains("Closed output stream from text file"))).affirm();
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Logger(java.util.logging.Logger) LengthOf(org.cactoos.scalar.LengthOf) AllOf(org.hamcrest.core.AllOf) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 7 with StringContains

use of org.hamcrest.core.StringContains in project jbosstools-openshift by jbosstools.

the class CreateServerAdapterTest method finishNewServerAdapterWizardAndVerifyExistence.

public void finishNewServerAdapterWizardAndVerifyExistence() {
    new FinishButton().click();
    new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.ADAPTER));
    boolean jobExists = false;
    try {
        new WaitUntil(new JobIsRunning(new StringContains(JOB_NAME)), TimePeriod.getCustom(5));
        jobExists = true;
    } catch (WaitTimeoutExpiredException e) {
    // job is not running, do nothing
    }
    if (jobExists) {
        new WaitUntil(new JobIsKilled(JOB_NAME), TimePeriod.VERY_LONG);
    }
    assertTrue("OpenShift server adapter was not created.", new ServerAdapterExists(Version.OPENSHIFT3, OpenShiftResources.EAP_SERVICE, "Service").test());
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) FinishButton(org.eclipse.reddeer.swt.impl.button.FinishButton) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) ServerAdapterExists(org.jboss.tools.openshift.reddeer.condition.ServerAdapterExists) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) JobIsKilled(org.eclipse.reddeer.workbench.core.condition.JobIsKilled) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) StringContains(org.hamcrest.core.StringContains)

Example 8 with StringContains

use of org.hamcrest.core.StringContains in project jbosstools-openshift by jbosstools.

the class DeployDockerImageTest method verifyDeployedHelloWorldDockerImage.

/**
 * Verifies whether an application pod has been created and application is running successfully.
 */
private void verifyDeployedHelloWorldDockerImage(String projectName) {
    new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).refresh();
    try {
        new WaitUntil(new OpenShiftResourceExists(Resource.POD, new StringContains("hello-openshift"), ResourceState.RUNNING, projectName, openshiftConnectionRequirement.getConnection()), TimePeriod.VERY_LONG);
    } catch (WaitTimeoutExpiredException ex) {
        fail("There should be a running application pod for a deployed docker image, " + "but it does not exist.");
    }
    new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).refresh();
    new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).getProject(projectName).getOpenShiftResources(Resource.ROUTE).get(0).select();
    new ContextMenuItem(OpenShiftLabel.ContextMenu.SHOW_IN_BROWSER).select();
    try {
        // getRouteURL("hello-openshift", projectName),
        new WaitUntil(new BrowserContainsText("Hello OpenShift!"), TimePeriod.VERY_LONG);
    } catch (WaitTimeoutExpiredException ex) {
        fail("Browser does not contain hello world content.");
    }
}
Also used : ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) BrowserContainsText(org.jboss.tools.openshift.reddeer.condition.BrowserContainsText) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) OpenShiftResourceExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists) StringContains(org.hamcrest.core.StringContains)

Example 9 with StringContains

use of org.hamcrest.core.StringContains in project nextprot-api by calipho-sib.

the class XMLWebTest method shouldGetXmlWellFormatted.

@Test
public void shouldGetXmlWellFormatted() throws Exception {
    ResultActions result = this.mockMvc.perform(get("/entry/NX_P01308.xml"));
    result.andExpect(xpath("//publication[@id='28338750']").exists());
    // β-sheets
    result.andExpect(content().string(new StringContains("β-sheets")));
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) StringContains(org.hamcrest.core.StringContains) MVCBaseSecurityIntegrationTest(org.nextprot.api.web.dbunit.base.mvc.MVCBaseSecurityIntegrationTest) Test(org.junit.Test)

Example 10 with StringContains

use of org.hamcrest.core.StringContains in project nakadi by zalando.

the class EventTypeControllerTest method whenPostOptionsRetentionTimeSmallerThanMin.

@Test
public void whenPostOptionsRetentionTimeSmallerThanMin() throws Exception {
    final EventType defaultEventType = TestUtils.buildDefaultEventType();
    defaultEventType.getOptions().setRetentionTime(1079999L);
    postEventType(defaultEventType).andExpect(status().is4xxClientError()).andExpect(content().string(new StringContains("Field \\\"options.retention_time\\\" can not be less than 10800000")));
}
Also used : EventType(org.zalando.nakadi.domain.EventType) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Aggregations

StringContains (org.hamcrest.core.StringContains)30 Test (org.junit.Test)21 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Logger (java.util.logging.Logger)5 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)5 OutputStream (java.io.OutputStream)4 LengthOf (org.cactoos.scalar.LengthOf)3 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)3 EventType (org.zalando.nakadi.domain.EventType)3 StringContainsProto (androidx.test.espresso.proto.matcher13.HamcrestMatchersv13.StringContainsProto)2 GenericRemoteMessage (androidx.test.espresso.remote.GenericRemoteMessage)2 SmallTest (androidx.test.filters.SmallTest)2 Path (java.nio.file.Path)2 BytesOf (org.cactoos.bytes.BytesOf)2 NamedThreadHasStatus (org.eclipse.reddeer.core.condition.NamedThreadHasStatus)2 Problem (org.eclipse.reddeer.eclipse.ui.problems.Problem)2 ProblemsView (org.eclipse.reddeer.eclipse.ui.views.markers.ProblemsView)2 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)2 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)2