View Javadoc
1   /*
2    * This file is part of dependency-check-core.
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) 2012 Jeremy Long. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck;
19  
20  import org.junit.After;
21  import static org.junit.Assert.assertTrue;
22  import org.junit.Before;
23  import org.junit.Test;
24  import org.owasp.dependencycheck.data.nvdcve.CveDB;
25  import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties;
26  import org.owasp.dependencycheck.reporting.ReportGenerator;
27  import org.owasp.dependencycheck.utils.Settings;
28  
29  /**
30   *
31   * @author Jeremy Long
32   */
33  public class EngineIntegrationTest extends BaseDBTestCase {
34  
35      /**
36       * Test running the entire engine.
37       *
38       * @throws Exception is thrown when an exception occurs.
39       */
40      @Test
41      public void testEngine() throws Exception {
42          String testClasses = "target/test-classes";
43          boolean autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE);
44          Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false);
45          Engine instance = new Engine();
46          Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
47          instance.scan(testClasses);
48          assertTrue(instance.getDependencies().size() > 0);
49          instance.analyzeDependencies();
50          CveDB cveDB = new CveDB();
51          cveDB.open();
52          DatabaseProperties dbProp = cveDB.getDatabaseProperties();
53          cveDB.close();
54          ReportGenerator rg = new ReportGenerator("DependencyCheck", instance.getDependencies(), instance.getAnalyzers(), dbProp);
55          rg.generateReports("./target/", "ALL");
56          instance.cleanup();
57      }
58  }