-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
executable file
·113 lines (86 loc) · 4.06 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Autor: Clayton Kendy Nakahara Passos
e-mail: [email protected]
_________________________________________________________________________
Exemplo de uso:
/**
* A list of bug patterns reported by FindBugs (402):
* http://findbugs.sourceforge.net/bugDescriptions.html
*
* A Comparison of Bug Finding Tools for Java (ESC/Java, Bandera, FindBugs,
* JLint, PMD) http://www.cs.umd.edu/~jfoster/papers/issre04.pdf
*
* How to write custom detector:
* http://www.ibm.com/developerworks/java/library/j-findbug2/
*
* @author Clayton K. N. Passos
* @email [email protected]
*
*/
public class FindBugsTest {
@Test
public void junitFindBugsTestWrapperRunParameters() throws JUnitTestWrapperException {
String args[] = new String[] { "-nested:true", "-low", "-effort:max", "C:\\dev\\projetos\\crm\\GvtOAuthServices\\GvtWebOauthServicesWeb\\target\\classes",
"C:\\dev\\projetos\\crm\\GvtOAuthServices\\GvtWebOauthServicesBusiness\\target\\classes" };
JUnitFindBugsTestWrapper w = new JUnitFindBugsTestWrapper(this);
w.run(args);
int bugCount = w.getBugCount();
int errorCount = w.getErrorCount();
String bugReporterMessage = w.getBugReporterMessage();
Assert.assertTrue(bugCount + " findbugs bugs found. " + bugReporterMessage, bugCount == 0);
Assert.assertTrue(errorCount + " findbugs error found. " + bugReporterMessage, errorCount == 0);
}
@Test
public void junitFindBugsTestWrapper() throws JUnitTestWrapperException {
JUnitFindBugsTestWrapper w = new JUnitFindBugsTestWrapper(this);
w.addParameterNestedTrue();
w.addParameterLow();
w.addParameterEffortMax();
w.addParameterFolderCheck("target/classes");
w.addIncludeFilter("");
w.addExcludeFilter("");
w.run();
int bugCount = w.getBugCount();
int errorCount = w.getErrorCount();
String bugReporterMessage = w.getBugReporterMessage();
Assert.assertTrue(bugCount + " findbugs bugs found. " + bugReporterMessage, bugCount == 0);
Assert.assertTrue(errorCount + " findbugs error found. " + bugReporterMessage, errorCount == 0);
}
@Test
public void junitFindBugsTestWrapperWithExcludeFilter() throws JUnitTestWrapperException {
JUnitFindBugsTestWrapper w = new JUnitFindBugsTestWrapper(this);
w.addParameterNestedTrue();
w.addParameterLow();
w.addParameterEffortMax();
w.addParameterFolderCheck("target/classes");
w.addExcludeFilter("findbugs.xml");
w.run();
int bugCount = w.getBugCount();
int errorCount = w.getErrorCount();
String bugReporterMessage = w.getBugReporterMessage();
Assert.assertTrue(bugCount + " findbugs bugs found. " + bugReporterMessage, bugCount == 0);
Assert.assertTrue(errorCount + " findbugs error found. " + bugReporterMessage, errorCount == 0);
}
@Test
@Ignore
public void rascunhoTest() throws Exception {
// "-outputFile", "C:\\t\\t.txt",
// "C:\\dev\\projetos\\crm\\GvtOAuthServices\\GvtWebOauthServicesEAR\\target\\GvtWebOauthServicesEAR-1.0.0\\lib"
// "-exclude", "src/test/java/br/com/gvt/architecture/sanity/check/findbugs/findbugs.xml"
String args[] = new String[] { "-nested:true", "-low", "-effort:max", "C:\\dev\\projetos\\crm\\GvtOAuthServices\\GvtWebOauthServicesWeb\\target\\classes",
"C:\\dev\\projetos\\crm\\GvtOAuthServices\\GvtWebOauthServicesBusiness\\target\\classes" };
// Sanity-check the loaded BCEL classes
if (!CheckBcel.check()) {
System.exit(1);
}
FindBugs2 f = new FindBugs2();
TextUICommandLine commandLine = new TextUICommandLine();
FindBugs.processCommandLine(commandLine, args, f);
CollectBugInstanceBugReporterObserver bugReporterObserver = new CollectBugInstanceBugReporterObserver();
f.getBugReporter().addObserver(bugReporterObserver);
FindBugs.runMain(f, commandLine);
int bugCount = f.getBugCount();
int errorCount = f.getErrorCount();
Assert.assertTrue(bugCount + " findbugs bugs found. " + bugReporterObserver.getWriter().toString(), bugCount == 0);
Assert.assertTrue(errorCount + " findbugs error found. " + bugReporterObserver.getWriter().toString(), errorCount == 0);
}
}