Migrate away from ExpectedException (#22922)

* Add limited checkstyles to test code

Add a limited set of checkstyle rules to the test codebase to improve
code consistency.

* Fix checksyle violations in test code

* Organize imports to fix checkstyle for test code

* Migrate to assertThatExceptionOfType

Migrate aware from ExpectedException rules to AssertJ exception
assertions. Also include a checkstyle rules to ensure that the
the ExpectedException is not accidentally used in the future.

See gh-22894
This commit is contained in:
Phil Webb
2019-05-08 07:25:52 -07:00
committed by Sam Brannen
parent 7e6e3d7027
commit d7320de871
671 changed files with 3861 additions and 4601 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,12 +69,12 @@ class TestableAsyncUncaughtExceptionHandler
try {
this.latch.await(timeout, TimeUnit.MILLISECONDS);
}
catch (Exception e) {
catch (Exception ex) {
Thread.currentThread().interrupt();
}
}
private static class UncaughtExceptionDescriptor {
private static final class UncaughtExceptionDescriptor {
private final Throwable ex;
private final Method method;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -181,11 +181,11 @@ public class TransactionAspectTests {
try {
toc.performTransactionalOperation();
}
catch (Throwable t) {
catch (Throwable ex) {
if (expected == null) {
fail("Expected " + expected);
}
assertSame(expected, t);
assertSame(expected, ex);
}
finally {
assertEquals(0, txManager.begun);