@Override
	public Statement apply(final Statement base, Description description) {
		try {
			obtainResource();
		}
		catch (Exception e) {
			maybeCleanup();

			return failOrSkip(e);
		}

		return new Statement() {

			@Override
			public void evaluate() throws Throwable {
				try {
					base.evaluate();
				}
				finally {
					try {
						cleanupResource();
					}
					catch (Exception ignored) {
						logger.warn("Exception while trying to cleanup proper resource", ignored);
					}
				}
			}

		};
	}
Abstract base class for JUnit {@link Rule}s that detect the presence of some external resource. If the resource is
indeed present, it will be available during the test lifecycle through {@link #getResource()}. If it is not, tests
will either fail or be skipped, depending on the value of system property {@value #XD_EXTERNAL_SERVERS_REQUIRED}.

@author Eric Bottard
@author Gary Russell
spring-xd-test/src/main/java/org/springframework/xd/test/AbstractExternalResourceTestSupport.java