1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.analyzer;
19
20 import java.io.File;
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertTrue;
23 import org.junit.Test;
24 import org.owasp.dependencycheck.BaseTest;
25 import org.owasp.dependencycheck.dependency.Dependency;
26
27
28
29
30
31 public class FileNameAnalyzerTest extends BaseTest {
32
33
34
35
36 @Test
37 public void testGetName() {
38 FileNameAnalyzer instance = new FileNameAnalyzer();
39 String expResult = "File Name Analyzer";
40 String result = instance.getName();
41 assertEquals(expResult, result);
42 }
43
44
45
46
47 @Test
48 public void testGetAnalysisPhase() {
49 FileNameAnalyzer instance = new FileNameAnalyzer();
50 AnalysisPhase expResult = AnalysisPhase.INFORMATION_COLLECTION;
51 AnalysisPhase result = instance.getAnalysisPhase();
52 assertEquals(expResult, result);
53 }
54
55
56
57
58 @Test
59 public void testAnalyze() throws Exception {
60
61 File struts = BaseTest.getResourceAsFile(this, "struts2-core-2.1.2.jar");
62 Dependency resultStruts = new Dependency(struts);
63
64 File axis = BaseTest.getResourceAsFile(this, "axis2-adb-1.4.1.jar");
65 Dependency resultAxis = new Dependency(axis);
66 FileNameAnalyzer instance = new FileNameAnalyzer();
67 instance.analyze(resultStruts, null);
68 assertTrue(resultStruts.getVendorEvidence().toString().toLowerCase().contains("struts"));
69
70 instance.analyze(resultAxis, null);
71 assertTrue(resultStruts.getVersionEvidence().toString().toLowerCase().contains("2.1.2"));
72
73 }
74
75
76
77
78 @Test
79 public void testInitialize() throws Exception {
80 FileNameAnalyzer instance = new FileNameAnalyzer();
81 instance.initialize();
82 assertTrue(true);
83 }
84
85
86
87
88 @Test
89 public void testClose() throws Exception {
90 FileNameAnalyzer instance = new FileNameAnalyzer();
91 instance.close();
92 assertTrue(true);
93 }
94 }