mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-24 01:51:49 +01:00
updated templates for API changes in 3.0.0
This commit is contained in:
@@ -23,6 +23,7 @@ import org.owasp.dependencycheck.analyzer.FileTypeAnalyzer;
|
|||||||
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
|
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
|
||||||
import org.owasp.dependencycheck.dependency.Dependency;
|
import org.owasp.dependencycheck.dependency.Dependency;
|
||||||
import org.owasp.dependencycheck.exception.InitializationException;
|
import org.owasp.dependencycheck.exception.InitializationException;
|
||||||
|
import org.owasp.dependencycheck.utils.Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An OWASP dependency-check plug-in example. If you are not implementing a
|
* An OWASP dependency-check plug-in example. If you are not implementing a
|
||||||
@@ -66,7 +67,7 @@ public class ${analyzerName} implements Analyzer, FileTypeAnalyzer {
|
|||||||
@Override
|
@Override
|
||||||
public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
|
public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
throw new UnsupportedOperationException("Not implemented yet.");
|
//TODO implement analyze
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,15 +92,26 @@ public class ${analyzerName} implements Analyzer, FileTypeAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The initialize method is called (once) prior to the analyze method being
|
* The initialize method is called just after instantiation of the object.
|
||||||
* called on all of the dependencies.
|
|
||||||
*
|
*
|
||||||
* @throws InitializationException is thrown if an exception occurs
|
* @param settings a reference to the configured settings
|
||||||
* initializing the analyzer.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws InitializationException {
|
public void initialize(Settings settings) {
|
||||||
|
//TODO implement initialize
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The prepare method is called once just prior to repeated calls to
|
||||||
|
* analyze.
|
||||||
|
*
|
||||||
|
* @param engine a reference to the engine
|
||||||
|
* @throws InitializationException thrown when the analyzer cannot be
|
||||||
|
* initialized
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void prepare(Engine engine) throws InitializationException {
|
||||||
|
//TODO implement prepare
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +128,7 @@ public class ${analyzerName} implements Analyzer, FileTypeAnalyzer {
|
|||||||
/**
|
/**
|
||||||
* Returns whether multiple instances of the same type of analyzer can run
|
* Returns whether multiple instances of the same type of analyzer can run
|
||||||
* in parallel. If the analyzer does not support parallel processing it is
|
* in parallel. If the analyzer does not support parallel processing it is
|
||||||
* generally best to also mark the analyze(Dependency,Engine) as synchronized.
|
* generally best to also mark the analyze(Dependency,Engine) as synchronized.
|
||||||
*
|
*
|
||||||
* @return {@code true} if the analyzer supports parallel processing,
|
* @return {@code true} if the analyzer supports parallel processing,
|
||||||
* {@code false} else
|
* {@code false} else
|
||||||
|
|||||||
@@ -30,25 +30,27 @@ import org.owasp.dependencycheck.utils.Settings;
|
|||||||
*/
|
*/
|
||||||
public class ${analyzerName}Test {
|
public class ${analyzerName}Test {
|
||||||
|
|
||||||
|
Settings settings = null;
|
||||||
|
|
||||||
public ${analyzerName}Test() {
|
public ${analyzerName}Test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() {
|
public static void setUpClass() {
|
||||||
Settings.initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void tearDownClass() {
|
public static void tearDownClass() {
|
||||||
Settings.cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
settings = new Settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
|
settings.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,12 +70,14 @@ public class ${analyzerName}Test {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAnalyze() throws Exception {
|
public void testAnalyze() throws Exception {
|
||||||
|
//The engine is generally null for most analyzer test cases but can be instantiated if needed.
|
||||||
|
Engine engine = null;
|
||||||
${analyzerName} instance = new ${analyzerName}();
|
${analyzerName} instance = new ${analyzerName}();
|
||||||
instance.initialize();
|
instance.initialize(settings);
|
||||||
|
instance.prepare(engine);
|
||||||
|
|
||||||
File file = new File(${analyzerName}.class.getClassLoader().getResource("test.file").toURI().getPath());
|
File file = new File(${analyzerName}.class.getClassLoader().getResource("test.file").toURI().getPath());
|
||||||
Dependency dependency = new Dependency(file);
|
Dependency dependency = new Dependency(file);
|
||||||
//The engine is generally null for most analyzer test cases.
|
|
||||||
Engine engine = null;
|
|
||||||
|
|
||||||
//TODO uncomment the following line and add assertions against the dependency.
|
//TODO uncomment the following line and add assertions against the dependency.
|
||||||
//instance.analyze(dependency, engine);
|
//instance.analyze(dependency, engine);
|
||||||
@@ -107,7 +111,7 @@ public class ${analyzerName}Test {
|
|||||||
@Test
|
@Test
|
||||||
public void testInitialize() throws Exception {
|
public void testInitialize() throws Exception {
|
||||||
${analyzerName} instance = new ${analyzerName}();
|
${analyzerName} instance = new ${analyzerName}();
|
||||||
instance.initialize();
|
instance.initialize(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user