use of org.pentaho.database.model.IDatabaseConnection in project pentaho-platform by pentaho.
the class JcrBackedDatasourceMgmtServiceTest method createDatabaseConnection.
private IDatabaseConnection createDatabaseConnection(final String dbName) throws Exception {
IDatabaseConnection dbConnection = new DatabaseConnection();
dbConnection.setName(dbName);
dbConnection.setHostname(EXP_DBMETA_HOSTNAME);
dbConnection.setDatabaseType(mockDatabaseType("Hypersonic"));
dbConnection.setAccessType(DatabaseAccessType.NATIVE);
dbConnection.setDatabasePort(EXP_DBMETA_PORT);
return dbConnection;
}
use of org.pentaho.database.model.IDatabaseConnection in project pentaho-platform by pentaho.
the class DatasourceMgmtToWebServiceAdapterTest method testEverything.
@Test
public void testEverything() throws Exception {
String id = adapter.createDatasource(createDatabaseConnection("testDatabase"));
assertNotNull(id);
IDatabaseConnection databaseConnection = adapter.getDatasourceByName("testDatabase");
assertNotNull(databaseConnection);
assertEquals(EXP_DBMETA_HOSTNAME, databaseConnection.getHostname());
IDatabaseConnection databaseConnection1 = adapter.getDatasourceById(id);
assertEquals(EXP_DBMETA_HOSTNAME, databaseConnection.getHostname());
String id1 = adapter.createDatasource(createDatabaseConnection("testDatabase1"));
assertNotNull(id1);
IDatabaseConnection databaseConnection2 = adapter.getDatasourceByName("testDatabase1");
assertNotNull(databaseConnection2);
assertEquals(EXP_DBMETA_HOSTNAME, databaseConnection1.getHostname());
IDatabaseConnection databaseConnection3 = adapter.getDatasourceById(id1);
assertEquals(EXP_DBMETA_HOSTNAME, databaseConnection1.getHostname());
List<IDatabaseConnection> databaseConnections = adapter.getDatasources();
assertEquals(2, databaseConnections.size());
List<String> ids = adapter.getDatasourceIds();
assertEquals(2, ids.size());
updateDatabaseConnection(databaseConnection);
String id2 = adapter.updateDatasourceByName("testDatabase", databaseConnection);
assertNotNull(id2);
IDatabaseConnection updatedDatabaseConnection = adapter.getDatasourceByName("testDatabase");
String id3 = adapter.updateDatasourceById(id, databaseConnection);
assertNotNull(id3);
updatedDatabaseConnection = adapter.getDatasourceById(id3);
assertNotNull(updatedDatabaseConnection);
assertEquals(EXP_UPDATED_DBMETA_HOSTNAME, databaseConnection.getHostname());
String id4 = adapter.createDatasource(createDatabaseConnection("testDatabase3"));
assertNotNull(id4);
adapter.deleteDatasourceByName("testDatabase3");
IDatabaseConnection deletedDatabaseConnection = adapter.getDatasourceByName("testDatabase3");
assertNull(deletedDatabaseConnection);
IDatabaseConnection deletedDatabaseConnection111 = adapter.getDatasourceById(id4);
assertNull(deletedDatabaseConnection111);
String id5 = adapter.createDatasource(createDatabaseConnection("testDatabase4"));
assertNotNull(id5);
adapter.deleteDatasourceById(id5);
IDatabaseConnection deletedDatabaseConnection11 = adapter.getDatasourceByName("testDatabase4");
assertNull(deletedDatabaseConnection11);
IDatabaseConnection deletedDatabaseConnection1 = adapter.getDatasourceById(id5);
assertNull(deletedDatabaseConnection1);
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionServiceImplIT method testAddConnection.
@Test
public void testAddConnection() throws ConnectionServiceException {
DatabaseConnection connection = new DatabaseConnection();
connection.setName(SECOND_CONNECTION);
connectionServiceImpl.addConnection(connection);
IDatabaseConnection actualCnnection = connectionServiceImpl.getConnectionByName(SECOND_CONNECTION);
assertEquals(connection, actualCnnection);
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionServiceImplIT method testGetConnectionByID.
@Test
public void testGetConnectionByID() throws ConnectionServiceException {
IDatabaseConnection connection = connectionServiceImpl.getConnectionById(EXIST_CONNECTION_ID);
assertNotNull(connection);
assertEquals(EXIST_CONNECTION_NAME, connection.getName());
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionServiceImplIT method testUpdateConnection.
@Test
public void testUpdateConnection() throws ConnectionServiceException {
DatabaseConnection connection = new DatabaseConnection();
connection.setName(EXIST_CONNECTION_NAME);
connection.setPassword(NEW_PASSWORD);
connectionServiceImpl.updateConnection(connection);
IDatabaseConnection actualConnection = connectionServiceImpl.getConnectionByName(EXIST_CONNECTION_NAME);
assertEquals(NEW_PASSWORD, actualConnection.getPassword());
}
Aggregations