private List<WildflyDataSourceDef> createWFDataSources() { // emulates the data sources deployments information returned by the WF server. List<WildflyDataSourceDef> result = new ArrayList<>(); WildflyDataSourceDef dataSourceDef = new WildflyDataSourceDef(); dataSourceDef.setName(DS1_DEPLOYMENT_ID); dataSourceDef.setDriverName(DRIVER1_DEPLOYMENT_ID); dataSourceDef.setConnectionURL(DS1_CONNECTION_URL); dataSourceDef.setPassword(DS1_PASSWORD); dataSourceDef.setUser(DS1_USER); dataSourceDef.setJndi(DS1_JNID); result.add(dataSourceDef); dataSourceDef = new WildflyDataSourceDef(); dataSourceDef.setName(DS2_DEPLOYMENT_ID); dataSourceDef.setDriverName(DRIVER1_DEPLOYMENT_ID); dataSourceDef.setConnectionURL(DS2_CONNECTION_URL); dataSourceDef.setPassword(DS2_PASSWORD); dataSourceDef.setUser(DS2_USER); dataSourceDef.setJndi(DS2_JNID); result.add(dataSourceDef); return result; }
@Override public void testDeployDataSource() throws Exception { super.testDeployDataSource(); // additional check // expected WF data source definition that should be created in the WF server. WildflyDataSourceDef wfDataSource = new WildflyDataSourceDef(); wfDataSource.setName(DeploymentIdGenerator.generateDeploymentId(dataSourceDef)); wfDataSource.setConnectionURL(dataSourceDef.getConnectionURL()); wfDataSource.setUser(dataSourceDef.getUser()); wfDataSource.setPassword(dataSourceDef.getPassword()); wfDataSource.setDriverName(DRIVER1_DEPLOYMENT_ID); wfDataSource.setJndi(JndiNameGenerator.generateJNDIName(dataSourceDef)); // the expected WF data source definition should have been created in the WF server. ArgumentCaptor<WildflyDataSourceDef> argumentCaptor = ArgumentCaptor.forClass(WildflyDataSourceDef.class); verify(managementClient, times(1)).createDataSource(argumentCaptor.capture()); if (!areTheSame(wfDataSource, argumentCaptor.getValue())) { fail("Data source definition wasn't properly created in the WF server: " + wfDataSource); } }