@Test @DisplayName("Verify that schemas can be obtained from INFORMATION_SCHEMA") public void schemataView(final Connection connection) throws SQLException { final DatabaseMetaData databaseMetaData = mock(DatabaseMetaData.class); final Connection spyConnection = spy(connection); when(spyConnection.getMetaData()).thenReturn(databaseMetaData); final MutableCatalog catalog = new MutableCatalog("test_catalog"); final InformationSchemaViews informationSchemaViews = InformationSchemaViewsBuilder.builder() .withSql(InformationSchemaKey.SCHEMATA, "SELECT * FROM INFORMATION_SCHEMA.SCHEMATA") .toOptions(); final SchemaRetrievalOptionsBuilder schemaRetrievalOptionsBuilder = SchemaRetrievalOptionsBuilder.builder(); schemaRetrievalOptionsBuilder.withInformationSchemaViews(informationSchemaViews); final SchemaRetrievalOptions schemaRetrievalOptions = schemaRetrievalOptionsBuilder.toOptions(); final RetrieverConnection retrieverConnection = new RetrieverConnection(spyConnection, schemaRetrievalOptions); final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions(); final SchemaRetriever schemaRetriever = new SchemaRetriever(retrieverConnection, catalog, options); schemaRetriever.retrieveSchemas(new IncludeAll()); verify(databaseMetaData, times(0)).getSchemas(); assertThat( schemaRetriever .getAllSchemas() .values() .stream() .map(schema -> schema.getFullName()) .collect(toList()), is( asList( "PUBLIC.BOOKS", "PUBLIC.FOR_LINT", "PUBLIC.INFORMATION_SCHEMA", "PUBLIC.PUBLIC", "PUBLIC.\"PUBLISHER SALES\"", "PUBLIC.SYSTEM_LOBS"))); }
void retrieveSchemas(final InclusionRule schemaInclusionRule) throws SQLException { final InclusionRuleFilter<Schema> schemaFilter = new InclusionRuleFilter<>(schemaInclusionRule, true); if (schemaFilter.isExcludeAll()) { return; } final Set<SchemaReference> schemaRefs; schemaRefs = retrieveAllSchemasFromInformationSchemaViews(); if (schemaRefs.isEmpty()) { schemaRefs.addAll(retrieveAllSchemas()); } for (final Iterator<SchemaReference> iterator = schemaRefs.iterator(); iterator.hasNext(); ) { final SchemaReference schemaRef = iterator.next(); if (!schemaFilter.test(schemaRef)) { LOGGER.log(Level.FINER, new StringFormat("Excluding schema <%s>", schemaRef)); iterator.remove(); } } for (final SchemaReference schemaRef : schemaRefs) { catalog.addSchema(schemaRef); } if (!supportsCatalogs && !supportsSchemas) { catalog.addSchema(new SchemaReference(null, null)); } }
SchemaRetriever extends AbstractRetriever { void retrieveSchemas(final InclusionRule schemaInclusionRule) throws SQLException { final InclusionRuleFilter<Schema> schemaFilter = new InclusionRuleFilter<>(schemaInclusionRule, true); if (schemaFilter.isExcludeAll()) { return; } final Set<SchemaReference> schemaRefs; schemaRefs = retrieveAllSchemasFromInformationSchemaViews(); if (schemaRefs.isEmpty()) { schemaRefs.addAll(retrieveAllSchemas()); } for (final Iterator<SchemaReference> iterator = schemaRefs.iterator(); iterator.hasNext(); ) { final SchemaReference schemaRef = iterator.next(); if (!schemaFilter.test(schemaRef)) { LOGGER.log(Level.FINER, new StringFormat("Excluding schema <%s>", schemaRef)); iterator.remove(); } } for (final SchemaReference schemaRef : schemaRefs) { catalog.addSchema(schemaRef); } if (!supportsCatalogs && !supportsSchemas) { catalog.addSchema(new SchemaReference(null, null)); } } }
SchemaRetriever extends AbstractRetriever { void retrieveSchemas(final InclusionRule schemaInclusionRule) throws SQLException { final InclusionRuleFilter<Schema> schemaFilter = new InclusionRuleFilter<>(schemaInclusionRule, true); if (schemaFilter.isExcludeAll()) { return; } final Set<SchemaReference> schemaRefs; schemaRefs = retrieveAllSchemasFromInformationSchemaViews(); if (schemaRefs.isEmpty()) { schemaRefs.addAll(retrieveAllSchemas()); } for (final Iterator<SchemaReference> iterator = schemaRefs.iterator(); iterator.hasNext(); ) { final SchemaReference schemaRef = iterator.next(); if (!schemaFilter.test(schemaRef)) { LOGGER.log(Level.FINER, new StringFormat("Excluding schema <%s>", schemaRef)); iterator.remove(); } } for (final SchemaReference schemaRef : schemaRefs) { catalog.addSchema(schemaRef); } if (!supportsCatalogs && !supportsSchemas) { catalog.addSchema(new SchemaReference(null, null)); } } SchemaRetriever(
      final RetrieverConnection retrieverConnection,
      final MutableCatalog catalog,
      final SchemaCrawlerOptions options); }
SchemaRetriever extends AbstractRetriever { void retrieveSchemas(final InclusionRule schemaInclusionRule) throws SQLException { final InclusionRuleFilter<Schema> schemaFilter = new InclusionRuleFilter<>(schemaInclusionRule, true); if (schemaFilter.isExcludeAll()) { return; } final Set<SchemaReference> schemaRefs; schemaRefs = retrieveAllSchemasFromInformationSchemaViews(); if (schemaRefs.isEmpty()) { schemaRefs.addAll(retrieveAllSchemas()); } for (final Iterator<SchemaReference> iterator = schemaRefs.iterator(); iterator.hasNext(); ) { final SchemaReference schemaRef = iterator.next(); if (!schemaFilter.test(schemaRef)) { LOGGER.log(Level.FINER, new StringFormat("Excluding schema <%s>", schemaRef)); iterator.remove(); } } for (final SchemaReference schemaRef : schemaRefs) { catalog.addSchema(schemaRef); } if (!supportsCatalogs && !supportsSchemas) { catalog.addSchema(new SchemaReference(null, null)); } } SchemaRetriever(
      final RetrieverConnection retrieverConnection,
      final MutableCatalog catalog,
      final SchemaCrawlerOptions options);  }
SchemaRetriever extends AbstractRetriever { void retrieveSchemas(final InclusionRule schemaInclusionRule) throws SQLException { final InclusionRuleFilter<Schema> schemaFilter = new InclusionRuleFilter<>(schemaInclusionRule, true); if (schemaFilter.isExcludeAll()) { return; } final Set<SchemaReference> schemaRefs; schemaRefs = retrieveAllSchemasFromInformationSchemaViews(); if (schemaRefs.isEmpty()) { schemaRefs.addAll(retrieveAllSchemas()); } for (final Iterator<SchemaReference> iterator = schemaRefs.iterator(); iterator.hasNext(); ) { final SchemaReference schemaRef = iterator.next(); if (!schemaFilter.test(schemaRef)) { LOGGER.log(Level.FINER, new StringFormat("Excluding schema <%s>", schemaRef)); iterator.remove(); } } for (final SchemaReference schemaRef : schemaRefs) { catalog.addSchema(schemaRef); } if (!supportsCatalogs && !supportsSchemas) { catalog.addSchema(new SchemaReference(null, null)); } } SchemaRetriever(
      final RetrieverConnection retrieverConnection,
      final MutableCatalog catalog,
      final SchemaCrawlerOptions options);   }