From c2f4ee309a39bad012b189e13cef276985fd0b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Wed, 13 Nov 2019 13:44:26 +0100 Subject: [PATCH] #10: Dialect name list now assembled at runtime. (#11) * #10: Dialect name list now assembled at runtime. * #10: Automatted dialect list detection * #12: Changed java version from 9 to 11 --- .settings/org.eclipse.jdt.core.prefs | 14 +- .settings/org.eclipse.jdt.ui.prefs | 71 ++- .travis.yml | 2 +- README.md | 2 +- pom.xml | 473 +++++++++--------- .../adapternotes/ColumnAdapterNotes.java | 2 +- .../adapternotes/SchemaAdapterNotes.java | 67 +-- .../adapter/dialects/SqlDialectRegistry.java | 37 +- .../dialects/SqlGenerationContext.java | 4 +- .../adapter/dialects/SqlGenerationHelper.java | 8 +- .../dialects/SqlGenerationVisitor.java | 4 +- .../jdbc/BaseRemoteMetadataReader.java | 3 +- .../com/exasol/adapter/jdbc/JdbcAdapter.java | 9 - .../adapter/jdbc/JdbcAdapterFactory.java | 4 +- .../com.exasol.adapter.AdapterFactory | 1 + ....exasol.adapter.dialects.SqlDialectFactory | 1 - .../SchemaAdapterNotesJsonConverterTest.java | 37 +- .../adapternotes/SchemaAdapterNotesTest.java | 114 +++-- ...ava => AbstractQueryRewriterTestBase.java} | 2 +- .../dialects/BaseIdentifierConverterTest.java | 4 +- .../dialects/BaseQueryRewriterTest.java | 2 +- .../adapter/dialects/DialectTestData.java | 50 -- .../dialects/SqlDialectRegistryTest.java | 28 +- .../dialects/derby/DerbySqlDialect.java | 6 +- ...AbstractColumnMetadataReaderTestBase.java} | 2 +- ...tConnectionDefinitionBuilderTestBase.java} | 2 +- .../jdbc/BaseColumnMetadataReaderTest.java | 36 +- .../BaseConnectionDefinitionBuilderTest.java | 2 +- .../exasol/adapter/jdbc/JdbcAdapterIT.java | 38 ++ .../exasol/adapter/jdbc/JdbcAdapterTest.java | 7 +- .../java/com/exasol/sql/SqlNormalizer.java | 9 +- ....exasol.adapter.dialects.SqlDialectFactory | 2 + 32 files changed, 559 insertions(+), 484 deletions(-) create mode 100644 src/main/resources/META-INF/services/com.exasol.adapter.AdapterFactory delete mode 100644 src/main/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory rename src/test/java/com/exasol/adapter/dialects/{AbstractQueryRewriterTest.java => AbstractQueryRewriterTestBase.java} (97%) delete mode 100644 src/test/java/com/exasol/adapter/dialects/DialectTestData.java rename src/test/java/com/exasol/adapter/jdbc/{AbstractColumnMetadataReaderTest.java => AbstractColumnMetadataReaderTestBase.java} (95%) rename src/test/java/com/exasol/adapter/jdbc/{AbstractConnectionDefinitionBuilderTest.java => AbstractConnectionDefinitionBuilderTestBase.java} (97%) create mode 100644 src/test/java/com/exasol/adapter/jdbc/JdbcAdapterIT.java create mode 100644 src/test/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 5b1af68..ae409a1 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,14 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=9 +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false @@ -52,7 +52,9 @@ org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 @@ -61,6 +63,7 @@ org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line @@ -330,7 +333,12 @@ org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never org.eclipse.jdt.core.formatter.lineSplit=120 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs index a227ba5..32e9db6 100644 --- a/.settings/org.eclipse.jdt.ui.prefs +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -1,7 +1,74 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=true +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=true +cleanup.convert_to_enhanced_for_loop=true +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=true +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=true +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=false +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_modifiers=false +cleanup.remove_redundant_semicolons=false +cleanup.remove_redundant_type_arguments=false +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup_profile=_Exasol +cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Exasol -formatter_settings_version=16 +formatter_settings_version=17 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.ondemandthreshold=3 +org.eclipse.jdt.ui.staticondemandthreshold=3 +org.eclipse.jdt.ui.text.custom_code_templates= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true @@ -53,6 +120,7 @@ sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false sp_cleanup.use_blocks=true sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_lambda=true @@ -61,3 +129,4 @@ sp_cleanup.use_this_for_non_static_field_access=true sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false diff --git a/.travis.yml b/.travis.yml index a0d2e7e..8b77a78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java matrix: include: - - jdk: openjdk9 + - jdk: openjdk11 addons: sonarcloud: organization: exasol diff --git a/README.md b/README.md index e5e102c..0832750 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Please refer to the [documentation in the main Virtual Schema project](https://g ### Run Time Dependencies -Running the Virtual Schema requires a Java Runtime version 9 or later. +Running the Virtual Schema requires a Java Runtime version 11 or later. | Dependency | Purpose | License | |-------------------------------------------------------------------------------------|--------------------------------------------------------|-------------------------------| diff --git a/pom.xml b/pom.xml index 39efb99..5e5c088 100644 --- a/pom.xml +++ b/pom.xml @@ -1,235 +1,242 @@ - 4.0.0 - com.exasol - virtual-schema-common-jdbc - ${product.version} - Virtual Schema Common JDBC - Common module for JDBC-based data access from Virtual Schemas. - https://github.com/exasol/virtual-schema-common-jdbc - - 1.0.1 - UTF-8 - UTF-8 - 9 - 5.4.2 - 1.4.2 - 2.22.1 - 7.5.0 - true - - - - MIT - https://opensource.org/licenses/MIT - repo - - - - - Exasol - opensource@exasol.com - Exasol AG - https://www.exasol.com/ - - - - scm:git:https://github.com/exasol/virtual-schema-common-jdbc.git - scm:git:https://github.com/exasol/virtual-schema-common-jdbc.git - https://github.com/exasol/virtual-schema-common-jdbc/tree/master - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - maven.exasol.com - https://maven.exasol.com/artifactory/exasol-releases - - false - - - - maven.exasol.com-snapshots - https://maven.exasol.com/artifactory/exasol-snapshots - - true - - - - - - com.exasol - virtual-schema-common-java - ${vscommon.version} - - - com.exasol - java-util-logging-testing - 1.0.0 - - - org.hamcrest - hamcrest - 2.1 - test - - - org.skyscreamer - jsonassert - 1.5.0 - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.junit.platform - junit-platform-runner - ${junit.platform.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit.version} - test - - - nl.jqno.equalsverifier - equalsverifier - 3.1.10 - test - - - org.mockito - mockito-junit-jupiter - 2.23.4 - test - - - javax.xml.bind - jaxb-api - 2.3.1 - - - org.apache.derby - derby - 10.14.2.0 - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.version} - - - -Djava.util.logging.config.file=src/test/resources/logging.properties - ${argLine} - - - - org.jacoco - jacoco-maven-plugin - 0.8.5 - - - - prepare-agent - - - - report - test - - report - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - ${java.version} - ${java.version} - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - - attach-javadocs - - jar - - - - - UTF-8 - - true - true - true - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.2 - - - - test-jar - - - - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + com.exasol + virtual-schema-common-jdbc + ${product.version} + Virtual Schema Common JDBC + Common module for JDBC-based data access from Virtual Schemas. + https://github.com/exasol/virtual-schema-common-jdbc + + 2.0.0 + UTF-8 + UTF-8 + 11 + 5.4.2 + 1.4.2 + 2.22.1 + 8.0.0 + true + + + + MIT + https://opensource.org/licenses/MIT + repo + + + + + Exasol + opensource@exasol.com + Exasol AG + https://www.exasol.com/ + + + + scm:git:https://github.com/exasol/virtual-schema-common-jdbc.git + scm:git:https://github.com/exasol/virtual-schema-common-jdbc.git + https://github.com/exasol/virtual-schema-common-jdbc/tree/master + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + maven.exasol.com + https://maven.exasol.com/artifactory/exasol-releases + + false + + + + maven.exasol.com-snapshots + https://maven.exasol.com/artifactory/exasol-snapshots + + true + + + + + + com.exasol + virtual-schema-common-java + ${vscommon.version} + + + com.exasol + java-util-logging-testing + 1.0.0 + + + org.hamcrest + hamcrest + 2.1 + test + + + org.skyscreamer + jsonassert + 1.5.0 + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + nl.jqno.equalsverifier + equalsverifier + 3.1.10 + test + + + org.mockito + mockito-junit-jupiter + 2.23.4 + test + + + javax.xml.bind + jaxb-api + 2.3.1 + + + org.apache.derby + derby + 10.14.2.0 + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.version} + + + -Djava.util.logging.config.file=src/test/resources/logging.properties + ${argLine} + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + + prepare-agent + + + + report + test + + report + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.1 + + + attach-javadocs + + jar + + + + + UTF-8 + + true + true + true + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + test-jar + + + + **/*Test.class + **/*IT.class + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/exasol/adapter/adapternotes/ColumnAdapterNotes.java b/src/main/java/com/exasol/adapter/adapternotes/ColumnAdapterNotes.java index 5e1b6ae..545c61a 100644 --- a/src/main/java/com/exasol/adapter/adapternotes/ColumnAdapterNotes.java +++ b/src/main/java/com/exasol/adapter/adapternotes/ColumnAdapterNotes.java @@ -60,7 +60,7 @@ public static String serialize(final ColumnAdapterNotes notes) { * Deserialize column adapter notes. * * @param columnAdapterNotes column adapter notes - * @param columnName column name + * @param columnName column name * @return deserialized column adapter notes * @throws AdapterException if column adapter notes are empty or null */ diff --git a/src/main/java/com/exasol/adapter/adapternotes/SchemaAdapterNotes.java b/src/main/java/com/exasol/adapter/adapternotes/SchemaAdapterNotes.java index 40cf259..d82f4ed 100644 --- a/src/main/java/com/exasol/adapter/adapternotes/SchemaAdapterNotes.java +++ b/src/main/java/com/exasol/adapter/adapternotes/SchemaAdapterNotes.java @@ -63,64 +63,64 @@ public String getIdentifierQuoteString() { } /** - * @return true if remote database treats mixed case unquoted SQL identifiers as case sensitive - * and as a result stores them in mixed case. + * @return true if remote database treats mixed case unquoted SQL identifiers as case sensitive and as a result + * stores them in mixed case. */ public boolean supportsMixedCaseIdentifiers() { return this.supportsMixedCaseIdentifiers; } /** - * @return true if remote database treats mixed case quoted SQL identifiers as case sensitive - * and as a result stores them in mixed case. TRUE for EXASOL and Oracle. + * @return true if remote database treats mixed case quoted SQL identifiers as case sensitive and as a result stores + * them in mixed case. TRUE for EXASOL and Oracle. */ public boolean supportsMixedCaseQuotedIdentifiers() { return this.supportsMixedCaseQuotedIdentifiers; } /** - * @return true if remote database treats mixed case unquoted SQL identifiers - * as case insensitive and stores them in lower case. + * @return true if remote database treats mixed case unquoted SQL identifiers as case insensitive and stores them in + * lower case. */ public boolean storesLowerCaseIdentifiers() { return this.storesLowerCaseIdentifiers; } /** - * @return true if remote database treats mixed case unquoted SQL identifiers - * as case insensitive and stores them in upper case. TRUE for EXASOL and Oracle + * @return true if remote database treats mixed case unquoted SQL identifiers as case insensitive and stores them in + * upper case. TRUE for EXASOL and Oracle */ public boolean storesUpperCaseIdentifiers() { return this.storesUpperCaseIdentifiers; } /** - * @return true if remote database treats mixed case unquoted SQL identifiers - * as case insensitive and stores them in mixed case. + * @return true if remote database treats mixed case unquoted SQL identifiers as case insensitive and stores them in + * mixed case. */ public boolean storesMixedCaseIdentifiers() { return this.storesMixedCaseIdentifiers; } /** - * @return true if remote database treats mixed case quoted SQL identifiers as case insensitive - * and stores them in lower case. + * @return true if remote database treats mixed case quoted SQL identifiers as case insensitive and stores them in + * lower case. */ public boolean storesLowerCaseQuotedIdentifiers() { return this.storesLowerCaseQuotedIdentifiers; } /** - * @return true if remote database treats mixed case quoted SQL identifiers as case insensitive - * and stores them in upper case. + * @return true if remote database treats mixed case quoted SQL identifiers as case insensitive and stores them in + * upper case. */ public boolean storesUpperCaseQuotedIdentifiers() { return this.storesUpperCaseQuotedIdentifiers; } /** - * @return true if remote database treats mixed case quoted SQL identifiers as case insensitive - * and stores them in mixed case. TRUE for Oracle. + * @return true if remote database treats mixed case quoted SQL identifiers as case insensitive and stores them in + * mixed case. TRUE for Oracle. */ public boolean storesMixedCaseQuotedIdentifiers() { return this.storesMixedCaseQuotedIdentifiers; @@ -164,27 +164,28 @@ public boolean equals(final Object o) { } final SchemaAdapterNotes that = (SchemaAdapterNotes) o; return this.storesLowerCaseIdentifiers == that.storesLowerCaseIdentifiers - && this.storesUpperCaseIdentifiers == that.storesUpperCaseIdentifiers - && this.storesMixedCaseIdentifiers == that.storesMixedCaseIdentifiers - && this.supportsMixedCaseIdentifiers == that.supportsMixedCaseIdentifiers - && this.storesLowerCaseQuotedIdentifiers == that.storesLowerCaseQuotedIdentifiers - && this.storesUpperCaseQuotedIdentifiers == that.storesUpperCaseQuotedIdentifiers - && this.storesMixedCaseQuotedIdentifiers == that.storesMixedCaseQuotedIdentifiers - && this.supportsMixedCaseQuotedIdentifiers == that.supportsMixedCaseQuotedIdentifiers - && this.areNullsSortedAtEnd == that.areNullsSortedAtEnd - && this.areNullsSortedAtStart == that.areNullsSortedAtStart - && this.areNullsSortedHigh == that.areNullsSortedHigh && this.areNullsSortedLow == that.areNullsSortedLow - && Objects.equals(this.catalogSeparator, that.catalogSeparator) && Objects - .equals(this.identifierQuoteString, that.identifierQuoteString); + && this.storesUpperCaseIdentifiers == that.storesUpperCaseIdentifiers + && this.storesMixedCaseIdentifiers == that.storesMixedCaseIdentifiers + && this.supportsMixedCaseIdentifiers == that.supportsMixedCaseIdentifiers + && this.storesLowerCaseQuotedIdentifiers == that.storesLowerCaseQuotedIdentifiers + && this.storesUpperCaseQuotedIdentifiers == that.storesUpperCaseQuotedIdentifiers + && this.storesMixedCaseQuotedIdentifiers == that.storesMixedCaseQuotedIdentifiers + && this.supportsMixedCaseQuotedIdentifiers == that.supportsMixedCaseQuotedIdentifiers + && this.areNullsSortedAtEnd == that.areNullsSortedAtEnd + && this.areNullsSortedAtStart == that.areNullsSortedAtStart + && this.areNullsSortedHigh == that.areNullsSortedHigh + && this.areNullsSortedLow == that.areNullsSortedLow + && Objects.equals(this.catalogSeparator, that.catalogSeparator) + && Objects.equals(this.identifierQuoteString, that.identifierQuoteString); } @Override public int hashCode() { return Objects.hash(this.catalogSeparator, this.identifierQuoteString, this.storesLowerCaseIdentifiers, - this.storesUpperCaseIdentifiers, this.storesMixedCaseIdentifiers, this.supportsMixedCaseIdentifiers, - this.storesLowerCaseQuotedIdentifiers, this.storesUpperCaseQuotedIdentifiers, - this.storesMixedCaseQuotedIdentifiers, this.supportsMixedCaseQuotedIdentifiers, this.areNullsSortedAtEnd, - this.areNullsSortedAtStart, this.areNullsSortedHigh, this.areNullsSortedLow); + this.storesUpperCaseIdentifiers, this.storesMixedCaseIdentifiers, this.supportsMixedCaseIdentifiers, + this.storesLowerCaseQuotedIdentifiers, this.storesUpperCaseQuotedIdentifiers, + this.storesMixedCaseQuotedIdentifiers, this.supportsMixedCaseQuotedIdentifiers, + this.areNullsSortedAtEnd, this.areNullsSortedAtStart, this.areNullsSortedHigh, this.areNullsSortedLow); } @Override @@ -201,7 +202,7 @@ public String toString() { builder.append("storesLowerCaseQuotedIdentifiers=").append(this.storesLowerCaseQuotedIdentifiers).append(",\n"); builder.append("storesMixedCaseQuotedIdentifiers=").append(this.storesMixedCaseQuotedIdentifiers).append(",\n"); builder.append("supportsMixedCaseQuotedIdentifiers=").append(this.supportsMixedCaseQuotedIdentifiers) - .append(",\n"); + .append(",\n"); builder.append("areNullsSortedAtEnd=").append(this.areNullsSortedAtEnd).append(",\n"); builder.append("areNullsSortedAtStart=").append(this.areNullsSortedAtStart).append(",\n"); builder.append("areNullsSortedHigh=").append(this.areNullsSortedHigh).append(",\n"); diff --git a/src/main/java/com/exasol/adapter/dialects/SqlDialectRegistry.java b/src/main/java/com/exasol/adapter/dialects/SqlDialectRegistry.java index d35cac8..0031478 100644 --- a/src/main/java/com/exasol/adapter/dialects/SqlDialectRegistry.java +++ b/src/main/java/com/exasol/adapter/dialects/SqlDialectRegistry.java @@ -12,7 +12,7 @@ */ public final class SqlDialectRegistry { private static final Logger LOGGER = Logger.getLogger(SqlDialectRegistry.class.getName()); - private static final SqlDialectRegistry instance = new SqlDialectRegistry(); + private static SqlDialectRegistry instance; private final Map registeredFactories = new HashMap<>(); /** @@ -20,14 +20,16 @@ public final class SqlDialectRegistry { * * @return singleton instance */ - public static SqlDialectRegistry getInstance() { + public static final synchronized SqlDialectRegistry getInstance() { + if (instance == null) { + LOGGER.finer(() -> "Instanciating SQL dialect registry and loading adapter factories."); + instance = new SqlDialectRegistry(); + instance.loadSqlDialectFactories(); + } return instance; } - /** - * Load available dialect factories. - */ - public void loadSqlDialectFactories() { + private void loadSqlDialectFactories() { final ServiceLoader serviceLoader = ServiceLoader.load(SqlDialectFactory.class); final Iterator factories = serviceLoader.iterator(); while (factories.hasNext()) { @@ -40,21 +42,33 @@ public void loadSqlDialectFactories() { /** * Register a factory for an {@link SqlDialect}. * - * @param factory factory that can create the SqlDialect + * @param factory factory that creates an {@link SqlDialect} */ - public void registerSqlDialectFactory(final SqlDialectFactory factory) { + private void registerSqlDialectFactory(final SqlDialectFactory factory) { this.registeredFactories.put(factory.getSqlDialectName(), factory); } /** - * Get a list of all currently registered Virtual Schema Adapters. + * Get a list of all currently registered SQL dialect adapters. * - * @return list of adapter factories + * @return list of dialect factories */ public List getRegisteredAdapterFactories() { return new ArrayList<>(this.registeredFactories.values()); } + /** + * Get a list of the name of all registered SQL dialect adapters. + * + * @return list of dialect names + */ + public Set getRegisteredAdapterNames() { + return this.registeredFactories.values() // + .stream() // + .map(SqlDialectFactory::getSqlDialectName) // + .collect(Collectors.toSet()); + } + /** * Get the SQL dialect registered under the given name. * @@ -107,9 +121,10 @@ public String describe() { * @return comma-separated string containing list of SQL dialect names */ public String listRegisteredSqlDialectNames() { - return this.registeredFactories.keySet() // + final String dialectNamesAsString = this.registeredFactories.keySet() // .stream() // .sorted().map(name -> "\"" + name + "\"") // .collect(Collectors.joining(", ")); + return dialectNamesAsString.isEmpty() ? "none" : dialectNamesAsString; } } diff --git a/src/main/java/com/exasol/adapter/dialects/SqlGenerationContext.java b/src/main/java/com/exasol/adapter/dialects/SqlGenerationContext.java index be05e61..16c5792 100644 --- a/src/main/java/com/exasol/adapter/dialects/SqlGenerationContext.java +++ b/src/main/java/com/exasol/adapter/dialects/SqlGenerationContext.java @@ -14,8 +14,8 @@ public class SqlGenerationContext { * Creates a new instance of the {@link SqlGenerationContext}. * * @param catalogName catalog name as a string - * @param schemaName schema name as a string - * @param isLocal true if import is local + * @param schemaName schema name as a string + * @param isLocal true if import is local */ public SqlGenerationContext(final String catalogName, final String schemaName, final boolean isLocal) { this.catalogName = catalogName; diff --git a/src/main/java/com/exasol/adapter/dialects/SqlGenerationHelper.java b/src/main/java/com/exasol/adapter/dialects/SqlGenerationHelper.java index 739e062..679ad9a 100644 --- a/src/main/java/com/exasol/adapter/dialects/SqlGenerationHelper.java +++ b/src/main/java/com/exasol/adapter/dialects/SqlGenerationHelper.java @@ -15,18 +15,18 @@ */ public final class SqlGenerationHelper { private SqlGenerationHelper() { - //intentionally left blank + // intentionally left blank } /** * Check if selected node requires cast or not. * - * @param selectList SQL select list + * @param selectList SQL select list * @param nodeRequiresCast node that requires cast * @return true if selected node requires cast */ public static boolean selectListRequiresCasts(final SqlSelectList selectList, - final Predicate nodeRequiresCast) { + final Predicate nodeRequiresCast) { boolean requiresCasts = false; final SqlStatementSelect select = (SqlStatementSelect) selectList.getParent(); final int columnId = 0; @@ -45,7 +45,7 @@ public static boolean selectListRequiresCasts(final SqlSelectList selectList, /** * Add metadata to the list. * - * @param node SQL node to get metadata from + * @param node SQL node to get metadata from * @param metadata list of TableMetadata */ public static void addMetadata(final SqlNode node, final List metadata) { diff --git a/src/main/java/com/exasol/adapter/dialects/SqlGenerationVisitor.java b/src/main/java/com/exasol/adapter/dialects/SqlGenerationVisitor.java index 7e21fd0..329c6a7 100644 --- a/src/main/java/com/exasol/adapter/dialects/SqlGenerationVisitor.java +++ b/src/main/java/com/exasol/adapter/dialects/SqlGenerationVisitor.java @@ -271,14 +271,14 @@ public String visit(final SqlFunctionScalar function) throws AdapterException { functionNameInSourceSystem = this.dialect.getScalarFunctionAliases().get(function.getFunction()); } else { if (this.dialect.getBinaryInfixFunctionAliases().containsKey(function.getFunction())) { - assert (argumentsSql.size() == 2); + assert(argumentsSql.size() == 2); String realFunctionName = function.getFunctionName(); if (this.dialect.getBinaryInfixFunctionAliases().containsKey(function.getFunction())) { realFunctionName = this.dialect.getBinaryInfixFunctionAliases().get(function.getFunction()); } return "(" + argumentsSql.get(0) + " " + realFunctionName + " " + argumentsSql.get(1) + ")"; } else if (this.dialect.getPrefixFunctionAliases().containsKey(function.getFunction())) { - assert (argumentsSql.size() == 1); + assert(argumentsSql.size() == 1); String realFunctionName = function.getFunctionName(); if (this.dialect.getPrefixFunctionAliases().containsKey(function.getFunction())) { realFunctionName = this.dialect.getPrefixFunctionAliases().get(function.getFunction()); diff --git a/src/main/java/com/exasol/adapter/jdbc/BaseRemoteMetadataReader.java b/src/main/java/com/exasol/adapter/jdbc/BaseRemoteMetadataReader.java index c400b20..cb23297 100644 --- a/src/main/java/com/exasol/adapter/jdbc/BaseRemoteMetadataReader.java +++ b/src/main/java/com/exasol/adapter/jdbc/BaseRemoteMetadataReader.java @@ -10,8 +10,7 @@ * This class implements basic reading of database metadata from JDBC. * *

