HiveDatabaseMeta extends DatabaseMetaWithVersion { @Override public String getURL( String hostname, String port, String databaseName ) { if ( Const.isEmpty( port ) ) { port = Integer.toString( getDefaultDatabasePort() ); } return URL_PREFIX + hostname + ":" + port + "/" + databaseName; } HiveDatabaseMeta( DriverLocator driverLocator ); @Override int[] getAccessTypeList(); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean useAutoinc,
                                       String pk, boolean semicolon ); @Override String getDriverClass(); @Override String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean useAutoinc,
                                    boolean addFieldname, boolean addCr ); @Override String getModifyColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean useAutoinc,
                                          String pk, boolean semicolon ); @Override String getURL( String hostname, String port, String databaseName ); @Override String[] getUsedLibraries(); @Override String getSelectCountStatement( String tableName ); @Override String generateColumnAlias( int columnIndex, String suggestedName ); String getStartQuote(); String getEndQuote(); @Override int getDefaultDatabasePort(); @Override String[] getTableTypes(); @Override String[] getViewTypes(); @Override String getTruncateTableStatement( String tableName ); @Override boolean supportsSetCharacterStream(); @Override boolean supportsBatchUpdates(); @Override boolean supportsTimeStampToDateConversion(); static final String URL_PREFIX; static final String SELECT_COUNT_1_FROM; static final String VIEW; static final String VIRTUAL_VIEW; static final String TRUNCATE_TABLE; }
@Test public void testGetURL() throws KettleDatabaseException, MalformedURLException { String testHostname = "testHostname"; int port = 9429; String testDbName = "testDbName"; String urlString = hiveDatabaseMeta.getURL( testHostname, "" + port, testDbName ); assertTrue( urlString.startsWith( HiveDatabaseMeta.URL_PREFIX ) ); urlString = "http: URL url = new URL( urlString ); assertEquals( testHostname, url.getHost() ); assertEquals( port, url.getPort() ); assertEquals( "/" + testDbName, url.getPath() ); }