summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/system/execution/ProcessExecutorTest.java
blob: 607a223b00bf7f71133adad66408115d4d91e7ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.system.execution;

import org.junit.Test;

import java.time.Duration;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * @author gjoranv
 */
public class ProcessExecutorTest {

    @Test
    public void echo_can_be_executed() throws Exception {
        final String message = "Hello from executor!";
        ProcessExecutor executor = new ProcessExecutor.Builder(Duration.ofSeconds(10)).build();
        Optional<ProcessResult> result = executor.execute("echo " + message);
        assertTrue(result.isPresent());
        assertEquals(message, result.get().stdOut.trim());
        assertEquals("", result.get().stdErr);
    }
}