use of org.pentaho.database.model.DatabaseConnection in project data-access by pentaho.
the class WizardConnectionController method showEditConnectionDialog.
@Bindable
public void showEditConnectionDialog() {
datasourceModel.setEditing(true);
if (databaseDialog != null) {
IDatabaseConnection connection = datasourceModel.getSelectedRelationalConnection();
previousConnectionName = connection.getName();
existingConnectionName = previousConnectionName;
DatabaseConnection editConnection = new DatabaseConnection();
copyDatabaseConnectionProperties(connection, editConnection);
databaseDialog.setDatabaseConnection(editConnection);
databaseDialog.show();
} else {
databaseDialog = new GwtDatabaseDialog(databaseTypeHelper, GWT.getModuleBaseURL() + "dataaccess-databasedialog.xul", // $NON-NLS-1$
connectionSetter);
}
}
use of org.pentaho.database.model.DatabaseConnection in project data-access by pentaho.
the class InMemoryConnectionServiceImplTest method testGetConnectionByName.
@Test
public void testGetConnectionByName() {
try {
InMemoryConnectionServiceImpl serv = new InMemoryConnectionServiceImpl();
List<IDatabaseConnection> conns = serv.getConnections();
assertTrue(conns != null && conns.size() == 0);
IDatabaseConnection connection = new DatabaseConnection();
connection.setName("Connection 1");
serv.addConnection(connection);
connection = new DatabaseConnection();
connection.setName("Connection 2");
serv.addConnection(connection);
connection = serv.getConnectionByName("Connection 2");
assertTrue(connection != null && connection.getName().equals("Connection 2"));
try {
connection = serv.getConnectionByName("Connection 5");
fail();
} catch (Exception ex) {
}
} catch (Exception ex) {
fail();
}
}
use of org.pentaho.database.model.DatabaseConnection in project data-access by pentaho.
the class InMemoryConnectionServiceImplTest method testDeleteConnections.
@Test
public void testDeleteConnections() {
try {
InMemoryConnectionServiceImpl serv = new InMemoryConnectionServiceImpl();
List<IDatabaseConnection> conns = serv.getConnections();
assertTrue(conns != null && conns.size() == 0);
IDatabaseConnection connection = new DatabaseConnection();
connection.setName("Connection 1");
serv.addConnection(connection);
connection = new DatabaseConnection();
connection.setName("Connection 2");
serv.addConnection(connection);
conns = serv.getConnections();
assertTrue(conns != null && conns.size() == 2);
try {
serv.deleteConnection(connection);
connection = serv.getConnectionByName("Connection 2");
fail();
} catch (Exception ex) {
}
try {
serv.deleteConnection("Connection 1");
connection = serv.getConnectionByName("Connection 1");
fail();
} catch (Exception ex) {
}
} catch (Exception ex) {
fail();
}
}
use of org.pentaho.database.model.DatabaseConnection in project data-access by pentaho.
the class InMemoryConnectionServiceImplTest method testAddConnections.
@Test
public void testAddConnections() {
try {
InMemoryConnectionServiceImpl serv = new InMemoryConnectionServiceImpl();
List<IDatabaseConnection> conns = serv.getConnections();
assertTrue(conns != null && conns.size() == 0);
IDatabaseConnection connection = new DatabaseConnection();
connection.setName("Connection 1");
serv.addConnection(connection);
connection = new DatabaseConnection();
connection.setName("Connection 1");
try {
// validate adding connection with existing name
serv.addConnection(connection);
fail();
} catch (ConnectionServiceException e) {
}
connection = new DatabaseConnection();
connection.setName("Connection 2");
serv.addConnection(connection);
conns = serv.getConnections();
assertTrue(conns != null && conns.size() > 0);
} catch (Exception ex) {
fail();
}
}
use of org.pentaho.database.model.DatabaseConnection in project data-access by pentaho.
the class UtilHtmlSanitizerTest method testUnsanitizeConnectionParameters.
@Test
public void testUnsanitizeConnectionParameters() throws Exception {
DatabaseConnection connection = new DatabaseConnection();
connection.setName("<font color=\"red\">\"AAAAAAAAAAAA\"");
assertEquals("<font color=\"red\">\"AAAAAAAAAAAA\"", connection.getName());
sanitizer.sanitizeConnectionParameters(connection);
assertEquals("<font color="red">"AAAAAAAAAAAA"", connection.getName());
sanitizer.unsanitizeConnectionParameters(connection);
assertEquals("<font color=\"red\">\"AAAAAAAAAAAA\"", connection.getName());
assertNull(connection.getDatabaseName());
}
Aggregations