aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/system/ProcessExecuterTestCase.java
blob: a7308828397a3a2f2bbcfc30a3ef1236735ccdd2 (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
27
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.system;

import com.yahoo.collections.Pair;
import com.yahoo.io.IOUtils;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

import static org.junit.Assert.assertEquals;

/**
 * @author bratseth
 */
public class ProcessExecuterTestCase {

    @Test
    public void testIt() throws IOException {
        IOUtils.writeFile("tmp123.txt","hello\nworld",false);
        ProcessExecuter exec=new ProcessExecuter();
        assertEquals(new Pair<>(0, "hello\nworld"), exec.exec("cat tmp123.txt"));
        assertEquals(new Pair<>(0, "hello\nworld"), exec.exec(new String[]{"cat", "tmp123.txt"}));
        new File("tmp123.txt").delete();
    }
    
}