/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.ow2.choreos.utils;

import static org.junit.Assert.assertTrue;

import java.util.Calendar;

import org.junit.Test;

public class OSCommandTest {

    @Test
    public void testRunLocalCommand() throws CommandLineException {
        OSCommand com = new OSCommand("date");
        String result = com.execute();
        Calendar cal = Calendar.getInstance();
        int today = cal.get(Calendar.DAY_OF_MONTH);
        assertTrue(result.contains(Integer.toString(today)));
    }

    @Test(expected = CommandLineException.class)
    public void shouldThrowExceptionBecauseExistStatus() throws CommandLineException {
        OSCommand com = new OSCommand("this command does not exit");
        com.execute();
    }

    @Test(expected = CommandLineException.class)
    public void shouldThrowExceptionBecauseExistStatus2() throws CommandLineException {
        OSCommand com = new OSCommand("cat arquivo_que_nao_existe");
        com.execute();
    }

}

@@ -272,40 +272,14 @@
 sert
-True;%0A%0Aimport java.util.Calendar
+Equals
 ;%0A%0Ai
@@ -452,12 +452,15 @@
 nd(%22
-date
+echo 42
 %22);%0A
@@ -510,157 +510,50 @@
     
-Calendar cal = Calendar.getInstance();%0A        int today = cal.get(Calendar.DAY_OF_MONTH);%0A        assertTrue(result.contains(Integer.toString(today)
+assertEquals(%2242%22, result.replace(%22%5Cn%22, %22%22
 ));%0A

simplifying testRunLocalCommand