DataSourceDecorator implements TestClassDecorator { @Override public void beforeAll(final TestInvocation invocation) throws Exception { final ExecutionContext context = invocation.getContext(); final SqlDbConfiguration configuration = new SqlDbConfiguration(context.getDescriptor()); context.storeData(Constants.KEY_DATA_SOURCE, configuration.createDataSource()); }  @Override int getPriority(); @Override void beforeAll(final TestInvocation invocation); @Override void afterAll(final TestInvocation invocation); @Override boolean isConfigurationSupported(final ExecutionContext ctx);  }
@Test public void testCreateDataSource() throws Throwable { final DataSourceDecorator decorator = new DataSourceDecorator(); decorator.beforeAll(invocation); final ArgumentCaptor<BasicDataSource> dsCaptor = ArgumentCaptor.forClass(BasicDataSource.class); verify(ctx).storeData(eq(Constants.KEY_DATA_SOURCE), dsCaptor.capture()); final BasicDataSource dataSource = dsCaptor.getValue(); assertThat(dataSource.getUsername(), equalTo("user")); assertThat(dataSource.getPassword(), equalTo("password")); assertThat(dataSource.getDriverClassName(), equalTo("driver")); assertThat(dataSource.getUrl(), equalTo("url")); }