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 static org.junit.Assert.assertEquals;
21 import org.junit.Test;
22 import org.owasp.dependencycheck.BaseTest;
23 import org.owasp.dependencycheck.dependency.Dependency;
24
25
26
27
28
29 public class DependencyBundlingAnalyzerTest extends BaseTest {
30
31
32
33
34 @Test
35 public void testGetName() {
36 DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer();
37 String expResult = "Dependency Bundling Analyzer";
38 String result = instance.getName();
39 assertEquals(expResult, result);
40 }
41
42
43
44
45 @Test
46 public void testGetAnalysisPhase() {
47 DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer();
48 AnalysisPhase expResult = AnalysisPhase.PRE_FINDING_ANALYSIS;
49 AnalysisPhase result = instance.getAnalysisPhase();
50 assertEquals(expResult, result);
51 }
52
53
54
55
56 @Test
57 public void testAnalyze() throws Exception {
58
59
60
61
62
63
64 }
65
66
67
68
69 @Test
70 public void testIsCore() {
71 Dependency left = new Dependency();
72 Dependency right = new Dependency();
73
74 left.setFileName("axis2-kernel-1.4.1.jar");
75 right.setFileName("axis2-adb-1.4.1.jar");
76 DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer();
77 boolean expResult = true;
78 boolean result = instance.isCore(left, right);
79 assertEquals(expResult, result);
80
81 left.setFileName("struts-1.2.7.jar");
82 right.setFileName("file.tar.gz\\file.tar\\struts.jar");
83
84 expResult = true;
85 result = instance.isCore(left, right);
86 assertEquals(expResult, result);
87 }
88
89 @Test
90 public void testFirstPathIsShortest() {
91 DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer();
92
93 String left = "./a/c.jar";
94 String right = "./d/e/f.jar";
95 boolean expResult = true;
96 boolean result = instance.firstPathIsShortest(left, right);
97 assertEquals(expResult, result);
98
99 left = "./a/b/c.jar";
100 right = "./d/e/f.jar";
101 expResult = true;
102 result = instance.firstPathIsShortest(left, right);
103 assertEquals(expResult, result);
104
105 left = "./d/b/c.jar";
106 right = "./a/e/f.jar";
107 expResult = false;
108 result = instance.firstPathIsShortest(left, right);
109 assertEquals(expResult, result);
110
111 left = "./a/b/c.jar";
112 right = "./d/f.jar";
113 expResult = false;
114 result = instance.firstPathIsShortest(left, right);
115 assertEquals(expResult, result);
116
117 left = "./a/b/c.jar";
118 right = "./a/b/c.jar";
119 expResult = true;
120 result = instance.firstPathIsShortest(left, right);
121 assertEquals(expResult, result);
122
123 }
124
125 }