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 java.io.File;
22  
23  import static org.junit.Assert.assertEquals;
24  // import static org.junit.Assert.assertNotNull;
25  
26  import org.junit.Test;
27  
28  public class SettingsTest {
29  
30  	@Test
31    public void testSettings() throws BuildFailureException {
32      Settings settings = new Settings();
33  
34      // invoked from within maven in base directory with pom.xml 
35      File baseDirectory = new File(System.getProperty("user.dir"));
36      settings.setBaseDirectory(baseDirectory);
37      // mvn project has default file structure 
38      File targetDirectory = new File(baseDirectory, "target");
39      settings.setTargetDirectory(targetDirectory);
40      File targetSiteDirectory = new File(targetDirectory, "site");
41      settings.setTargetSiteDirectory(targetSiteDirectory);
42  
43      // test getTexSrcDirectoryFile() and setTexSrcDirectory(...) 
44      new File(baseDirectory, Settings.SST).mkdir();
45      //assertEquals(new File(baseDirectory, Settings.SST),
46      assertEquals(new File(Settings.SST),
47          // may throw BuildFailureException
48          settings.getTexSrcDirectoryFile());
49      settings.setBaseDirectory(targetDirectory);
50      targetSiteDirectory.mkdir();
51      settings.setTexSrcDirectory("target/site");
52      // may throw BuildFailureException 
53  
54      assertEquals(targetSiteDirectory, settings.getTexSrcDirectoryFile().getAbsoluteFile());
55  
56      // FIXME: Further tests required. 
57  
58      }
59  
60  	public static void main(String[] args) throws Exception {
61  		//Class<?> cls = SettingsTest.class
62  		//    .getMethod("testSettings")
63  		//    .getAnnotation(Test.class).getClass();
64  		//System.out.println("cls: "+);
65  
66  	}
67  
68  }