View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar.test;
21  
22  import java.io.File;
23  
24  import junit.framework.Assert;
25  import junit.framework.TestCase;
26  
27  import org.apache.maven.plugin.MojoExecutionException;
28  import org.apache.maven.plugin.MojoFailureException;
29  import org.apache.maven.plugin.logging.Log;
30  import org.apache.maven.plugin.logging.SystemStreamLog;
31  
32  import com.github.maven_nar.AbstractNarLayout;
33  import com.github.maven_nar.Library;
34  import com.github.maven_nar.NarFileLayout;
35  import com.github.maven_nar.NarFileLayout10;
36  import com.github.maven_nar.NarLayout;
37  import com.github.maven_nar.NarLayout20;
38  
39  /**
40   * @author Mark Donszelmann (Mark.Donszelmann@gmail.com)
41   */
42  public class TestNarLayout20 extends TestCase {
43    private NarFileLayout fileLayout;
44  
45    private Log log;
46  
47    private NarLayout layout;
48  
49    private File baseDir;
50  
51    private String aol;
52  
53    private String type;
54  
55    /*
56     * (non-Javadoc)
57     * 
58     * @see junit.framework.TestCase#setUp()
59     */
60    @Override
61    protected void setUp() throws Exception {
62      this.log = new SystemStreamLog();
63      this.fileLayout = new NarFileLayout10();
64      this.layout = new NarLayout20(this.log);
65      this.baseDir = new File("/Users/maven");
66      this.aol = "x86_64-MacOSX-g++";
67      this.type = Library.SHARED;
68    }
69  
70    /**
71     * Test method for
72     * {@link com.github.maven_nar.NarLayout20#getBinDirectory(java.io.File, java.lang.String)}
73     * .
74     * 
75     * @throws MojoFailureException
76     * @throws MojoExecutionException
77     */
78    public final void testGetBinDirectory() throws MojoExecutionException, MojoFailureException {
79      Assert.assertEquals(new File(this.baseDir, this.fileLayout.getBinDirectory(this.aol)),
80          this.layout.getBinDirectory(this.baseDir, null, null, this.aol));
81    }
82  
83    /**
84     * Test method for
85     * {@link com.github.maven_nar.NarLayout20#getIncludeDirectory(java.io.File)}.
86     * 
87     * @throws MojoFailureException
88     * @throws MojoExecutionException
89     */
90    public final void testGetIncludeDirectory() throws MojoExecutionException, MojoFailureException {
91      Assert.assertEquals(new File(this.baseDir, this.fileLayout.getIncludeDirectory()),
92          this.layout.getIncludeDirectory(this.baseDir, null, null));
93    }
94  
95    public final void testGetLayout() throws MojoExecutionException {
96      AbstractNarLayout.getLayout("NarLayout20", this.log);
97    }
98  
99    /**
100    * Test method for
101    * {@link com.github.maven_nar.NarLayout20#getLibDirectory(java.io.File, java.lang.String, java.lang.String)}
102    * .
103    * 
104    * @throws MojoFailureException
105    * @throws MojoExecutionException
106    */
107   public final void testGetLibDirectory() throws MojoExecutionException, MojoFailureException {
108     Assert.assertEquals(new File(this.baseDir, this.fileLayout.getLibDirectory(this.aol, this.type)),
109         this.layout.getLibDirectory(this.baseDir, null, null, this.aol, this.type));
110   }
111 }