HADOOP-14415. Use java.lang.AssertionError instead of junit.framework.AssertionFailedError. Contributed by Chen Liang.

This commit is contained in:
Akira Ajisaka 2017-05-17 15:38:28 -04:00
parent 035d46836b
commit d4aa9e3c69
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
3 changed files with 6 additions and 10 deletions

View File

@ -17,7 +17,6 @@
*/
package org.apache.hadoop.fs;
import junit.framework.AssertionFailedError;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.shell.Command;
import org.apache.hadoop.fs.shell.CommandFactory;
@ -45,7 +44,7 @@ public void testConfWithInvalidFile() throws Throwable {
}
if (!(th instanceof RuntimeException)) {
throw new AssertionFailedError("Expected Runtime exception, got: " + th)
throw new AssertionError("Expected Runtime exception, got: " + th)
.initCause(th);
}
}

View File

@ -37,8 +37,6 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import junit.framework.AssertionFailedError;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -328,7 +326,7 @@ private void assertWikified(Exception e) throws Throwable {
private void assertInException(Exception e, String text) throws Throwable {
String message = extractExceptionMessage(e);
if (!(message.contains(text))) {
throw new AssertionFailedError("Wrong text in message "
throw new AssertionError("Wrong text in message "
+ "\"" + message + "\""
+ " expected \"" + text + "\"")
.initCause(e);
@ -339,7 +337,7 @@ private String extractExceptionMessage(Exception e) throws Throwable {
assertNotNull("Null Exception", e);
String message = e.getMessage();
if (message == null) {
throw new AssertionFailedError("Empty text in exception " + e)
throw new AssertionError("Empty text in exception " + e)
.initCause(e);
}
return message;
@ -349,7 +347,7 @@ private void assertNotInException(Exception e, String text)
throws Throwable{
String message = extractExceptionMessage(e);
if (message.contains(text)) {
throw new AssertionFailedError("Wrong text in message "
throw new AssertionError("Wrong text in message "
+ "\"" + message + "\""
+ " did not expect \"" + text + "\"")
.initCause(e);
@ -364,7 +362,7 @@ private IOException verifyExceptionClass(IOException e,
"localhost", LOCAL_PORT, e);
LOG.info(wrapped.toString(), wrapped);
if(!(wrapped.getClass().equals(expectedClass))) {
throw new AssertionFailedError("Wrong exception class; expected "
throw new AssertionError("Wrong exception class; expected "
+ expectedClass
+ " got " + wrapped.getClass() + ": " + wrapped).initCause(wrapped);
}

View File

@ -18,7 +18,6 @@
package org.apache.hadoop.fs.swift;
import junit.framework.AssertionFailedError;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@ -119,7 +118,7 @@ public void testMkdirsFailsForSubdirectoryOfExistingFile() throws Exception {
public void testWriteReadAndDeleteEmptyFile() throws Exception {
try {
super.testWriteReadAndDeleteEmptyFile();
} catch (AssertionFailedError e) {
} catch (AssertionError e) {
SwiftTestUtils.downgrade("empty files get mistaken for directories", e);
}
}