/** * 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 initialize(Configuration cfg, ServiceRegistry serviceRegistry, Settings settings) { super.initialize(cfg, serviceRegistry, settings); JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class); dialect = jdbcServices.getDialect(); tableSelector = new TableSelectorStrategy(new DefaultReverseEngineeringStrategy()); reader = JDBCReaderFactory.newJDBCReader(serviceRegistry, settings, tableSelector); dbc = new DefaultDatabaseCollector(reader.getMetaDataDialect()); mapping = cfg.buildMapping(); }
@Test public void testNewDatabaseCollector() { Configuration cfg = new Configuration(); IJDBCReader jdbcReader = FACADE_FACTORY.createJDBCReader( JDBCReaderFactory.newJDBCReader( cfg.getProperties(), cfg.buildSettings(), new DefaultReverseEngineeringStrategy())); IDatabaseCollector databaseCollectorFacade = service.newDatabaseCollector(jdbcReader); Assert.assertNotNull(databaseCollectorFacade); DatabaseCollector databaseCollector = (DatabaseCollector) ((IFacade) databaseCollectorFacade).getTarget(); Assert.assertNotNull(databaseCollector); }