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