Package net.raymanoz.util

Source Code of net.raymanoz.util.ScriptExecuterCommandLineParserImplTests

package net.raymanoz.util;

import net.raymanoz.io.File;

import org.junit.Test;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

public class ScriptExecuterCommandLineParserImplTests {

  @Test(expected=IllegalArgumentException.class)
  public void throwsIlliegalArgumentExceptionIfNoScriptHolderInCmdLine(){
    new ScriptExecuterCommandLineParserImpl("Invalid {script} holder");
  }
 
  @Test(expected=IllegalArgumentException.class)
  public void throwsIlliegalArgumentExceptionIfNullCmdLine(){
    new ScriptExecuterCommandLineParserImpl(null);
  }
 
  private void checkParser(String cmdLine, String absolutePath,  String ... expectedArguments){
    File executeFile = mock(File.class);
    when(executeFile.getAbsolutePath()).thenReturn(absolutePath);
    ScriptExecuterCommandLineParser parser = new ScriptExecuterCommandLineParserImpl(cmdLine);
    assertArrayEquals(expectedArguments, parser.processBuilderArgs(executeFile));
  }
 
  @Test
  public void checkParsing(){
    checkParser("\"S:\\One\\Hellp\\Out\\..\\There\" ${script} -p" , "A Path of Absolute", "S:\\One\\Hellp\\Out\\..\\There", "A Path of Absolute", "-p");
    checkParser("'One' -p '${script}'" , "Different Path", "One", "-p", "Different Path");
    checkParser("One -p ${script}" , "Different Path", "One", "-p", "Different Path");
    checkParser("One -p${script}" , "Different Path", "One", "-pDifferent Path");
    checkParser("Two ${script}" , "Different Path", "Two", "Different Path");
    checkParser("Two ${script} -x${script}" , "Different Path", "Two", "Different Path", "-xDifferent Path");
  }
}
TOP

Related Classes of net.raymanoz.util.ScriptExecuterCommandLineParserImplTests

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.