package io.xunyss.commons.exec;

import java.util.StringTokenizer;

import org.junit.Test;

/**
 *
 * @author XUNYSS
 */
public class ProcessExecutorTest {
	
	@Test
	public void openssl() throws Exception {
		String binName = "D:\\xdev\\git\\commons\\openssl\\target\\classes\\io\\xunyss\\openssl\\binary\\win32\\openssl.exe";
		
		ProcessExecutor processExecutor = new ProcessExecutor();
//		processExecutor.execute(binName, "asn1parse", "-genstr", "UTF8:\"hello world\"");
//		processExecutor.execute(binName, "asn1parse", "-genstr", "UTF8:\"hello", "", "world\"");

//		processExecutor.execute(binName, "version");
		
		processExecutor.execute1("cmd /c dir");
	}
	
	@Test
	public void dir() throws Exception {
		StreamHandler streamHandler = new StreamHandler();
		
		ProcessExecutor processExecutor = new ProcessExecutor();
		processExecutor.setStreamHandler(streamHandler);
		processExecutor.execute1("cmd", "/C", "dir");
	}
	
	@Test
	public void notepad() throws Exception {
		ProcessExecutor processExecutor = new ProcessExecutor();
		String cmd = "D:\\xdev\\git\\commons\\openssl\\target\\classes\\io\\xunyss\\openssl\\binary\\win32\\openssl.exe asn1parse -genstr UTF8:\"hello world\"";
//		processExecutor.execute("notepad");
		processExecutor.execute1(cmd);
	}
	
	
	@Test
	public void token() {
		String cmd = "openssl.exe asn1parse -genstr UTF8:\"hello world\"";
		System.out.println(cmd.split(" ").length);
		StringTokenizer stk = new StringTokenizer(cmd);
		System.out.println(stk.countTokens());
	}
}

@@ -216,25 +216,25 @@
  binName = %22
-D
+C
 :%5C%5Cxdev%5C%5Cgit
@@ -1053,9 +1053,9 @@
  = %22
-D
+C
 :%5C%5Cx

test code