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) 2015 Jeremy Long. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck.analyzer;
19  
20  import org.junit.Test;
21  import org.owasp.dependencycheck.BaseDBTestCase;
22  
23  /**
24   *
25   * @author Jeremy Long
26   */
27  public class DependencyBundlingAnalyzerIntegrationTest extends BaseDBTestCase {
28  
29      /**
30       * Test of analyze method, of class DependencyBundlingAnalyzer.
31       */
32      @Test
33      public void testAnalyze() throws Exception {
34  //        Engine engine = null;
35  //        JarAnalyzer ja = null;
36  //        FileNameAnalyzer fna = null;
37  //        CPEAnalyzer cpea = null;
38  //        DependencyBundlingAnalyzer instance = null;
39  //        try {
40  //            //Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false);
41  //            Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, false);
42  //            //Settings.setBoolean(Settings.KEYS.ANALYZER_CENTRAL_ENABLED, false);
43  //            engine = new Engine();
44  //            engine.doUpdates();
45  //
46  //            File file1 = new File("C:\\Users\\jeremy\\Projects\\testCases\\batlik\\app1.war");
47  //            File file2 = new File("C:\\Users\\jeremy\\Projects\\testCases\\batlik\\app2.war");
48  //            Dependency dependency1 = new Dependency(file1);
49  //            Dependency dependency2 = new Dependency(file2);
50  //            engine.getDependencies().add(dependency1);
51  //            engine.getDependencies().add(dependency2);
52  //            ArchiveAnalyzer aa = new ArchiveAnalyzer();
53  //            aa.setEnabled(true);
54  //            aa.setFilesMatched(true);
55  //            aa.initialize();
56  //            ja = new JarAnalyzer();
57  //            ja.setFilesMatched(true);
58  //            ja.setEnabled(true);
59  //            ja.initialize();
60  //            fna = new FileNameAnalyzer();
61  //            fna.initialize();
62  //            cpea = new CPEAnalyzer();
63  //            cpea.initialize();
64  //
65  //            aa.analyze(dependency1, engine);
66  //            aa.analyze(dependency2, engine);
67  //
68  //            for (Dependency d : engine.getDependencies()) {
69  //                fna.analyze(d, engine);
70  //                ja.analyze(d, engine);
71  //                cpea.analyze(d, engine);
72  //            }
73  //
74  //            instance = new DependencyBundlingAnalyzer();
75  //            instance.initialize();
76  //            instance.analyze(null, engine);
77  //            System.out.println(engine.getDependencies().size());
78  //            for (Dependency d : engine.getDependencies()) {
79  //                System.out.println(d.getDisplayFileName());
80  //            }
81  //        } finally {
82  //            if (ja != null) {
83  //                ja.close();
84  //            }
85  //            if (fna != null) {
86  //                fna.close();
87  //            }
88  //            if (cpea != null) {
89  //                cpea.close();
90  //            }
91  //            if (instance != null) {
92  //                instance.close();
93  //            }
94  //            if (engine != null) {
95  //                engine.cleanup();
96  //            }
97  //        }
98      }
99  }