View Javadoc
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) 2014 Jeremy Long. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck.maven;
19  
20  import java.io.IOException;
21  import java.io.InputStream;
22  import java.util.logging.Level;
23  import java.util.logging.Logger;
24  import org.junit.AfterClass;
25  import org.junit.BeforeClass;
26  import org.owasp.dependencycheck.utils.Settings;
27  
28  /**
29   *
30   * @author Jeremy Long
31   */
32  public class BaseTest {
33  
34      /**
35       * The properties file location.
36       */
37      public static final String PROPERTIES_FILE = "mojo.properties";
38  
39      @BeforeClass
40      public static void setUpClass() throws Exception {
41          Settings.initialize();
42          InputStream mojoProperties = null;
43          try {
44              mojoProperties = BaseTest.class.getClassLoader().getResourceAsStream(BaseTest.PROPERTIES_FILE);
45              Settings.mergeProperties(mojoProperties);
46          } finally {
47              if (mojoProperties != null) {
48                  try {
49                      mojoProperties.close();
50                  } catch (IOException ex) {
51                      Logger.getLogger(BaseTest.class.getName()).log(Level.SEVERE, null, ex);
52                  }
53              }
54          }
55  
56      }
57  
58      @AfterClass
59      public static void tearDownClass() throws Exception {
60          Settings.cleanup(true);
61      }
62  }