View Javadoc
1   /*
2    * Copyright 2014 OWASP.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.owasp.dependencycheck.analyzer;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertTrue;
20  import org.junit.Test;
21  import org.owasp.dependencycheck.BaseTest;
22  import org.owasp.dependencycheck.Engine;
23  import org.owasp.dependencycheck.dependency.Dependency;
24  
25  /**
26   *
27   * @author Jeremy Long
28   */
29  public class FalsePositiveAnalyzerTest extends BaseTest {
30  
31      /**
32       * Test of getName method, of class FalsePositiveAnalyzer.
33       */
34      @Test
35      public void testGetName() {
36          FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
37          String expResult = "False Positive Analyzer";
38          String result = instance.getName();
39          assertEquals(expResult, result);
40      }
41  
42      /**
43       * Test of getAnalysisPhase method, of class FalsePositiveAnalyzer.
44       */
45      @Test
46      public void testGetAnalysisPhase() {
47          FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
48          AnalysisPhase expResult = AnalysisPhase.POST_IDENTIFIER_ANALYSIS;
49          AnalysisPhase result = instance.getAnalysisPhase();
50          assertEquals(expResult, result);
51      }
52  
53      /**
54       * Test of analyze method, of class FalsePositiveAnalyzer.
55       */
56      @Test
57      public void testAnalyze() throws Exception {
58          Dependency dependency = new Dependency();
59          dependency.setFileName("pom.xml");
60          dependency.setFilePath("pom.xml");
61          dependency.addIdentifier("cpe", "cpe:/a:file:file:1.2.1", "http://some.org/url");
62          Engine engine = null;
63          FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
64          int before = dependency.getIdentifiers().size();
65          instance.analyze(dependency, engine);
66          int after = dependency.getIdentifiers().size();
67          assertTrue(before > after);
68      }
69  
70  }