1 /*
2 * This file is part of dependency-check-maven.
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 * Copyright (c) 2013 Jeremy Long. All Rights Reserved.
17 */
18 package org.owasp.dependencycheck.maven;
19
20 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
21 import org.junit.After;
22 import org.junit.AfterClass;
23 import org.junit.Before;
24 import org.junit.BeforeClass;
25 import org.junit.Test;
26
27 /**
28 * TODO - figure out how to get the test harness to work. ATM no tests are running.
29 *
30 * @author Jeremy Long <jeremy.long@owasp.org>
31 */
32 public class DependencyCheckMojoTest extends AbstractMojoTestCase {
33
34 public DependencyCheckMojoTest() {
35 }
36
37 @BeforeClass
38 public static void setUpClass() throws Exception {
39 }
40
41 @AfterClass
42 public static void tearDownClass() throws Exception {
43 }
44
45 @Before
46 public void setUp() {
47 }
48
49 @After
50 public void tearDown() {
51 }
52 //
53 // /**
54 // * Test of execute method, of class DependencyCheckMojo.
55 // */
56 // @Test
57 // public void testExecute() throws Exception {
58 // System.out.println("execute");
59 // DependencyCheckMojo instance = new DependencyCheckMojo();
60 // instance.execute();
61 // // TODO review the generated test code and remove the default call to fail.
62 // fail("The test case is a prototype.");
63 // }
64 //
65 // /**
66 // * Test of generate method, of class DependencyCheckMojo.
67 // */
68 // @Test
69 // public void testGenerate_Sink_Locale() throws Exception {
70 // System.out.println("generate");
71 // org.codehaus.doxia.sink.Sink sink = null;
72 // Locale locale = null;
73 // DependencyCheckMojo instance = new DependencyCheckMojo();
74 // instance.generate(sink, locale);
75 // // TODO review the generated test code and remove the default call to fail.
76 // fail("The test case is a prototype.");
77 // }
78
79 /**
80 * Test of generate method, of class DependencyCheckMojo.
81 */
82 @Test
83 public void testGenerate_Sink_SinkFactory_Locale() throws Exception {
84 //can't get the test-harness to work.
85 // File samplePom = new File(this.getClass().getClassLoader().getResource("sample.xml").toURI());
86 // DependencyCheckMojo mojo = (DependencyCheckMojo) lookupMojo("check", samplePom);
87 // assertNotNull("Unable to load mojo", mojo);
88 //
89 // File out = mojo.getReportOutputDirectory();
90 // OutputStream os = new FileOutputStream(out);
91 // MySink sink = new MySink(os);
92 // Locale locale = new Locale("en");
93 //
94 //
95 // mojo.generate(sink, null, locale);
96 // sink.close();
97 }
98 // /**
99 // * Test of getOutputName method, of class DependencyCheckMojo.
100 // */
101 // @Test
102 // public void testGetOutputName() {
103 // System.out.println("getOutputName");
104 // DependencyCheckMojo instance = new DependencyCheckMojo();
105 // String expResult = "";
106 // String result = instance.getOutputName();
107 // assertEquals(expResult, result);
108 // // TODO review the generated test code and remove the default call to fail.
109 // fail("The test case is a prototype.");
110 // }
111 //
112 // /**
113 // * Test of getCategoryName method, of class DependencyCheckMojo.
114 // */
115 // @Test
116 // public void testGetCategoryName() {
117 // System.out.println("getCategoryName");
118 // DependencyCheckMojo instance = new DependencyCheckMojo();
119 // String expResult = "";
120 // String result = instance.getCategoryName();
121 // assertEquals(expResult, result);
122 // // TODO review the generated test code and remove the default call to fail.
123 // fail("The test case is a prototype.");
124 // }
125 //
126 // /**
127 // * Test of getName method, of class DependencyCheckMojo.
128 // */
129 // @Test
130 // public void testGetName() {
131 // System.out.println("getName");
132 // Locale locale = null;
133 // DependencyCheckMojo instance = new DependencyCheckMojo();
134 // String expResult = "";
135 // String result = instance.getName(locale);
136 // assertEquals(expResult, result);
137 // // TODO review the generated test code and remove the default call to fail.
138 // fail("The test case is a prototype.");
139 // }
140 //
141 // /**
142 // * Test of setReportOutputDirectory method, of class DependencyCheckMojo.
143 // */
144 // @Test
145 // public void testSetReportOutputDirectory() {
146 // System.out.println("setReportOutputDirectory");
147 // File directory = null;
148 // DependencyCheckMojo instance = new DependencyCheckMojo();
149 // instance.setReportOutputDirectory(directory);
150 // // TODO review the generated test code and remove the default call to fail.
151 // fail("The test case is a prototype.");
152 // }
153 //
154 // /**
155 // * Test of getReportOutputDirectory method, of class DependencyCheckMojo.
156 // */
157 // @Test
158 // public void testGetReportOutputDirectory() {
159 // System.out.println("getReportOutputDirectory");
160 // DependencyCheckMojo instance = new DependencyCheckMojo();
161 // File expResult = null;
162 // File result = instance.getReportOutputDirectory();
163 // assertEquals(expResult, result);
164 // // TODO review the generated test code and remove the default call to fail.
165 // fail("The test case is a prototype.");
166 // }
167 //
168 // /**
169 // * Test of getDescription method, of class DependencyCheckMojo.
170 // */
171 // @Test
172 // public void testGetDescription() {
173 // System.out.println("getDescription");
174 // Locale locale = null;
175 // DependencyCheckMojo instance = new DependencyCheckMojo();
176 // String expResult = "";
177 // String result = instance.getDescription(locale);
178 // assertEquals(expResult, result);
179 // // TODO review the generated test code and remove the default call to fail.
180 // fail("The test case is a prototype.");
181 // }
182 //
183 // /**
184 // * Test of isExternalReport method, of class DependencyCheckMojo.
185 // */
186 // @Test
187 // public void testIsExternalReport() {
188 // System.out.println("isExternalReport");
189 // DependencyCheckMojo instance = new DependencyCheckMojo();
190 // boolean expResult = false;
191 // boolean result = instance.isExternalReport();
192 // assertEquals(expResult, result);
193 // // TODO review the generated test code and remove the default call to fail.
194 // fail("The test case is a prototype.");
195 // }
196 //
197 // /**
198 // * Test of canGenerateReport method, of class DependencyCheckMojo.
199 // */
200 // @Test
201 // public void testCanGenerateReport() {
202 // System.out.println("canGenerateReport");
203 // DependencyCheckMojo instance = new DependencyCheckMojo();
204 // boolean expResult = false;
205 // boolean result = instance.canGenerateReport();
206 // assertEquals(expResult, result);
207 // // TODO review the generated test code and remove the default call to fail.
208 // fail("The test case is a prototype.");
209 // }
210 }