View Javadoc

    1   /*
    2    * This file is part of dependency-check-core.
    3    *
    4    * Dependency-check-core is free software: you can redistribute it and/or modify it
    5    * under the terms of the GNU General Public License as published by the Free
    6    * Software Foundation, either version 3 of the License, or (at your option) any
    7    * later version.
    8    *
    9    * Dependency-check-core is distributed in the hope that it will be useful, but
    10   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11   * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    12   * details.
    13   *
    14   * You should have received a copy of the GNU General Public License along with
    15   * dependency-check-core. If not, see http://www.gnu.org/licenses/.
    16   *
    17   * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
    18   */
    19  package org.owasp.dependencycheck.analyzer;
    20
    21  import org.owasp.dependencycheck.analyzer.AnalyzerService;
    22  import org.owasp.dependencycheck.analyzer.Analyzer;
    23  import java.util.Set;
    24  import java.util.Iterator;
    25  import org.junit.After;
    26  import org.junit.AfterClass;
    27  import org.junit.Before;
    28  import org.junit.BeforeClass;
    29  import org.junit.Test;
    30  import static org.junit.Assert.*;
    31
    32  /**
    33   *
    34   * @author Jeremy Long (jeremy.long@owasp.org)
    35   */
    36  public class AnalyzerServiceTest {
    37
    38      public AnalyzerServiceTest() {
    39      }
    40
    41      @BeforeClass
    42      public static void setUpClass() throws Exception {
    43      }
    44
    45      @AfterClass
    46      public static void tearDownClass() throws Exception {
    47      }
    48
    49      @Before
    50      public void setUp() {
    51      }
    52
    53      @After
    54      public void tearDown() {
    55      }
    56
    57      /**
    58       * Test of getAnalyzers method, of class AnalyzerService.
    59       */
    60      @Test
    61      public void testGetAnalyzers() {
    62          AnalyzerService instance = AnalyzerService.getInstance();
    63          Iterator<Analyzer> result = instance.getAnalyzers();
    64
    65          boolean found = false;
    66          while (result.hasNext()) {
    67              Analyzer a = result.next();
    68              Set<String> e = a.getSupportedExtensions();
    69              if (e != null && e.contains("jar")) {
    70                  found = true;
    71              }
    72          }
    73          assertTrue("JarAnalyzer loaded", found);
    74      }
    75  }