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.cpptasks.compiler;
21  
22  import java.io.File;
23  
24  import com.github.maven_nar.cpptasks.ProcessorParam;
25  import com.github.maven_nar.cpptasks.gcc.GccCCompiler;
26  
27  /**
28   */
29  public class TestCommandLineCompilerConfiguration extends TestCompilerConfiguration {
30    private final CommandLineCompiler compiler;
31    private final String compilerId;
32  
33    public TestCommandLineCompilerConfiguration(final String name) {
34      super(name);
35      this.compiler = GccCCompiler.getInstance();
36      this.compilerId = this.compiler.getIdentifier();
37    }
38  
39    @Override
40    protected CompilerConfiguration create() {
41      return new CommandLineCompilerConfiguration(this.compiler, "dummy", new File[0], new File[0], new File[0], "",
42          new String[] {
43            "/Id:/gcc"
44          }, new ProcessorParam[0], false, new String[0]);
45    }
46  
47    public void testConstructorNullCompiler() {
48      try {
49        new CommandLineCompilerConfiguration(null, "dummy", new File[0], new File[0], new File[0], "", new String[0],
50            new ProcessorParam[0], false, new String[0]);
51        fail("Should throw exception for null compiler");
52      } catch (final NullPointerException ex) {
53      }
54    }
55  
56    public void testGetIdentifier() {
57      final CompilerConfiguration config = create();
58      final String id = config.getIdentifier();
59      assertEquals("dummy", id);
60    }
61  
62    public void testToString() {
63      final CompilerConfiguration config = create();
64      final String toString = config.toString();
65      assertEquals("dummy", toString);
66    }
67  }