package org.dita.dost.invoker;

import org.dita.dost.exception.DITAOTException;
import org.dita.dost.invoker.CommandLineInvoker;
import org.junit.Test;

public class TestCmdInvoker {

	@Test(expected = DITAOTException.class)
	public void testProcessArguments() throws Exception {
		String input[]={"/i:abc.ditamap","/transtypexhtml"};
		CommandLineInvoker test = new CommandLineInvoker();
		test.processArguments(input);
	}
	
	@Test(expected = DITAOTException.class)
	public void testProcessArgsWrongParam() throws Exception {
		String input[]={"/i:abc.ditamap","/abc:def"};
		CommandLineInvoker test = new CommandLineInvoker();		
		test.processArguments(input);
	}
	
	@Test(expected = DITAOTException.class)
	public void testProcessArgsEmptyValue() throws Exception {
		String input[]={"/i:"};
		CommandLineInvoker test = new CommandLineInvoker();
		test.processArguments(input);
	}

}

@@ -25,16 +25,208 @@
 voker;%0A%0A
+import static org.junit.Assert.assertTrue;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.io.PrintStream;%0A%0Aimport org.dita.dost.TestUtils;%0A
 import o
@@ -280,44 +280,44 @@
 org.
-dita.dost.invoker.CommandLineInvoker
+junit.After;%0Aimport org.junit.Before
 ;%0Aim
@@ -374,47 +374,276 @@
 %7B%0A%0A%09
-@Test(expected = DITAOTException.class)
+private final PrintStream originalOut = System.out;%0A%09%0A%09private File tempDir;%0A%09private String tempArg;%0A%09%0A%09@Before%0A%09public void setUp() throws IOException %7B%0A%09%09tempDir = TestUtils.createTempDir(getClass());%0A%09%09tempArg = %22/tempdir:%22 + tempDir.getAbsolutePath();%0A%09%7D%0A%09%0A%09@Test
 %0A%09pu
@@ -688,32 +688,38 @@
 s Exception %7B%0A%09%09
+final 
 String input%5B%5D=%7B
@@ -708,34 +708,37 @@
 l String input%5B%5D
-=%7B
+ = %7B 
 %22/i:abc.ditamap%22
@@ -738,16 +738,17 @@
 itamap%22,
+ 
 %22/transt
@@ -754,19 +754,36 @@
 type
+:
 xhtml%22
-%7D;%0A%09%09
+, tempArg %7D;%0A%09%09final 
 Comm
@@ -857,33 +857,32 @@
 ents(input);%0A%09%7D%0A
-%09
 %0A%09@Test(expected
@@ -961,32 +961,110 @@
 s Exception %7B%0A%09%09
+final ByteArrayOutputStream outContent = new ByteArrayOutputStream();%0A%09%09final 
 String input%5B%5D=%7B
@@ -1057,26 +1057,29 @@
 ring input%5B%5D
-=%7B
+ = %7B 
 %22/i:abc.dita
@@ -1083,16 +1083,17 @@
 itamap%22,
+ 
 %22/abc:de
@@ -1094,21 +1094,28 @@
 abc:def%22
+ 
 %7D;%0A%09%09
+final 
 CommandL
@@ -1161,47 +1161,237 @@
 r();
+%0A
 %09%09
-%0A%09%09test.processArguments(input);
+try %7B%0A%09%09%09System.setOut(new PrintStream(outContent));%0A%09%09%09test.processArguments(input);%0A%09%09%7D catch (final DITAOTException e) %7B%0A%09%09%09throw e;%0A%09%09%7D finally %7B%0A%09%09%09System.setOut(originalOut);%0A%09%09%09assertTrue(outContent.size() %3E 0);%0A%09%09%7D
 %0A%09%7D%0A
-%09
 %0A%09@T
@@ -1490,16 +1490,94 @@
 ion %7B%0A%09%09
+final ByteArrayOutputStream outContent = new ByteArrayOutputStream();%0A%09%09final 
 String i
@@ -1586,20 +1586,30 @@
 ut%5B%5D
-=%7B
+ = %7B 
 %22/i:%22
+ 
 %7D;%0A%09%09
+final 
 Comm
@@ -1663,39 +1663,324 @@
 %0A%09%09t
-est.processArguments(input
+ry %7B%0A%09%09%09System.setOut(new PrintStream(outContent));%0A%09%09%09test.processArguments(input);%0A%09%09%7D catch (final DITAOTException e) %7B%0A%09%09%09throw e;%0A%09%09%7D finally %7B%0A%09%09%09System.setOut(originalOut);%0A%09%09%09assertTrue(outContent.size() %3E 0);%0A%09%09%7D%0A%09%7D%0A%0A%09@After%0A%09public void tearDown() throws IOException %7B%0A%09%09TestUtils.forceDelete(tempDir
 );%0A%09%7D%0A
+%09
 %0A%7D%0A

Fix invoker unit test - ID: 3159001