- * See java.sql.DatabaseMetaData + * See java.sql.DatabaseMetaData */ public final class BaseRemoteMetadataReader extends AbstractRemoteMetadataReader { /** diff --git a/src/main/java/com/exasol/adapter/jdbc/JdbcAdapter.java b/src/main/java/com/exasol/adapter/jdbc/JdbcAdapter.java index 2692be0..f5ed1f9 100644 --- a/src/main/java/com/exasol/adapter/jdbc/JdbcAdapter.java +++ b/src/main/java/com/exasol/adapter/jdbc/JdbcAdapter.java @@ -22,19 +22,10 @@ public class JdbcAdapter implements VirtualSchemaAdapter { private static final String PREDICATE_PREFIX = "FN_PRED_"; private static final String AGGREGATE_FUNCTION_PREFIX = "FN_AGG_"; private static final String LITERAL_PREFIX = "LITERAL_"; - private static final String TABLES_PROPERTY = "TABLE_FILTER"; - private static final Logger LOGGER = Logger.getLogger(JdbcAdapter.class.getName()); private final RemoteConnectionFactory connectionFactory = new RemoteConnectionFactory(); - /** - * Create a new instance of type {@link JdbcAdapter}. - */ - public JdbcAdapter() { - SqlDialectRegistry.getInstance().loadSqlDialectFactories(); - } - @Override public CreateVirtualSchemaResponse createVirtualSchema(final ExaMetadata exasolMetadata, final CreateVirtualSchemaRequest request) throws AdapterException { diff --git a/src/main/java/com/exasol/adapter/jdbc/JdbcAdapterFactory.java b/src/main/java/com/exasol/adapter/jdbc/JdbcAdapterFactory.java index ded7d0a..8821c30 100644 --- a/src/main/java/com/exasol/adapter/jdbc/JdbcAdapterFactory.java +++ b/src/main/java/com/exasol/adapter/jdbc/JdbcAdapterFactory.java @@ -5,6 +5,7 @@ import com.exasol.adapter.AdapterFactory; import com.exasol.adapter.VirtualSchemaAdapter; +import com.exasol.adapter.dialects.SqlDialectRegistry; import com.exasol.logging.VersionCollector; /** @@ -18,8 +19,7 @@ public class JdbcAdapterFactory implements AdapterFactory { @Override public Set getSupportedAdapterNames() { - return Set.of("ATHENA", "BIGQUERY", "DB2", "DERBY", "EXASOL", "GENERIC", "HIVE", "IMPALA", "MYSQL", "ORACLE", - "POSTGRESQL", "REDSHIFT", "SAPHANA", "SQLSERVER", "SYBASE", "TERADATA"); + return SqlDialectRegistry.getInstance().getRegisteredAdapterNames(); } @Override diff --git a/src/main/resources/META-INF/services/com.exasol.adapter.AdapterFactory b/src/main/resources/META-INF/services/com.exasol.adapter.AdapterFactory new file mode 100644 index 0000000..00a1f81 --- /dev/null +++ b/src/main/resources/META-INF/services/com.exasol.adapter.AdapterFactory @@ -0,0 +1 @@ +com.exasol.adapter.jdbc.JdbcAdapterFactory \ No newline at end of file diff --git a/src/main/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory b/src/main/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory deleted file mode 100644 index 889bdb3..0000000 --- a/src/main/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory +++ /dev/null @@ -1 +0,0 @@ -com.exasol.adapter.dialects.derby.DerbySqlDialectFactory \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesJsonConverterTest.java b/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesJsonConverterTest.java index 83e2628..3a79cb6 100644 --- a/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesJsonConverterTest.java +++ b/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesJsonConverterTest.java @@ -20,43 +20,42 @@ void setUp() { } private static final String SERIALIZED_STRING = "{\"catalogSeparator\":\".\"," // - + "\"identifierQuoteString\":\"\\\"\"," // - + "\"storesLowerCaseIdentifiers\":false," // - + "\"storesUpperCaseIdentifiers\":false," // - + "\"storesMixedCaseIdentifiers\":false," // - + "\"supportsMixedCaseIdentifiers\":false," // - + "\"storesLowerCaseQuotedIdentifiers\":false," // - + "\"storesUpperCaseQuotedIdentifiers\":false," // - + "\"storesMixedCaseQuotedIdentifiers\":false," // - + "\"supportsMixedCaseQuotedIdentifiers\":false," // - + "\"areNullsSortedAtEnd\":false," // - + "\"areNullsSortedAtStart\":false," // - + "\"areNullsSortedHigh\":false," // - + "\"areNullsSortedLow\":false}"; + + "\"identifierQuoteString\":\"\\\"\"," // + + "\"storesLowerCaseIdentifiers\":false," // + + "\"storesUpperCaseIdentifiers\":false," // + + "\"storesMixedCaseIdentifiers\":false," // + + "\"supportsMixedCaseIdentifiers\":false," // + + "\"storesLowerCaseQuotedIdentifiers\":false," // + + "\"storesUpperCaseQuotedIdentifiers\":false," // + + "\"storesMixedCaseQuotedIdentifiers\":false," // + + "\"supportsMixedCaseQuotedIdentifiers\":false," // + + "\"areNullsSortedAtEnd\":false," // + + "\"areNullsSortedAtStart\":false," // + + "\"areNullsSortedHigh\":false," // + + "\"areNullsSortedLow\":false}"; @Test void convertToJsonWithDefaultValues() throws JSONException { JSONAssert.assertEquals(SERIALIZED_STRING, - this.schemaAdapterNotesJsonConverter.convertToJson(SchemaAdapterNotes.builder().build()), false); + this.schemaAdapterNotesJsonConverter.convertToJson(SchemaAdapterNotes.builder().build()), false); } @Test void deserializeWithDefaultValues() throws AdapterException { - assertThat( - this.schemaAdapterNotesJsonConverter.convertFromJsonToSchemaAdapterNotes(SERIALIZED_STRING, "test_name"), - equalTo(SchemaAdapterNotes.builder().build())); + assertThat(this.schemaAdapterNotesJsonConverter.convertFromJsonToSchemaAdapterNotes(SERIALIZED_STRING, + "test_name"), equalTo(SchemaAdapterNotes.builder().build())); } @Test void deserializeThrowsExceptionWithEmptyAdapterNotes() { assertThrows(AdapterException.class, - () -> this.schemaAdapterNotesJsonConverter.convertFromJsonToSchemaAdapterNotes("", "")); + () -> this.schemaAdapterNotesJsonConverter.convertFromJsonToSchemaAdapterNotes("", "")); } @Test void deserializeThrowsExceptionWithWrongAdapterNotes() { assertThrows(AdapterException.class, - () -> this.schemaAdapterNotesJsonConverter.convertFromJsonToSchemaAdapterNotes("testNotes", "")); + () -> this.schemaAdapterNotesJsonConverter.convertFromJsonToSchemaAdapterNotes("testNotes", "")); } } \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesTest.java b/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesTest.java index aca98fc..8d897db 100644 --- a/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesTest.java +++ b/src/test/java/com/exasol/adapter/adapternotes/SchemaAdapterNotesTest.java @@ -34,40 +34,43 @@ void createSchemaAdapterNotes() { @Test void createSchemaAdapterNotesWithAllFields() { final SchemaAdapterNotes schemaAdapterNotes = SchemaAdapterNotes.builder() // - .catalogSeparator(CATALOG_SEPARATOR) // - .identifierQuoteString(IDENTIFIER_QUOTE_STRING) // - .storesLowerCaseIdentifiers(STORES_LOWER_CASE_IDENTIFIERS) // - .storesUpperCaseIdentifiers(STORES_UPPER_CASE_IDENTIFIERS) // - .storesMixedCaseIdentifiers(STORES_MIXED_CASE_IDENTIFIERS) // - .supportsMixedCaseIdentifiers(SUPPORTS_MIXED_CASE_IDENTIFIERS) // - .storesLowerCaseQuotedIdentifiers(STORES_LOWER_CASE_QUOTED_IDENTIFIERS) // - .storesUpperCaseQuotedIdentifiers(STORES_UPPER_CASE_QUOTED_IDENTIFIERS) // - .storesMixedCaseQuotedIdentifiers(STORES_MIXED_CASE_QUOTED_IDENTIFIERS) // - .supportsMixedCaseQuotedIdentifiers(SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS) // - .areNullsSortedAtEnd(NULLS_ARE_SORTED_AT_END) // - .areNullsSortedAtStart(NULLS_ARE_SORTED_AT_START) // - .areNullsSortedHigh(NULLS_ARE_SORTED_HIGH) // - .areNullsSortedLow(NULLS_ARE_SORTED_LOW) // - .build(); + .catalogSeparator(CATALOG_SEPARATOR) // + .identifierQuoteString(IDENTIFIER_QUOTE_STRING) // + .storesLowerCaseIdentifiers(STORES_LOWER_CASE_IDENTIFIERS) // + .storesUpperCaseIdentifiers(STORES_UPPER_CASE_IDENTIFIERS) // + .storesMixedCaseIdentifiers(STORES_MIXED_CASE_IDENTIFIERS) // + .supportsMixedCaseIdentifiers(SUPPORTS_MIXED_CASE_IDENTIFIERS) // + .storesLowerCaseQuotedIdentifiers(STORES_LOWER_CASE_QUOTED_IDENTIFIERS) // + .storesUpperCaseQuotedIdentifiers(STORES_UPPER_CASE_QUOTED_IDENTIFIERS) // + .storesMixedCaseQuotedIdentifiers(STORES_MIXED_CASE_QUOTED_IDENTIFIERS) // + .supportsMixedCaseQuotedIdentifiers(SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS) // + .areNullsSortedAtEnd(NULLS_ARE_SORTED_AT_END) // + .areNullsSortedAtStart(NULLS_ARE_SORTED_AT_START) // + .areNullsSortedHigh(NULLS_ARE_SORTED_HIGH) // + .areNullsSortedLow(NULLS_ARE_SORTED_LOW) // + .build(); assertAll(() -> assertThat(schemaAdapterNotes.getCatalogSeparator(), equalTo(CATALOG_SEPARATOR)), - () -> assertThat(schemaAdapterNotes.getIdentifierQuoteString(), equalTo(IDENTIFIER_QUOTE_STRING)), - () -> assertThat(schemaAdapterNotes.storesLowerCaseIdentifiers(), equalTo(STORES_LOWER_CASE_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.storesUpperCaseIdentifiers(), equalTo(STORES_UPPER_CASE_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.storesMixedCaseIdentifiers(), equalTo(STORES_MIXED_CASE_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.supportsMixedCaseIdentifiers(), - equalTo(SUPPORTS_MIXED_CASE_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.storesLowerCaseQuotedIdentifiers(), - equalTo(STORES_LOWER_CASE_QUOTED_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.storesUpperCaseQuotedIdentifiers(), - equalTo(STORES_UPPER_CASE_QUOTED_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.storesMixedCaseQuotedIdentifiers(), - equalTo(STORES_MIXED_CASE_QUOTED_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.supportsMixedCaseQuotedIdentifiers(), - equalTo(SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS)), - () -> assertThat(schemaAdapterNotes.areNullsSortedAtEnd(), equalTo(NULLS_ARE_SORTED_AT_END)), - () -> assertThat(schemaAdapterNotes.areNullsSortedAtStart(), equalTo(NULLS_ARE_SORTED_AT_START)), - () -> assertThat(schemaAdapterNotes.areNullsSortedHigh(), equalTo(NULLS_ARE_SORTED_HIGH)), - () -> assertThat(schemaAdapterNotes.areNullsSortedLow(), equalTo(NULLS_ARE_SORTED_LOW))); + () -> assertThat(schemaAdapterNotes.getIdentifierQuoteString(), equalTo(IDENTIFIER_QUOTE_STRING)), + () -> assertThat(schemaAdapterNotes.storesLowerCaseIdentifiers(), + equalTo(STORES_LOWER_CASE_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.storesUpperCaseIdentifiers(), + equalTo(STORES_UPPER_CASE_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.storesMixedCaseIdentifiers(), + equalTo(STORES_MIXED_CASE_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.supportsMixedCaseIdentifiers(), + equalTo(SUPPORTS_MIXED_CASE_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.storesLowerCaseQuotedIdentifiers(), + equalTo(STORES_LOWER_CASE_QUOTED_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.storesUpperCaseQuotedIdentifiers(), + equalTo(STORES_UPPER_CASE_QUOTED_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.storesMixedCaseQuotedIdentifiers(), + equalTo(STORES_MIXED_CASE_QUOTED_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.supportsMixedCaseQuotedIdentifiers(), + equalTo(SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS)), + () -> assertThat(schemaAdapterNotes.areNullsSortedAtEnd(), equalTo(NULLS_ARE_SORTED_AT_END)), + () -> assertThat(schemaAdapterNotes.areNullsSortedAtStart(), equalTo(NULLS_ARE_SORTED_AT_START)), + () -> assertThat(schemaAdapterNotes.areNullsSortedHigh(), equalTo(NULLS_ARE_SORTED_HIGH)), + () -> assertThat(schemaAdapterNotes.areNullsSortedLow(), equalTo(NULLS_ARE_SORTED_LOW))); } @Test @@ -78,27 +81,28 @@ void equalsContract() { @Test void testToString() { final SchemaAdapterNotes schemaAdapterNotes = SchemaAdapterNotes.builder() // - .catalogSeparator(CATALOG_SEPARATOR) // - .identifierQuoteString(IDENTIFIER_QUOTE_STRING) // - .storesLowerCaseIdentifiers(STORES_LOWER_CASE_IDENTIFIERS) // - .storesUpperCaseIdentifiers(STORES_UPPER_CASE_IDENTIFIERS) // - .storesMixedCaseIdentifiers(STORES_MIXED_CASE_IDENTIFIERS) // - .supportsMixedCaseIdentifiers(SUPPORTS_MIXED_CASE_IDENTIFIERS) // - .storesLowerCaseQuotedIdentifiers(STORES_LOWER_CASE_QUOTED_IDENTIFIERS) // - .storesUpperCaseQuotedIdentifiers(STORES_UPPER_CASE_QUOTED_IDENTIFIERS) // - .storesMixedCaseQuotedIdentifiers(STORES_MIXED_CASE_QUOTED_IDENTIFIERS) // - .supportsMixedCaseQuotedIdentifiers(SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS) // - .areNullsSortedAtEnd(NULLS_ARE_SORTED_AT_END) // - .areNullsSortedAtStart(NULLS_ARE_SORTED_AT_START) // - .areNullsSortedHigh(NULLS_ARE_SORTED_HIGH) // - .areNullsSortedLow(NULLS_ARE_SORTED_LOW) // - .build(); - assertThat(schemaAdapterNotes.toString(), equalTo("SchemaAdapterNotes{\ncatalogSeparator='.'," - + "\nidentifierQuoteString='\"',\nstoresLowerCaseIdentifiers=true," - + "\nstoresUpperCaseIdentifiers=true,\nstoresMixedCaseIdentifiers=false," - + "\nsupportsMixedCaseIdentifiers=true,\nstoresUpperCaseQuotedIdentifiers=false," - + "\nstoresLowerCaseQuotedIdentifiers=true,\nstoresMixedCaseQuotedIdentifiers=false," - + "\nsupportsMixedCaseQuotedIdentifiers=true,\nareNullsSortedAtEnd=true," - + "\nareNullsSortedAtStart=false,\nareNullsSortedHigh=true,\nareNullsSortedLow=false\n}")); + .catalogSeparator(CATALOG_SEPARATOR) // + .identifierQuoteString(IDENTIFIER_QUOTE_STRING) // + .storesLowerCaseIdentifiers(STORES_LOWER_CASE_IDENTIFIERS) // + .storesUpperCaseIdentifiers(STORES_UPPER_CASE_IDENTIFIERS) // + .storesMixedCaseIdentifiers(STORES_MIXED_CASE_IDENTIFIERS) // + .supportsMixedCaseIdentifiers(SUPPORTS_MIXED_CASE_IDENTIFIERS) // + .storesLowerCaseQuotedIdentifiers(STORES_LOWER_CASE_QUOTED_IDENTIFIERS) // + .storesUpperCaseQuotedIdentifiers(STORES_UPPER_CASE_QUOTED_IDENTIFIERS) // + .storesMixedCaseQuotedIdentifiers(STORES_MIXED_CASE_QUOTED_IDENTIFIERS) // + .supportsMixedCaseQuotedIdentifiers(SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS) // + .areNullsSortedAtEnd(NULLS_ARE_SORTED_AT_END) // + .areNullsSortedAtStart(NULLS_ARE_SORTED_AT_START) // + .areNullsSortedHigh(NULLS_ARE_SORTED_HIGH) // + .areNullsSortedLow(NULLS_ARE_SORTED_LOW) // + .build(); + assertThat(schemaAdapterNotes.toString(), + equalTo("SchemaAdapterNotes{\ncatalogSeparator='.'," + + "\nidentifierQuoteString='\"',\nstoresLowerCaseIdentifiers=true," + + "\nstoresUpperCaseIdentifiers=true,\nstoresMixedCaseIdentifiers=false," + + "\nsupportsMixedCaseIdentifiers=true,\nstoresUpperCaseQuotedIdentifiers=false," + + "\nstoresLowerCaseQuotedIdentifiers=true,\nstoresMixedCaseQuotedIdentifiers=false," + + "\nsupportsMixedCaseQuotedIdentifiers=true,\nareNullsSortedAtEnd=true," + + "\nareNullsSortedAtStart=false,\nareNullsSortedHigh=true,\nareNullsSortedLow=false\n}")); } } \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/dialects/AbstractQueryRewriterTest.java b/src/test/java/com/exasol/adapter/dialects/AbstractQueryRewriterTestBase.java similarity index 97% rename from src/test/java/com/exasol/adapter/dialects/AbstractQueryRewriterTest.java rename to src/test/java/com/exasol/adapter/dialects/AbstractQueryRewriterTestBase.java index 3f056c3..a31917c 100644 --- a/src/test/java/com/exasol/adapter/dialects/AbstractQueryRewriterTest.java +++ b/src/test/java/com/exasol/adapter/dialects/AbstractQueryRewriterTestBase.java @@ -11,7 +11,7 @@ import com.exasol.adapter.AdapterProperties; import com.exasol.adapter.sql.SqlStatement; -public abstract class AbstractQueryRewriterTest { +public abstract class AbstractQueryRewriterTestBase { protected static final String CONNECTION_NAME = "the_connection"; private static final String CONNECTION_USER = "connection_user"; private static final String CONNECTION_PW = "connection_secret"; diff --git a/src/test/java/com/exasol/adapter/dialects/BaseIdentifierConverterTest.java b/src/test/java/com/exasol/adapter/dialects/BaseIdentifierConverterTest.java index ea963a9..d347432 100644 --- a/src/test/java/com/exasol/adapter/dialects/BaseIdentifierConverterTest.java +++ b/src/test/java/com/exasol/adapter/dialects/BaseIdentifierConverterTest.java @@ -9,8 +9,8 @@ import org.junit.jupiter.params.provider.CsvSource; class BaseIdentifierConverterTest { - final IdentifierConverter identifierConverter = new BaseIdentifierConverter(IdentifierCaseHandling.INTERPRET_AS_UPPER, - IdentifierCaseHandling.INTERPRET_CASE_SENSITIVE); + final IdentifierConverter identifierConverter = new BaseIdentifierConverter( + IdentifierCaseHandling.INTERPRET_AS_UPPER, IdentifierCaseHandling.INTERPRET_CASE_SENSITIVE); @CsvSource({ "INTERPRET_AS_LOWER, INTERPRET_AS_LOWER, true", // "INTERPRET_AS_LOWER, INTERPRET_AS_UPPER, false", // diff --git a/src/test/java/com/exasol/adapter/dialects/BaseQueryRewriterTest.java b/src/test/java/com/exasol/adapter/dialects/BaseQueryRewriterTest.java index 0493056..80d50ac 100644 --- a/src/test/java/com/exasol/adapter/dialects/BaseQueryRewriterTest.java +++ b/src/test/java/com/exasol/adapter/dialects/BaseQueryRewriterTest.java @@ -18,7 +18,7 @@ import com.exasol.adapter.jdbc.BaseRemoteMetadataReader; import com.exasol.adapter.sql.TestSqlStatementFactory; -class BaseQueryRewriterTest extends AbstractQueryRewriterTest { +class BaseQueryRewriterTest extends AbstractQueryRewriterTestBase { @BeforeEach void beforeEach() { this.exaConnectionInformation = mock(ExaConnectionInformation.class); diff --git a/src/test/java/com/exasol/adapter/dialects/DialectTestData.java b/src/test/java/com/exasol/adapter/dialects/DialectTestData.java deleted file mode 100644 index 67821b0..0000000 --- a/src/test/java/com/exasol/adapter/dialects/DialectTestData.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.exasol.adapter.dialects; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -import com.exasol.adapter.adapternotes.ColumnAdapterNotes; -import com.exasol.adapter.metadata.*; -import com.exasol.adapter.sql.*; - -public class DialectTestData { - - public static SqlNode getTestSqlNode() { - // SELECT USER_ID, count(URL) FROM CLICKS - // WHERE 1 < USER_ID - // GROUP BY USER_ID - // HAVING 1 < COUNT(URL) - // ORDER BY USER_ID - // LIMIT 10; - final TableMetadata clicksMeta = getClicksTableMetadata(); - final SqlTable fromClause = new SqlTable("CLICKS", clicksMeta); - final SqlSelectList selectList = SqlSelectList.createRegularSelectList( - List.of(new SqlColumn(0, clicksMeta.getColumns().get(0)), new SqlFunctionAggregate( - AggregateFunction.COUNT, List.of(new SqlColumn(1, clicksMeta.getColumns().get(1))), false))); - final SqlNode whereClause = new SqlPredicateLess(new SqlLiteralExactnumeric(BigDecimal.ONE), - new SqlColumn(0, clicksMeta.getColumns().get(0))); - final SqlExpressionList groupBy = new SqlGroupBy(List.of(new SqlColumn(0, clicksMeta.getColumns().get(0)))); - final SqlNode countUrl = new SqlFunctionAggregate(AggregateFunction.COUNT, - List.of(new SqlColumn(1, clicksMeta.getColumns().get(1))), false); - final SqlNode having = new SqlPredicateLess(new SqlLiteralExactnumeric(BigDecimal.ONE), countUrl); - final SqlOrderBy orderBy = new SqlOrderBy(List.of(new SqlColumn(0, clicksMeta.getColumns().get(0))), - List.of(true), List.of(true)); - final SqlLimit limit = new SqlLimit(10); - return SqlStatementSelect.builder().selectList(selectList).fromClause(fromClause).whereClause(whereClause) - .groupBy(groupBy).having(having).orderBy(orderBy).limit(limit).build(); - } - - public static TableMetadata getClicksTableMetadata() { - final List columns = new ArrayList<>(); - columns.add(ColumnMetadata.builder().name("USER_ID") - .adapterNotes(ColumnAdapterNotes.serialize(new ColumnAdapterNotes(3, "DECIMAL"))) - .type(DataType.createDecimal(18, 0)).nullable(true).identity(false).defaultValue("").comment("") - .build()); - columns.add(ColumnMetadata.builder().name("URL") - .adapterNotes(ColumnAdapterNotes.serialize(new ColumnAdapterNotes(12, "VARCHAR"))) - .type(DataType.createVarChar(10000, DataType.ExaCharset.UTF8)).nullable(true).identity(false) - .defaultValue("").comment("").build()); - return new TableMetadata("CLICKS", "", columns, ""); - } -} \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/dialects/SqlDialectRegistryTest.java b/src/test/java/com/exasol/adapter/dialects/SqlDialectRegistryTest.java index 568bd51..c1b5e77 100644 --- a/src/test/java/com/exasol/adapter/dialects/SqlDialectRegistryTest.java +++ b/src/test/java/com/exasol/adapter/dialects/SqlDialectRegistryTest.java @@ -4,21 +4,16 @@ import static org.junit.Assert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.jupiter.api.AfterEach; +import java.util.Set; + import org.junit.jupiter.api.Test; +import com.exasol.adapter.dialects.derby.DerbySqlDialect; import com.exasol.adapter.dialects.derby.DerbySqlDialectFactory; -import com.exasol.adapter.dialects.dummy.DummySqlDialect; -import com.exasol.adapter.dialects.dummy.DummySqlDialectFactory; class SqlDialectRegistryTest { final SqlDialectRegistry registry = SqlDialectRegistry.getInstance(); - @AfterEach - void afterEach() { - this.registry.clear(); - } - @Test void testGetInstance() { final SqlDialectRegistry dialects = SqlDialectRegistry.getInstance(); @@ -32,14 +27,12 @@ void testGetInstanceTwiceYieldsSameInstance() { @Test void testLoadSqlDialectFactories() { - this.registry.loadSqlDialectFactories(); assertThat(this.registry.getRegisteredAdapterFactories(), hasItem(instanceOf(DerbySqlDialectFactory.class))); } @Test void testIsSupported() { - this.registry.registerSqlDialectFactory(new DummySqlDialectFactory()); - assertThat(this.registry.hasDialectWithName("DUMMYDIALECT"), is(true)); + assertThat(this.registry.hasDialectWithName("DERBY"), is(true)); } @Test @@ -49,19 +42,22 @@ void testIsNotSupported() { @Test void testGetSqlDialectForName() { - this.registry.registerSqlDialectFactory(new DummySqlDialectFactory()); - assertThat(SqlDialectRegistry.getInstance().getDialectForName("DUMMYDIALECT", null, null), - instanceOf(DummySqlDialect.class)); + assertThat(SqlDialectRegistry.getInstance().getDialectForName("DERBY", null, null), + instanceOf(DerbySqlDialect.class)); } @Test void testListRegisteredDialects() { - this.registry.registerSqlDialectFactory(new DerbySqlDialectFactory()); - this.registry.registerSqlDialectFactory(new DummySqlDialectFactory()); final String dialectNames = this.registry.listRegisteredSqlDialectNames(); assertThat(dialectNames, equalTo("\"DERBY\", \"DUMMYDIALECT\"")); } + @Test + void testGetRegisteredDialectNames() { + final Set dialectNames = this.registry.getRegisteredAdapterNames(); + assertThat(dialectNames, containsInAnyOrder("DERBY", "DUMMYDIALECT")); + } + @Test void testGetSqlDialectClassForNameThrowsException() { assertThrows(IllegalArgumentException.class, diff --git a/src/test/java/com/exasol/adapter/dialects/derby/DerbySqlDialect.java b/src/test/java/com/exasol/adapter/dialects/derby/DerbySqlDialect.java index 135dd05..4a49ed4 100644 --- a/src/test/java/com/exasol/adapter/dialects/derby/DerbySqlDialect.java +++ b/src/test/java/com/exasol/adapter/dialects/derby/DerbySqlDialect.java @@ -27,9 +27,9 @@ public class DerbySqlDialect extends AbstractSqlDialect { private static Capabilities createCapabilityList() { return Capabilities.builder().addMain(MainCapability.ORDER_BY_EXPRESSION) - .addScalarFunction(ScalarFunctionCapability.ADD) - .addAggregateFunction(AggregateFunctionCapability.COUNT_STAR).addLiteral(LiteralCapability.NULL) - .addPredicate(PredicateCapability.AND).build(); + .addScalarFunction(ScalarFunctionCapability.ADD) + .addAggregateFunction(AggregateFunctionCapability.COUNT_STAR).addLiteral(LiteralCapability.NULL) + .addPredicate(PredicateCapability.AND).build(); } /** diff --git a/src/test/java/com/exasol/adapter/jdbc/AbstractColumnMetadataReaderTest.java b/src/test/java/com/exasol/adapter/jdbc/AbstractColumnMetadataReaderTestBase.java similarity index 95% rename from src/test/java/com/exasol/adapter/jdbc/AbstractColumnMetadataReaderTest.java rename to src/test/java/com/exasol/adapter/jdbc/AbstractColumnMetadataReaderTestBase.java index b6f5c6c..5d959e5 100644 --- a/src/test/java/com/exasol/adapter/jdbc/AbstractColumnMetadataReaderTest.java +++ b/src/test/java/com/exasol/adapter/jdbc/AbstractColumnMetadataReaderTestBase.java @@ -7,7 +7,7 @@ import com.exasol.adapter.metadata.DataType; -public abstract class AbstractColumnMetadataReaderTest { +public abstract class AbstractColumnMetadataReaderTestBase { protected ColumnMetadataReader columnMetadataReader; protected DataType mapJdbcType(final int type) { diff --git a/src/test/java/com/exasol/adapter/jdbc/AbstractConnectionDefinitionBuilderTest.java b/src/test/java/com/exasol/adapter/jdbc/AbstractConnectionDefinitionBuilderTestBase.java similarity index 97% rename from src/test/java/com/exasol/adapter/jdbc/AbstractConnectionDefinitionBuilderTest.java rename to src/test/java/com/exasol/adapter/jdbc/AbstractConnectionDefinitionBuilderTestBase.java index 031f057..e27b323 100644 --- a/src/test/java/com/exasol/adapter/jdbc/AbstractConnectionDefinitionBuilderTest.java +++ b/src/test/java/com/exasol/adapter/jdbc/AbstractConnectionDefinitionBuilderTestBase.java @@ -9,7 +9,7 @@ import com.exasol.ExaConnectionInformation; import com.exasol.adapter.AdapterProperties; -public abstract class AbstractConnectionDefinitionBuilderTest { +public abstract class AbstractConnectionDefinitionBuilderTestBase { protected static final String USER = "property_user"; protected static final String PW = "property_secret"; protected static final String USER_IDENTIFIED_BY = "USER '" + USER + "' IDENTIFIED BY '" + PW + "'"; diff --git a/src/test/java/com/exasol/adapter/jdbc/BaseColumnMetadataReaderTest.java b/src/test/java/com/exasol/adapter/jdbc/BaseColumnMetadataReaderTest.java index f182b4b..e62f7bb 100644 --- a/src/test/java/com/exasol/adapter/jdbc/BaseColumnMetadataReaderTest.java +++ b/src/test/java/com/exasol/adapter/jdbc/BaseColumnMetadataReaderTest.java @@ -28,13 +28,13 @@ class BaseColumnMetadataReaderTest { @BeforeEach void beforeEach() { this.reader = new BaseColumnMetadataReader(null, AdapterProperties.emptyProperties(), - new BaseIdentifierConverter(IdentifierCaseHandling.INTERPRET_AS_UPPER, - IdentifierCaseHandling.INTERPRET_CASE_SENSITIVE)); + new BaseIdentifierConverter(IdentifierCaseHandling.INTERPRET_AS_UPPER, + IdentifierCaseHandling.INTERPRET_CASE_SENSITIVE)); } - @ValueSource(ints = {Types.OTHER, Types.BLOB, Types.NCLOB, Types.LONGVARBINARY, Types.VARBINARY, Types.JAVA_OBJECT, - Types.DISTINCT, Types.STRUCT, Types.ARRAY, Types.REF, Types.DATALINK, Types.SQLXML, Types.NULL, - Types.REF_CURSOR}) + @ValueSource(ints = { Types.OTHER, Types.BLOB, Types.NCLOB, Types.LONGVARBINARY, Types.VARBINARY, Types.JAVA_OBJECT, + Types.DISTINCT, Types.STRUCT, Types.ARRAY, Types.REF, Types.DATALINK, Types.SQLXML, Types.NULL, + Types.REF_CURSOR }) @ParameterizedTest void testMappingUnsupportedTypesReturnsUnsupportedType(final int jdbcType) { final JdbcTypeDescription jdbcTypeDescription = new JdbcTypeDescription(jdbcType, 0, 0, 0, null); @@ -45,31 +45,31 @@ void testMappingUnsupportedTypesReturnsUnsupportedType(final int jdbcType) { void testGetColumnsFromResultSetSkipsUnsupportedColumns() throws SQLException { final ResultSet remoteColumnsMock = mock(ResultSet.class); when(remoteColumnsMock.next()).thenReturn(true, true, true, false); - when(remoteColumnsMock.getString(BaseColumnMetadataReader.NAME_COLUMN)) - .thenReturn("DATE_COL", "BLOB_COL", "DOUBLE_COL"); - when(remoteColumnsMock.getInt(BaseColumnMetadataReader.DATA_TYPE_COLUMN)) - .thenReturn(Types.DATE, Types.BLOB, Types.DOUBLE); + when(remoteColumnsMock.getString(BaseColumnMetadataReader.NAME_COLUMN)).thenReturn("DATE_COL", "BLOB_COL", + "DOUBLE_COL"); + when(remoteColumnsMock.getInt(BaseColumnMetadataReader.DATA_TYPE_COLUMN)).thenReturn(Types.DATE, Types.BLOB, + Types.DOUBLE); final List columns = this.reader.getColumnsFromResultSet(remoteColumnsMock); final List columnTypes = columns // - .stream() // - .map(column -> column.getType().getExaDataType()) // - .collect(Collectors.toList()); + .stream() // + .map(column -> column.getType().getExaDataType()) // + .collect(Collectors.toList()); assertThat(columnTypes, containsInAnyOrder(ExaDataType.DATE, ExaDataType.DOUBLE)); } @Test void testMapJdbcTypeNumericToDecimalWithFallbackToDoubleReturnsDouble() { - final JdbcTypeDescription jdbcTypeDescription = - new JdbcTypeDescription(8, 10, DataType.MAX_EXASOL_DECIMAL_PRECISION + 1, 0, ""); + final JdbcTypeDescription jdbcTypeDescription = new JdbcTypeDescription(8, 10, + DataType.MAX_EXASOL_DECIMAL_PRECISION + 1, 0, ""); assertThat(this.reader.mapJdbcTypeNumericToDecimalWithFallbackToDouble(jdbcTypeDescription), - equalTo(DataType.createDouble())); + equalTo(DataType.createDouble())); } @Test void testMapJdbcTypeNumericToDecimalWithFallbackToDoubleReturnsDecimal() { - final JdbcTypeDescription jdbcTypeDescription = - new JdbcTypeDescription(8, 10, DataType.MAX_EXASOL_DECIMAL_PRECISION, 0, ""); + final JdbcTypeDescription jdbcTypeDescription = new JdbcTypeDescription(8, 10, + DataType.MAX_EXASOL_DECIMAL_PRECISION, 0, ""); assertThat(this.reader.mapJdbcTypeNumericToDecimalWithFallbackToDouble(jdbcTypeDescription), - equalTo(DataType.createDecimal(DataType.MAX_EXASOL_DECIMAL_PRECISION, 10))); + equalTo(DataType.createDecimal(DataType.MAX_EXASOL_DECIMAL_PRECISION, 10))); } } \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/jdbc/BaseConnectionDefinitionBuilderTest.java b/src/test/java/com/exasol/adapter/jdbc/BaseConnectionDefinitionBuilderTest.java index 3f4e191..aff6e44 100644 --- a/src/test/java/com/exasol/adapter/jdbc/BaseConnectionDefinitionBuilderTest.java +++ b/src/test/java/com/exasol/adapter/jdbc/BaseConnectionDefinitionBuilderTest.java @@ -12,7 +12,7 @@ import com.exasol.ExaConnectionInformation; -class BaseConnectionDefinitionBuilderTest extends AbstractConnectionDefinitionBuilderTest { +class BaseConnectionDefinitionBuilderTest extends AbstractConnectionDefinitionBuilderTestBase { @BeforeEach void beforeEach() { this.exaConnectionInformation = mock(ExaConnectionInformation.class); diff --git a/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterIT.java b/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterIT.java new file mode 100644 index 0000000..f213a1f --- /dev/null +++ b/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterIT.java @@ -0,0 +1,38 @@ +package com.exasol.adapter.jdbc; + +import static com.exasol.adapter.AdapterProperties.*; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.instanceOf; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import com.exasol.ExaMetadata; +import com.exasol.adapter.*; + +class JdbcAdapterIT { + @Test + public void testRegisteredDialects() throws AdapterException { + final String rawRequest = "{\n" // + + " \"type\" : \"getCapabilities\",\n" // + + " \"schemaMetadataInfo\" :\n" // + + " {\n" // + + " \"name\" : \"foo\",\n" // + + " \"properties\" :\n" // + + " {\n" // + + " \"" + SQL_DIALECT_PROPERTY + "\" : \"DERBY\"\n," // + + " \"" + CONNECTION_STRING_PROPERTY + "\" : \"jdbc:derby:memory:test;create=true;\"\n," // + + " \"" + USERNAME_PROPERTY + "\" : \"\"\n," // + + " \"" + PASSWORD_PROPERTY + "\" : \"\"\n" // + + " }\n" // + + " }\n" // + + "}"; + final ExaMetadata exaMetadata = Mockito.mock(ExaMetadata.class); + RequestDispatcher.adapterCall(exaMetadata, rawRequest); + final List registeredFactories = AdapterRegistry.getInstance().getRegisteredAdapterFactories(); + assertThat(registeredFactories, hasItem(instanceOf(JdbcAdapterFactory.class))); + } +} \ No newline at end of file diff --git a/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterTest.java b/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterTest.java index edeeba3..7f92be1 100644 --- a/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterTest.java +++ b/src/test/java/com/exasol/adapter/jdbc/JdbcAdapterTest.java @@ -16,8 +16,7 @@ import org.junit.jupiter.api.Test; import com.exasol.ExaMetadata; -import com.exasol.adapter.AdapterException; -import com.exasol.adapter.AdapterProperties; +import com.exasol.adapter.*; import com.exasol.adapter.capabilities.*; import com.exasol.adapter.metadata.*; import com.exasol.adapter.request.*; @@ -28,7 +27,7 @@ class JdbcAdapterTest { private static final String SCHEMA_NAME = "THE_SCHEMA"; private static final String TEST_DIALECT_NAME = "DERBY"; - private final JdbcAdapter adapter = new JdbcAdapter(); + private final VirtualSchemaAdapter adapter = new JdbcAdapterFactory().createAdapter(); private Map rawProperties; @BeforeEach @@ -115,7 +114,7 @@ void testGetCapabilitiesWithExcludedCapabilitiesList() throws AdapterException { } @Test - void testDropVirtualSchemaMustSucceedEvenIfDebugAddressIsInvalid() { + void testDropVirtualSchemaMustSucceedEvenIfDebugAddressIsInvalid() throws AdapterException { setTestSqlDialectProperty(); setDerbyConnectionProperties(); final ExaMetadata exaMetadataMock = mock(ExaMetadata.class); diff --git a/src/test/java/com/exasol/sql/SqlNormalizer.java b/src/test/java/com/exasol/sql/SqlNormalizer.java index 69166c2..955c893 100644 --- a/src/test/java/com/exasol/sql/SqlNormalizer.java +++ b/src/test/java/com/exasol/sql/SqlNormalizer.java @@ -1,8 +1,8 @@ package com.exasol.sql; public final class SqlNormalizer { - private SqlNormalizer(){ - //Intentionally left blank + private SqlNormalizer() { + // Intentionally left blank } /** @@ -12,9 +12,6 @@ private SqlNormalizer(){ * @return normalized SQL */ public static String normalizeSql(final String sql) { - return sql.replaceAll("\t", " ") - .replaceAll("\n", " ") - .replaceAll("\\s+", " "); + return sql.replaceAll("\t", " ").replaceAll("\n", " ").replaceAll("\\s+", " "); } } - diff --git a/src/test/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory b/src/test/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory new file mode 100644 index 0000000..0288d17 --- /dev/null +++ b/src/test/resources/META-INF/services/com.exasol.adapter.dialects.SqlDialectFactory @@ -0,0 +1,2 @@ +com.exasol.adapter.dialects.derby.DerbySqlDialectFactory +com.exasol.adapter.dialects.dummy.DummySqlDialectFactory \ No newline at end of file