Search in sources :

Example 1 with DatabaseConnection

use of org.pentaho.database.model.DatabaseConnection in project pentaho-platform by pentaho.

the class DatasourceMgmtToWebServiceAdapterTest 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;
}
Also used : DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection)

Example 2 with DatabaseConnection

use of org.pentaho.database.model.DatabaseConnection in project pentaho-platform by pentaho.

the class DefaultDatasourceMgmtWebServiceTest method createDatabaseConnection.

private DatabaseConnection createDatabaseConnection(final String dbName) throws Exception {
    DatabaseConnection 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;
}
Also used : DatabaseConnection(org.pentaho.database.model.DatabaseConnection)

Example 3 with DatabaseConnection

use of org.pentaho.database.model.DatabaseConnection in project pentaho-platform by pentaho.

the class DatabaseHelperTest method createDatabaseConnection.

private DatabaseConnection createDatabaseConnection() {
    DatabaseConnection databaseConnection = new DatabaseConnection();
    databaseConnection.setDatabaseType(new DatabaseType());
    databaseConnection.setName("name");
    databaseConnection.setId("id");
    databaseConnection.setAccessType(DatabaseAccessType.CUSTOM);
    databaseConnection.setHostname("hostName");
    databaseConnection.setDatabaseName("databaseName");
    databaseConnection.setDatabasePort("8080");
    databaseConnection.setUsername("username");
    databaseConnection.setPassword("password");
    databaseConnection.setInformixServername("informixServername");
    databaseConnection.setDataTablespace("dataTablespace");
    databaseConnection.setIndexTablespace("indexTableSpace");
    databaseConnection.setConnectSql("connectSql");
    databaseConnection.setInitialPoolSize(1);
    databaseConnection.setMaximumPoolSize(1);
    databaseConnection.setUsingConnectionPool(true);
    databaseConnection.setForcingIdentifiersToLowerCase(true);
    databaseConnection.setForcingIdentifiersToUpperCase(true);
    databaseConnection.setQuoteAllFields(true);
    databaseConnection.setUsingDoubleDecimalAsSchemaTableSeparator(true);
    Map<String, String> attributeMap = new HashMap<String, String>();
    attributeMap.put("key", "value");
    databaseConnection.setAttributes(attributeMap);
    Map<String, String> connectionPoolingMap = new HashMap<String, String>();
    connectionPoolingMap.put("key", "value");
    databaseConnection.setConnectionPoolingProperties(connectionPoolingMap);
    Map<String, String> extraOptions = new HashMap<String, String>();
    extraOptions.put("key", "value");
    databaseConnection.setExtraOptions(extraOptions);
    Map<String, String> extraOptionsOrder = new HashMap<String, String>();
    extraOptions.put("key", "value");
    databaseConnection.setExtraOptionsOrder(extraOptions);
    return databaseConnection;
}
Also used : DatabaseType(org.pentaho.database.model.DatabaseType) HashMap(java.util.HashMap) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection)

Example 4 with DatabaseConnection

use of org.pentaho.database.model.DatabaseConnection in project pentaho-platform by pentaho.

the class ExportManifestTest method testUnMarshal.

