/** * There are 2 solutions: 1. DatabaseCollector#addTable()/getTable() should be called for not * quoted parameters - I think it is preferable way. 2. DatabaseCollector#addTable()/getTable() * should be called for quoted parameters - here users should use the same quotes as JDBCReader. * Because of this there are 2 opposite methods(and they are both failed as addTable uses quoted * names but getTable uses non-quoted names ) */ public void testQuotedNamesAndDefaultDatabaseCollector() { StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder(); ServiceRegistry serviceRegistry = builder.build(); MetaDataDialect realMetaData = MetaDataDialectFactory.createMetaDataDialect( serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties()); JDBCReader reader = JDBCReaderFactory.newJDBCReader( cfg.getProperties(), new DefaultReverseEngineeringStrategy(), realMetaData, serviceRegistry); DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect()); reader.readDatabaseSchema(dc, null, SCHEMA); assertNotNull("The table should be found", dc.getTable(SCHEMA, "PUBLIC", TABLE1)); assertNotNull("The table should be found", dc.getTable(SCHEMA, "PUBLIC", TABLE2)); assertNull( "Quoted names should not return the table", dc.getTable(quote(SCHEMA), "PUBLIC", QTABLE1)); assertNull( "Quoted names should not return the table", dc.getTable(quote(SCHEMA), "PUBLIC", QTABLE2)); assertEquals("Foreign key 'masterref' was filtered!", 1, dc.getOneToManyCandidates().size()); }
public void testNeedQuote() { ServiceRegistry serviceRegistry = cfg.getServiceRegistry(); MetaDataDialect realMetaData = MetaDataDialectFactory.createMetaDataDialect( serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties()); assertTrue("The name must be quoted!", realMetaData.needQuote(SCHEMA)); assertTrue("The name must be quoted!", realMetaData.needQuote(TABLE1)); assertTrue("The name must be quoted!", realMetaData.needQuote(TABLE2)); }