View Javadoc
1   /*
2    * The akquinet maven-latex-plugin project
3    *
4    * Copyright (c) 2011 by akquinet tech@spree GmbH
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package eu.simuline.m2latex.core;
20  
21  // import eu.simuline.m2latex.mojo.MavenLogWrapper;
22  import java.io.File;
23  import java.io.IOException;
24  
25  // import junit.framework.TestCase;
26  
27  // import org.apache.maven.plugin.logging.SystemStreamLog;
28  
29  // import static org.junit.Assert.assertEquals;
30  
31  import org.junit.Test;
32  // import org.junit.Ignore;
33  import org.junit.Before;
34  import org.junit.After;
35  
36  public class CommandExecutorTest {
37    private final static File WORKING_DIR =
38        new File(System.getProperty("unitTestResourcesDir"));
39  
40    // FIXME: occurs also in other testclasses: 
41    // to be unified. 
42    private static void cleanWorkingDir() {
43      assert WORKING_DIR.isDirectory() : "Expected directory. ";
44      File[] files = WORKING_DIR.listFiles();
45      assert files != null : "Working directory is not readable. ";
46      for (File file : files) {
47        if (!file.isHidden()) {
48          file.delete();
49        }
50      }
51    }
52  
53    @Before
54    public void setUp() throws IOException {
55      cleanWorkingDir();
56    }
57  
58    @After
59    public void tearDown() throws IOException {
60      cleanWorkingDir();
61    }
62  
63    @Test
64    public void testExecute() throws BuildFailureException {
65      //CommandExecutor executor = 
66      //new CommandExecutor(new MavenLogWrapper(new SystemStreamLog()));
67      //String touchFile = "cmdLineExe.touch";
68      //String output = executor.execute(WORKING_DIR, 
69      //				 null, 
70      ///				 "touch", 
71      //				 new String[] {touchFile},
72      //				 new File(WORKING_DIR, touchFile)).output;
73      //assertEquals(echoText, output.subSequence(0, echoText.length()));
74    }
75  
76    // void mockExecute() throws BuildFailureException {
77    // 	File res = new File("/tmp/exists.latexPlugin");
78    // 	res.delete();
79    //     this.executor.execute(new File("/tmp/"),
80    // 			      null,
81    // 			      "touch",
82    // 			      new String[] {res.getName()},
83    // 			      res);
84    //     executorCtrl.setMatcher(MockControl.ARRAY_MATCHER);
85    //     executorCtrl.setReturnValue(null);
86    // }
87  }