@Test
public void testUnMarshal() {
    String xml = XmlToString();
    ExportManifest importManifest = null;
    ByteArrayInputStream input = new ByteArrayInputStream(xml.getBytes());
    try {
        importManifest = ExportManifest.fromXml(input);
    } catch (JAXBException e) {
        fail("Could not un-marshal to object " + e);
    }
    ExportManifestEntity fileEntity = importManifest.getExportManifestEntity("dir2/file1");
    assertNotNull(fileEntity);
    assertEquals("dir2/file1", fileEntity.getPath());
    assertNotNull(fileEntity.getEntityMetaData());
    assertFalse(fileEntity.getEntityMetaData().isIsFolder());
    fileEntity = importManifest.getExportManifestEntity("dir2");
    assertNotNull(fileEntity);
    assertNotNull(fileEntity.getEntityMetaData());
    assertTrue(fileEntity.getEntityMetaData().isIsFolder());
    RepositoryFile r = fileEntity.getRepositoryFile();
    try {
        RepositoryFileAcl rfa = fileEntity.getRepositoryFileAcl();
        assertNotNull(rfa.getAces());
    } catch (ExportManifestFormatException e) {
        e.printStackTrace();
        fail("Could not un-marshal to RepositoryFileAcl");
    }
    assertEquals(1, importManifest.getMetadataList().size());
    assertEquals(1, importManifest.getMondrianList().size());
    assertEquals(1, importManifest.getScheduleList().size());
    assertEquals(1, importManifest.getDatasourceList().size());
    ExportManifestMondrian mondrian1 = importManifest.getMondrianList().get(0);
    assertEquals("cat1", mondrian1.getCatalogName());
    assertTrue(mondrian1.getParameters().containsKey("testKey"));
    assertEquals("testValue", mondrian1.getParameters().get("testKey"));
    assertEquals("testMondrian.xml", mondrian1.getFile());
    ExportManifestMetadata metadata1 = importManifest.getMetadataList().get(0);
    assertEquals("testDomain", metadata1.getDomainId());
    assertEquals("testMetadata.xml", metadata1.getFile());
    DatabaseConnection connection = importManifest.getDatasourceList().get(0);
    assertEquals("SampleData", connection.getDatabaseName());
    assertEquals("9001", connection.getDatabasePort());
    assertEquals("Hypersonic", connection.getDatabaseType().getName());
    assertEquals("HYPERSONIC", connection.getDatabaseType().getShortName());
    assertEquals("localhost", connection.getHostname());
    assertEquals("pentaho_user", connection.getUsername());
    assertEquals("password", connection.getPassword());
    assertEquals(20, connection.getMaximumPoolSize());
}
Also used : ExportManifestMetadata(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestMetadata) ByteArrayInputStream(java.io.ByteArrayInputStream) JAXBException(javax.xml.bind.JAXBException) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) ExportManifestMondrian(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.ExportManifestMondrian) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 5 with DatabaseConnection

use of org.pentaho.database.model.DatabaseConnection in project pentaho-platform by pentaho.

the class PooledDatasourceHelperTest method testCreatePoolNoClassName.

@Test
public void testCreatePoolNoClassName() throws Exception {
    DatabaseDialectService dialectService = new DatabaseDialectService(false);
    final DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper(dialectService.getDatabaseTypes());
    mp = new MicroPlatform(SOLUTION_PATH);
    mp.defineInstance(IDatabaseDialectService.class, dialectService);
    mp.start();
    final DatabaseConnection con = new DatabaseConnection();
    con.setId("Postgres");
    con.setName("Postgres");
    con.setAccessType(DatabaseAccessType.NATIVE);
    con.setDatabaseType(databaseTypeHelper.getDatabaseTypeByShortName("GENERIC"));
    con.setUsername("pentaho_user");
    con.setPassword("password");
    final HashMap<String, String> attrs = new HashMap<>();
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_DRIVER_CLASS, "");
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_URL, "jdbc:postgresql://localhost:5432/hibernate");
    con.setAttributes(attrs);
    try {
        PooledDatasourceHelper.setupPooledDataSource(con);
        fail("Expecting the exception to be thrown");
    } catch (DBDatasourceServiceException ex) {
        assertNotNull(ex);
    }
}
Also used : DBDatasourceServiceException(org.pentaho.platform.api.data.DBDatasourceServiceException) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) HashMap(java.util.HashMap) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) DatabaseDialectService(org.pentaho.database.service.DatabaseDialectService) IDatabaseDialectService(org.pentaho.database.service.IDatabaseDialectService) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

DatabaseConnection (org.pentaho.database.model.DatabaseConnection)56 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)48 Test (org.junit.Test)36 HashMap (java.util.HashMap)10 IDatabaseDialectService (org.pentaho.database.service.IDatabaseDialectService)7 DatabaseType (org.pentaho.database.model.DatabaseType)6 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)6 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)6 ArrayList (java.util.ArrayList)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 IDatabaseType (org.pentaho.database.model.IDatabaseType)5 DBDatasourceServiceException (org.pentaho.platform.api.data.DBDatasourceServiceException)5 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)5 Response (javax.ws.rs.core.Response)4 List (java.util.List)3 LinkedList (java.util.LinkedList)2 Mockito.anyString (org.mockito.Mockito.anyString)2 DatabaseAccessType (org.pentaho.database.model.DatabaseAccessType)2 PartitionDatabaseMeta (org.pentaho.database.model.PartitionDatabaseMeta)2 Category (org.pentaho.metadata.model.Category)2