From 2c7885cfc66abccb3ddbf23e8ea38de74aff8cca Mon Sep 17 00:00:00 2001 From: Neil McErlean Date: Mon, 18 May 2015 15:11:16 +0000 Subject: [PATCH] Added some javadoc to clarify that ExceptionUtils.expectedException doesn't try to work around checked exceptions. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@104391 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../test/util/ExceptionUtils.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/ExceptionUtils.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/ExceptionUtils.java index f82c213df0..8a6d648c4c 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/ExceptionUtils.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/ExceptionUtils.java @@ -75,12 +75,13 @@ public class ExceptionUtils } /** - * Utility method to help with expected exceptions in test code. This can be used in place of {@code try/catch} - * blocks within test code and can sometimes make code more readable. + * Utility method to help with expected exceptions (unchecked - see below) in test code. This can be used in place + * of {@code try/catch} blocks within test code and can sometimes make code more readable. * A single expected exception would usually be let escape from the test method and be handled e.g. by JUnit's * {@code @Test(expected="Exception.class")} pattern. * However if you have multiple expected exceptions in a sequence, you need to either add a sequence of - * {@code try/catch} or use this method. + * {@code try/catch} or use this method. Likewise if you need to make assertions about state within the expected + * exception, such as root cause or other internal state, this method will be useful. *

* Examples: *

* + * A note on checked exceptions: currently this method does not provide any support for working around the normal + * integration of Java 8 lambdas and checked exceptions. If your {@code code} block must deal with checked exceptions, + * you must add {@code try}/{@code catch} blocks within your lambda which obviously makes this method less useful. + * This may change in the future. + * + * * @param expected the class of the expected throwable (subtypes will also match). * @param code a lambda containing the code block which should throw the expected throwable. * @param the return type of the code block (which should not matter as it should not complete).