DataSourceDecorator implements TestClassDecorator { @Override public void afterAll(final TestInvocation invocation) throws Exception { final ExecutionContext context = invocation.getContext(); final BasicDataSource ds = (BasicDataSource) context.getData(Constants.KEY_DATA_SOURCE); ds.close(); context.storeData(Constants.KEY_DATA_SOURCE, null); }  @Override int getPriority(); @Override void beforeAll(final TestInvocation invocation); @Override void afterAll(final TestInvocation invocation); @Override boolean isConfigurationSupported(final ExecutionContext ctx);  }
@Test public void testCloseDataSource() throws Throwable { final DataSourceDecorator decorator = new DataSourceDecorator(); decorator.afterAll(invocation); verify(ds).close(); verify(ctx).storeData(eq(Constants.KEY_DATA_SOURCE), eq(null)); }