mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-27 11:31:24 +01:00
doclint fixes
This commit is contained in:
@@ -30,147 +30,137 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for AutoconfAnalyzer. The test resources under autoconf/ were
|
* Unit tests for AutoconfAnalyzer. The test resources under autoconf/ were obtained from outside open source software projects.
|
||||||
* obtained from outside open source software projects. Links to those projects
|
* Links to those projects are given below.
|
||||||
* are given below.
|
|
||||||
*
|
*
|
||||||
* @author Dale Visser <dvisser@ida.org>
|
* @author Dale Visser
|
||||||
* @see <a href="http://readable.sourceforge.net/">Readable Lisp S-expressions
|
* @see <a href="http://readable.sourceforge.net/">Readable Lisp S-expressions Project</a>
|
||||||
* Project</a>
|
|
||||||
* @see <a href="https://gnu.org/software/binutils/">GNU Binutils</a>
|
* @see <a href="https://gnu.org/software/binutils/">GNU Binutils</a>
|
||||||
* @see <a href="https://gnu.org/software/ghostscript/">GNU Ghostscript</a>
|
* @see <a href="https://gnu.org/software/ghostscript/">GNU Ghostscript</a>
|
||||||
*/
|
*/
|
||||||
public class AutoconfAnalyzerTest extends BaseTest {
|
public class AutoconfAnalyzerTest extends BaseTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The analyzer to test.
|
* The analyzer to test.
|
||||||
*/
|
*/
|
||||||
AutoconfAnalyzer analyzer;
|
AutoconfAnalyzer analyzer;
|
||||||
|
|
||||||
private void assertCommonEvidence(Dependency result, String product,
|
private void assertCommonEvidence(Dependency result, String product,
|
||||||
String version, String vendor) {
|
String version, String vendor) {
|
||||||
assertProductAndVersion(result, product, version);
|
assertProductAndVersion(result, product, version);
|
||||||
assertTrue("Expected vendor evidence to contain \"" + vendor + "\".",
|
assertTrue("Expected vendor evidence to contain \"" + vendor + "\".",
|
||||||
result.getVendorEvidence().toString().contains(vendor));
|
result.getVendorEvidence().toString().contains(vendor));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertProductAndVersion(Dependency result, String product,
|
private void assertProductAndVersion(Dependency result, String product,
|
||||||
String version) {
|
String version) {
|
||||||
assertTrue("Expected product evidence to contain \"" + product + "\".",
|
assertTrue("Expected product evidence to contain \"" + product + "\".",
|
||||||
result.getProductEvidence().toString().contains(product));
|
result.getProductEvidence().toString().contains(product));
|
||||||
assertTrue("Expected version evidence to contain \"" + version + "\".",
|
assertTrue("Expected version evidence to contain \"" + version + "\".",
|
||||||
result.getVersionEvidence().toString().contains(version));
|
result.getVersionEvidence().toString().contains(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Correctly setup the analyzer for testing.
|
* Correctly setup the analyzer for testing.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception thrown if there is a problem
|
||||||
* thrown if there is a problem
|
*/
|
||||||
*/
|
@Before
|
||||||
@Before
|
public void setUp() throws Exception {
|
||||||
public void setUp() throws Exception {
|
analyzer = new AutoconfAnalyzer();
|
||||||
analyzer = new AutoconfAnalyzer();
|
analyzer.setFilesMatched(true);
|
||||||
analyzer.setFilesMatched(true);
|
analyzer.initialize();
|
||||||
analyzer.initialize();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup the analyzer's temp files, etc.
|
* Cleanup the analyzer's temp files, etc.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception thrown if there is a problem
|
||||||
* thrown if there is a problem
|
*/
|
||||||
*/
|
@After
|
||||||
@After
|
public void tearDown() throws Exception {
|
||||||
public void tearDown() throws Exception {
|
analyzer.close();
|
||||||
analyzer.close();
|
analyzer = null;
|
||||||
analyzer = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether expected evidence is gathered from Ghostscript's
|
* Test whether expected evidence is gathered from Ghostscript's configure.ac.
|
||||||
* configure.ac.
|
*
|
||||||
*
|
* @throws AnalysisException is thrown when an exception occurs.
|
||||||
* @throws AnalysisException
|
*/
|
||||||
* is thrown when an exception occurs.
|
@Test
|
||||||
*/
|
public void testAnalyzeConfigureAC1() throws AnalysisException {
|
||||||
@Test
|
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
||||||
public void testAnalyzeConfigureAC1() throws AnalysisException {
|
this, "autoconf/ghostscript/configure.ac"));
|
||||||
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
analyzer.analyze(result, null);
|
||||||
this, "autoconf/ghostscript/configure.ac"));
|
assertCommonEvidence(result, "ghostscript", "8.62.0", "gnu");
|
||||||
analyzer.analyze(result, null);
|
}
|
||||||
assertCommonEvidence(result, "ghostscript", "8.62.0", "gnu");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether expected evidence is gathered from Readable's configure.ac.
|
* Test whether expected evidence is gathered from Readable's configure.ac.
|
||||||
*
|
*
|
||||||
* @throws AnalysisException
|
* @throws AnalysisException is thrown when an exception occurs.
|
||||||
* is thrown when an exception occurs.
|
*/
|
||||||
*/
|
@Test
|
||||||
@Test
|
public void testAnalyzeConfigureAC2() throws AnalysisException {
|
||||||
public void testAnalyzeConfigureAC2() throws AnalysisException {
|
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
||||||
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
this, "autoconf/readable-code/configure.ac"));
|
||||||
this, "autoconf/readable-code/configure.ac"));
|
analyzer.analyze(result, null);
|
||||||
analyzer.analyze(result, null);
|
assertReadableCodeEvidence(result);
|
||||||
assertReadableCodeEvidence(result);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void assertReadableCodeEvidence(final Dependency result) {
|
private void assertReadableCodeEvidence(final Dependency result) {
|
||||||
assertCommonEvidence(result, "readable", "1.0.7", "dwheeler");
|
assertCommonEvidence(result, "readable", "1.0.7", "dwheeler");
|
||||||
final String url = "http://readable.sourceforge.net/";
|
final String url = "http://readable.sourceforge.net/";
|
||||||
assertTrue("Expected product evidence to contain \"" + url + "\".",
|
assertTrue("Expected product evidence to contain \"" + url + "\".",
|
||||||
result.getVendorEvidence().toString().contains(url));
|
result.getVendorEvidence().toString().contains(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether expected evidence is gathered from GNU Binutil's configure.
|
* Test whether expected evidence is gathered from GNU Binutil's configure.
|
||||||
*
|
*
|
||||||
* @throws AnalysisException
|
* @throws AnalysisException is thrown when an exception occurs.
|
||||||
* is thrown when an exception occurs.
|
*/
|
||||||
*/
|
@Test
|
||||||
@Test
|
public void testAnalyzeConfigureScript() throws AnalysisException {
|
||||||
public void testAnalyzeConfigureScript() throws AnalysisException {
|
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
||||||
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
this, "autoconf/binutils/configure"));
|
||||||
this, "autoconf/binutils/configure"));
|
analyzer.analyze(result, null);
|
||||||
analyzer.analyze(result, null);
|
assertProductAndVersion(result, "binutils", "2.25.51");
|
||||||
assertProductAndVersion(result, "binutils", "2.25.51");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether expected evidence is gathered from GNU Ghostscript's
|
* Test whether expected evidence is gathered from GNU Ghostscript's configure.
|
||||||
* configure.
|
*
|
||||||
*
|
* @throws AnalysisException is thrown when an exception occurs.
|
||||||
* @throws AnalysisException
|
*/
|
||||||
* is thrown when an exception occurs.
|
@Test
|
||||||
*/
|
public void testAnalyzeReadableConfigureScript() throws AnalysisException {
|
||||||
@Test
|
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
||||||
public void testAnalyzeReadableConfigureScript() throws AnalysisException {
|
this, "autoconf/readable-code/configure"));
|
||||||
final Dependency result = new Dependency(BaseTest.getResourceAsFile(
|
analyzer.analyze(result, null);
|
||||||
this, "autoconf/readable-code/configure"));
|
assertReadableCodeEvidence(result);
|
||||||
analyzer.analyze(result, null);
|
}
|
||||||
assertReadableCodeEvidence(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of getName method, of {@link AutoconfAnalyzer}.
|
* Test of getName method, of {@link AutoconfAnalyzer}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetName() {
|
public void testGetName() {
|
||||||
assertEquals("Analyzer name wrong.", "Autoconf Analyzer",
|
assertEquals("Analyzer name wrong.", "Autoconf Analyzer",
|
||||||
analyzer.getName());
|
analyzer.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of {@link AutoconfAnalyzer#accept(File)}.
|
* Test of {@link AutoconfAnalyzer#accept(File)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSupportsFileExtension() {
|
public void testSupportsFileExtension() {
|
||||||
assertTrue("Should support \"ac\" extension.",
|
assertTrue("Should support \"ac\" extension.",
|
||||||
analyzer.accept(new File("configure.ac")));
|
analyzer.accept(new File("configure.ac")));
|
||||||
assertTrue("Should support \"in\" extension.",
|
assertTrue("Should support \"in\" extension.",
|
||||||
analyzer.accept(new File("configure.in")));
|
analyzer.accept(new File("configure.in")));
|
||||||
assertTrue("Should support \"configure\" extension.",
|
assertTrue("Should support \"configure\" extension.",
|
||||||
analyzer.accept(new File("configure")));
|
analyzer.accept(new File("configure")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user