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.NarConstants;
35  import com.github.maven_nar.NarFileLayout;
36  import com.github.maven_nar.NarFileLayout10;
37  import com.github.maven_nar.NarLayout;
38  import com.github.maven_nar.NarLayout21;
39  
40  /**
41   * @author Mark Donszelmann (Mark.Donszelmann@gmail.com)
42   */
43  public class TestNarLayout21 extends TestCase {
44    private NarFileLayout fileLayout;
45  
46    private Log log;
47  
48    private NarLayout layout;
49  
50    private File baseDir;
51  
52    private String artifactId;
53  
54    private String version;
55  
56    private String aol;
57  
58    private String type;
59  
60    /*
61     * (non-Javadoc)
62     * 
63     * @see junit.framework.TestCase#setUp()
64     */
65    @Override
66    protected void setUp() throws Exception {
67      this.fileLayout = new NarFileLayout10();
68      this.artifactId = "artifactId";
69      this.version = "version";
70      this.baseDir = new File("/Users/maven");
71      this.aol = "x86_64-MacOSX-g++";
72      this.type = Library.SHARED;
73  
74      this.log = new SystemStreamLog();
75      this.layout = new NarLayout21(this.log);
76    }
77  
78    /**
79     * Test method for
80     * {@link com.github.maven_nar.NarLayout20#getBinDirectory(java.io.File, java.lang.String)}
81     * .
82     * 
83     * @throws MojoFailureException
84     * @throws MojoExecutionException
85     */
86    public final void testGetBinDirectory() throws MojoExecutionException, MojoFailureException {
87      Assert.assertEquals(new File(this.baseDir, this.artifactId + "-" + this.version + "-" + this.aol + "-"
88          + "executable" + File.separator + this.fileLayout.getBinDirectory(this.aol)),
89          this.layout.getBinDirectory(this.baseDir, this.artifactId, this.version, this.aol));
90    }
91  
92    /**
93     * Test method for
94     * {@link com.github.maven_nar.NarLayout20#getIncludeDirectory(java.io.File)}.
95     * 
96     * @throws MojoFailureException
97     * @throws MojoExecutionException
98     */
99    public final void testGetIncludeDirectory() throws MojoExecutionException, MojoFailureException {
100     Assert.assertEquals(new File(this.baseDir, this.artifactId + "-" + this.version + "-" + NarConstants.NAR_NO_ARCH
101         + File.separator + this.fileLayout.getIncludeDirectory()),
102         this.layout.getIncludeDirectory(this.baseDir, this.artifactId, this.version));
103   }
104 
105   public final void testGetLayout() throws MojoExecutionException {
106     AbstractNarLayout.getLayout("NarLayout21", this.log);
107   }
108 
109   /**
110    * Test method for
111    * {@link com.github.maven_nar.NarLayout20#getLibDirectory(java.io.File, java.lang.String, java.lang.String)}
112    * .
113    * 
114    * @throws MojoFailureException
115    * @throws MojoExecutionException
116    */
117   public final void testGetLibDirectory() throws MojoExecutionException, MojoFailureException {
118     Assert.assertEquals(new File(this.baseDir, this.artifactId + "-" + this.version + "-" + this.aol + "-" + this.type
119         + File.separator + this.fileLayout.getLibDirectory(this.aol, this.type)),
120         this.layout.getLibDirectory(this.baseDir, this.artifactId, this.version, this.aol, this.type));
121   }
122 }