Skip to content

Commit 582a4f1

Browse files
committed
CI: trigger SpotBugs (no-op)
1 parent 8611578 commit 582a4f1

File tree

46 files changed

+160
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+160
-132
lines changed

hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/KerberosTestUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
/**
3838
* Test helper class for Java Kerberos setup.
3939
*/
40+
// CI: trigger SpotBugs (no-op)
4041
public class KerberosTestUtils {
4142
private static String keytabFile = new File(System.getProperty("test.dir", "target"),
4243
UUID.randomUUID().toString()).getAbsolutePath();
@@ -68,7 +69,7 @@ public KerberosConfiguration(String principal) {
6869
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
6970
Map<String, String> options = new HashMap<String, String>();
7071
if (IBM_JAVA) {
71-
options.put("useKeytab", KerberosTestUtils.getKeytabFile().startsWith("file://") ?
72+
options.put("useKeytab", KerberosTestUtils.getKeytabFile().startsWith("file://") ?
7273
KerberosTestUtils.getKeytabFile() : "file://" + KerberosTestUtils.getKeytabFile());
7374
options.put("principal", principal);
7475
options.put("refreshKrb5Config", "true");
@@ -83,7 +84,7 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
8384
options.put("renewTGT", "true");
8485
options.put("refreshKrb5Config", "true");
8586
options.put("isInitiator", "true");
86-
}
87+
}
8788
String ticketCache = System.getenv("KRB5CCNAME");
8889
if (ticketCache != null) {
8990
if (IBM_JAVA) {

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/cli/CLITestHelper.java

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,26 @@
4242
/**
4343
* Tests for the Command Line Interface (CLI)
4444
*/
45+
// CI: trigger SpotBugs (no-op)
4546
public class CLITestHelper {
4647
private static final Logger LOG = LoggerFactory.getLogger(CLITestHelper
4748
.class);
4849

4950
// In this mode, it runs the command and compares the actual output
50-
// with the expected output
51+
// with the expected output
5152
public static final String TESTMODE_TEST = "test"; // Run the tests
52-
53+
5354
// If it is set to nocompare, run the command and do not compare.
5455
// This can be useful populate the testConfig.xml file the first time
5556
// a new command is added
5657
public static final String TESTMODE_NOCOMPARE = "nocompare";
5758
public static final String TEST_CACHE_DATA_DIR =
5859
System.getProperty("test.cache.data", "build/test/cache");
59-
60+
6061
//By default, run the tests. The other mode is to run the commands and not
6162
// compare the output
6263
protected String testMode = TESTMODE_TEST;
63-
64+
6465
// Storage for tests read in from the config file
6566
protected ArrayList<CLITestData> testsFromConfigFile = null;
6667
protected ArrayList<ComparatorData> testComparators = null;
@@ -104,29 +105,29 @@ protected TestConfigFileParser getConfigParser () {
104105
protected String getTestFile() {
105106
return "";
106107
}
107-
108+
108109
/*
109110
* Setup
110111
*/
111112
public void setUp() throws Exception {
112113
// Read the testConfig.xml file
113114
readTestConfigFile();
114-
115+
115116
conf = new Configuration();
116117
conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION,
117118
true);
118119

119120
clitestDataDir = new File(TEST_CACHE_DATA_DIR).
120121
toURI().toString().replace(' ', '+');
121122
}
122-
123+
123124
/**
124125
* Tear down
125126
*/
126127
public void tearDown() throws Exception {
127128
displayResults();
128129
}
129-
130+
130131
/**
131132
* Expand the commands from the test config xml file
132133
* @param cmd
@@ -136,22 +137,22 @@ protected String expandCommand(final String cmd) {
136137
String expCmd = cmd;
137138
expCmd = expCmd.replaceAll("CLITEST_DATA", clitestDataDir);
138139
expCmd = expCmd.replaceAll("USERNAME", username);
139-
140+
140141
return expCmd;
141142
}
142-
143+
143144
/**
144145
* Display the summarized results
145146
*/
146147
private void displayResults() {
147148
LOG.info("Detailed results:");
148149
LOG.info("----------------------------------\n");
149-
150+
150151
for (int i = 0; i < testsFromConfigFile.size(); i++) {
151152
CLITestData td = testsFromConfigFile.get(i);
152-
153+
153154
boolean testResult = td.getTestResult();
154-
155+
155156
// Display the details only if there is a failure
156157
if (!testResult) {
157158
LOG.info("-------------------------------------------");
@@ -161,7 +162,7 @@ private void displayResults() {
161162

162163
ArrayList<CLICommand> testCommands = td.getTestCommands();
163164
for (CLICommand cmd : testCommands) {
164-
LOG.info(" Test Commands: [" +
165+
LOG.info(" Test Commands: [" +
165166
expandCommand(cmd.getCmd()) + "]");
166167
}
167168

@@ -176,29 +177,29 @@ private void displayResults() {
176177
ArrayList<ComparatorData> compdata = td.getComparatorData();
177178
for (ComparatorData cd : compdata) {
178179
boolean resultBoolean = cd.getTestResult();
179-
LOG.info(" Comparator: [" +
180+
LOG.info(" Comparator: [" +
180181
cd.getComparatorType() + "]");
181-
LOG.info(" Comparision result: [" +
182+
LOG.info(" Comparision result: [" +
182183
(resultBoolean ? "pass" : "fail") + "]");
183-
LOG.info(" Expected output: [" +
184+
LOG.info(" Expected output: [" +
184185
expandCommand(cd.getExpectedOutput()) + "]");
185-
LOG.info(" Actual output: [" +
186+
LOG.info(" Actual output: [" +
186187
cd.getActualOutput() + "]");
187188
}
188189
LOG.info("");
189190
}
190191
}
191-
192+
192193
LOG.info("Summary results:");
193194
LOG.info("----------------------------------\n");
194-
195+
195196
boolean overallResults = true;
196197
int totalPass = 0;
197198
int totalFail = 0;
198199
int totalComparators = 0;
199200
for (int i = 0; i < testsFromConfigFile.size(); i++) {
200201
CLITestData td = testsFromConfigFile.get(i);
201-
totalComparators +=
202+
totalComparators +=
202203
testsFromConfigFile.get(i).getComparatorData().size();
203204
boolean resultBoolean = td.getTestResult();
204205
if (resultBoolean) {
@@ -208,27 +209,27 @@ private void displayResults() {
208209
}
209210
overallResults &= resultBoolean;
210211
}
211-
212-
212+
213+
213214
LOG.info(" Testing mode: " + testMode);
214215
LOG.info("");
215-
LOG.info(" Overall result: " +
216+
LOG.info(" Overall result: " +
216217
(overallResults ? "+++ PASS +++" : "--- FAIL ---"));
217218
if ((totalPass + totalFail) == 0) {
218219
LOG.info(" # Tests pass: " + 0);
219220
LOG.info(" # Tests fail: " + 0);
220221
}
221-
else
222+
else
222223
{
223224
LOG.info(" # Tests pass: " + totalPass +
224225
" (" + (100 * totalPass / (totalPass + totalFail)) + "%)");
225-
LOG.info(" # Tests fail: " + totalFail +
226+
LOG.info(" # Tests fail: " + totalFail +
226227
" (" + (100 * totalFail / (totalPass + totalFail)) + "%)");
227228
}
228-
229-
LOG.info(" # Validations done: " + totalComparators +
229+
230+
LOG.info(" # Validations done: " + totalComparators +
230231
" (each test may do multiple validations)");
231-
232+
232233
LOG.info("");
233234
LOG.info("Failing tests:");
234235
LOG.info("--------------");
@@ -237,23 +238,23 @@ private void displayResults() {
237238
for (i = 0; i < testsFromConfigFile.size(); i++) {
238239
boolean resultBoolean = testsFromConfigFile.get(i).getTestResult();
239240
if (!resultBoolean) {
240-
LOG.info((i + 1) + ": " +
241+
LOG.info((i + 1) + ": " +
241242
testsFromConfigFile.get(i).getTestDesc());
242243
foundTests = true;
243244
}
244245
}
245246
if (!foundTests) {
246247
LOG.info("NONE");
247248
}
248-
249+
249250
foundTests = false;
250251
LOG.info("");
251252
LOG.info("Passing tests:");
252253
LOG.info("--------------");
253254
for (i = 0; i < testsFromConfigFile.size(); i++) {
254255
boolean resultBoolean = testsFromConfigFile.get(i).getTestResult();
255256
if (resultBoolean) {
256-
LOG.info((i + 1) + ": " +
257+
LOG.info((i + 1) + ": " +
257258
testsFromConfigFile.get(i).getTestDesc());
258259
foundTests = true;
259260
}
@@ -266,7 +267,7 @@ private void displayResults() {
266267
"See the Detailed results to identify " +
267268
"the command that failed");
268269
}
269-
270+
270271
/**
271272
* Compare the actual output with the expected output
272273
* @param compdata
@@ -276,47 +277,47 @@ private boolean compareTestOutput(ComparatorData compdata, Result cmdResult) {
276277
// Compare the output based on the comparator
277278
String comparatorType = compdata.getComparatorType();
278279
Class<?> comparatorClass = null;
279-
280+
280281
// If testMode is "test", then run the command and compare the output
281282
// If testMode is "nocompare", then run the command and dump the output.
282283
// Do not compare
283-
284+
284285
boolean compareOutput = false;
285-
286+
286287
if (testMode.equals(TESTMODE_TEST)) {
287288
try {
288289
// Initialize the comparator class and run its compare method
289-
comparatorClass = Class.forName("org.apache.hadoop.cli.util." +
290+
comparatorClass = Class.forName("org.apache.hadoop.cli.util." +
290291
comparatorType);
291292
ComparatorBase comp = (ComparatorBase) comparatorClass.newInstance();
292-
compareOutput = comp.compare(cmdResult.getCommandOutput(),
293+
compareOutput = comp.compare(cmdResult.getCommandOutput(),
293294
expandCommand(compdata.getExpectedOutput()));
294295
} catch (Exception e) {
295296
LOG.info("Error in instantiating the comparator" + e);
296297
}
297298
}
298-
299+
299300
return compareOutput;
300301
}
301302

302303
private boolean compareTextExitCode(ComparatorData compdata,
303304
Result cmdResult) {
304305
return compdata.getExitCode() == cmdResult.getExitCode();
305306
}
306-
307+
307308
/***********************************
308309
************* TESTS RUNNER
309310
*********************************/
310-
311+
311312
public void testAll() {
312313
assertTrue(testsFromConfigFile.size() > 0,
313314
"Number of tests has to be greater then zero");
314315
LOG.info("TestAll");
315316
// Run the tests defined in the testConf.xml config file.
316317
for (int index = 0; index < testsFromConfigFile.size(); index++) {
317-
318+
318319
CLITestData testdata = testsFromConfigFile.get(index);
319-
320+
320321
// Execute the test commands
321322
ArrayList<CLICommand> testCommands = testdata.getTestCommands();
322323
Result cmdResult = null;
@@ -327,16 +328,16 @@ public void testAll() {
327328
fail(StringUtils.stringifyException(e));
328329
}
329330
}
330-
331+
331332
boolean overallTCResult = true;
332333
// Run comparators
333334
ArrayList<ComparatorData> compdata = testdata.getComparatorData();
334335
for (ComparatorData cd : compdata) {
335336
final String comptype = cd.getComparatorType();
336-
337+
337338
boolean compareOutput = false;
338339
boolean compareExitCode = false;
339-
340+
340341
if (! comptype.equalsIgnoreCase("none")) {
341342
compareOutput = compareTestOutput(cd, cmdResult);
342343
if (cd.getExitCode() == -1) {
@@ -347,17 +348,17 @@ public void testAll() {
347348
}
348349
overallTCResult &= (compareOutput & compareExitCode);
349350
}
350-
351+
351352
cd.setExitCode(cmdResult.getExitCode());
352353
cd.setActualOutput(cmdResult.getCommandOutput());
353354
cd.setTestResult(compareOutput);
354355
}
355356
testdata.setTestResult(overallTCResult);
356-
357+
357358
// Execute the cleanup commands
358359
ArrayList<CLICommand> cleanupCommands = testdata.getCleanupCommands();
359360
for (CLICommand cmd : cleanupCommands) {
360-
try {
361+
try {
361362
execute(cmd);
362363
} catch (Exception e) {
363364
fail(StringUtils.stringifyException(e));
@@ -372,7 +373,7 @@ public void testAll() {
372373
protected CommandExecutor.Result execute(CLICommand cmd) throws Exception {
373374
throw new Exception("Unknown type of test command:"+ cmd.getType());
374375
}
375-
376+
376377
/*
377378
* Parser class for the test config xml file
378379
*/
@@ -382,16 +383,16 @@ class TestConfigFileParser extends DefaultHandler {
382383
ArrayList<CLICommand> testCommands = null;
383384
ArrayList<CLICommand> cleanupCommands = null;
384385
boolean runOnWindows = true;
385-
386+
386387
@Override
387388
public void startDocument() throws SAXException {
388389
testsFromConfigFile = new ArrayList<CLITestData>();
389390
}
390-
391+
391392
@Override
392-
public void startElement(String uri,
393-
String localName,
394-
String qName,
393+
public void startElement(String uri,
394+
String localName,
395+
String qName,
395396
Attributes attributes) throws SAXException {
396397
if (qName.equals("test")) {
397398
td = new CLITestData();
@@ -407,7 +408,7 @@ public void startElement(String uri,
407408
}
408409
charString = "";
409410
}
410-
411+
411412
@Override
412413
public void endElement(String uri, String localName,String qName)
413414
throws SAXException {
@@ -451,10 +452,10 @@ public void endElement(String uri, String localName,String qName)
451452
}
452453
}
453454
}
454-
455+
455456
@Override
456-
public void characters(char[] ch,
457-
int start,
457+
public void characters(char[] ch,
458+
int start,
458459
int length) throws SAXException {
459460
String s = new String(ch, start, length);
460461
charString += s;

0 commit comments

Comments
 (0)