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.Engine;
22  import org.owasp.dependencycheck.dependency.Dependency;
23  
24  /**
25   *
26   * @author Jeremy Long
27   */
28  public class FalsePositiveAnalyzerTest {
29  
30      /**
31       * Test of getName method, of class FalsePositiveAnalyzer.
32       */
33      @Test
34      public void testGetName() {
35          FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
36          String expResult = "False Positive Analyzer";
37          String result = instance.getName();
38          assertEquals(expResult, result);
39      }
40  
41      /**
42       * Test of getAnalysisPhase method, of class FalsePositiveAnalyzer.
43       */
44      @Test
45      public void testGetAnalysisPhase() {
46          FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
47          AnalysisPhase expResult = AnalysisPhase.POST_IDENTIFIER_ANALYSIS;
48          AnalysisPhase result = instance.getAnalysisPhase();
49          assertEquals(expResult, result);
50      }
51  
52      /**
53       * Test of analyze method, of class FalsePositiveAnalyzer.
54       */
55      @Test
56      public void testAnalyze() throws Exception {
57          Dependency dependency = new Dependency();
58          dependency.setFileName("pom.xml");
59          dependency.setFilePath("pom.xml");
60          dependency.addIdentifier("cpe", "cpe:/a:file:file:1.2.1", "http://some.org/url");
61          Engine engine = null;
62          FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
63          int before = dependency.getIdentifiers().size();
64          instance.analyze(dependency, engine);
65          int after = dependency.getIdentifiers().size();
66          assertTrue(before > after);
67      }
68  
69  }