use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.
the class DataSourceProviderBaseTest method testLookupDataSourceForNotDeployed.
/**
* Tests the lookup of a data source that has not been deployed.
*/
@Test
public void testLookupDataSourceForNotDeployed() throws Exception {
setupDrivers();
// case 1
// emulate that the data source #1 was deployed in an earlier time.
deployDataSource(dataSourceDef);
// now do a lookup for data source #1
DataSourceDeploymentInfo deploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
// deployment info for data source #1 should exists.
assertNotNull(deploymentInfo);
// perform the lookup on data source #1
DataSource dataSource = dataSourceProvider.lookupDataSource(deploymentInfo);
// the lookup should be ok.
assertNotNull(dataSource);
// now un-deploy data source #1
unDeployDataSource(deploymentInfo);
// now a lookup for data source #1 must fail
expectedException.expectMessage("Data source for: " + deploymentInfo + " is not deployed in current system.");
dataSourceProvider.lookupDataSource(deploymentInfo);
// case 2
// invent that a valid deployment information for a non deployed (or not existing) data source.
deploymentInfo = new DataSourceDeploymentInfo(DS3_DEPLOYMENT_ID, true, DS3_UUID, false);
// the lookup should fail.
expectedException.expectMessage("Data source for: " + deploymentInfo + " is not deployed in current system.");
dataSourceProvider.lookupDataSource(deploymentInfo);
}
use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.
the class DataSourceProviderBaseTest method testUnDeployDataSource.
@Test
public void testUnDeployDataSource() throws Exception {
setupDrivers();
// deploy the data source
deployDataSource(dataSourceDef);
DataSourceDeploymentInfo initialDeploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
// deployment info should exists
assertNotNull(initialDeploymentInfo);
// un-deploy the datasource
unDeployDataSource(initialDeploymentInfo);
// the deployment info should not exists now
DataSourceDeploymentInfo currentDeploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
assertNull(currentDeploymentInfo);
// un-deploy the non existing data source
expectedException.expectMessage("DataSource: " + initialDeploymentInfo.getUuid() + " is not deployed");
dataSourceProvider.undeploy(initialDeploymentInfo);
}
use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.
the class DataSourceRuntimeManagerTest method setup.
@Before
public void setup() {
when(providerFactory.getDataSourceProvider()).thenReturn(dataSourceProvider);
when(providerFactory.getDriverProvider()).thenReturn(driverProvider);
runtimeManager = new DataSourceRuntimeManagerMock(providerFactory);
dataSourceDef = new DataSourceDef();
dataSourceDef.setUuid(DS1_UUID);
dataSourceDef.setName(DS1_NAME);
dataSourceDef.setDriverUuid(DRIVER1_UUID);
dataSourceDef.setConnectionURL(DS1_CONNECTION_URL);
dataSourceDef.setUser(DS1_USER);
dataSourceDef.setPassword(DS1_PASSWORD);
driverDef = new DriverDef();
driverDef.setUuid(DRIVER1_UUID);
driverDef.setName(DRIVER1_NAME);
driverDef.setDriverClass(DRIVER1_CLASS);
driverDef.setArtifactId(ARTIFACT_ID);
driverDef.setGroupId(GROUP_ID);
driverDef.setVersion(VERSION);
driverDeploymentInfo = new DriverDeploymentInfo();
dataSourceDeploymentInfo = new DataSourceDeploymentInfo();
}
use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.
the class DBCPDataSourceProvider method undeploy.
@Override
public void undeploy(DataSourceDeploymentInfo deploymentInfo) throws Exception {
DataSourceDeploymentInfo currentDeploymentInfo = deploymentInfos.get(deploymentInfo.getDeploymentId());
if (currentDeploymentInfo == null) {
throw new Exception("DataSource: " + deploymentInfo.getUuid() + " is not deployed");
}
DBCPDataSource dataSource = deploymentRegistry.remove(currentDeploymentInfo.getDeploymentId());
if (dataSource != null) {
try {
dataSource.close();
} catch (Exception e) {
logger.warn("An error was produced during datasource close", e);
}
}
deploymentRegistry.remove(currentDeploymentInfo.getDeploymentId());
deployedDataSources.remove(currentDeploymentInfo.getDeploymentId());
deploymentInfos.remove(currentDeploymentInfo.getDeploymentId());
}
use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.
the class DBCPDataSourceProvider method lookupDataSource.
@Override
public DataSource lookupDataSource(DataSourceDeploymentInfo deploymentInfo) throws Exception {
DBCPDataSource dataSource = deploymentRegistry.get(deploymentInfo.getDeploymentId());
if (dataSource != null) {
if (dataSource.isNew()) {
// first access to the data source
dataSource.setStatus(DataSourceStatus.REFERENCED);
}
DataSourceDeploymentInfo _deploymentInfo = deploymentInfos.get(deploymentInfo.getDeploymentId());
if (_deploymentInfo != null) {
DataSourceDeploymentInfo updatedDeploymentInfo = new DataSourceDeploymentInfo(deploymentInfo.getDeploymentId(), true, deploymentInfo.getUuid(), true);
deploymentInfos.put(deploymentInfo.getDeploymentId(), updatedDeploymentInfo);
}
return dataSource;
} else {
throw new Exception("Data source for: " + deploymentInfo + " is not deployed in current system.");
}
}
Aggregations