diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f71734b0da..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,540 +0,0 @@ -# -# Copyright 2012-2020 The Feign Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# - -# common executors -executors: - java: - docker: - - image: velo/toolchains-4-ci-builds:with-25 - -# common commands -commands: - resolve-dependencies: - description: 'Download and prepare all dependencies' - steps: - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Check if cache was restored' - command: | - if [ -d ~/.m2/repository/io/github/openfeign/querydsl ]; then - echo "Cache hit detected, skipping resolve job." - circleci step halt - else - echo "No cache hit, proceeding with resolve." - fi - - run: - name: 'Resolving Dependencies' - command: | - ./mvnw -ntp -B dependency:resolve-plugins go-offline:resolve-dependencies -DskipTests=true - - save-test-results: - steps: - - run: - name: Save package results - command: | - mkdir -p ~/test-results/junit/ - find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \; - when: always - - store_test_results: - path: ~/test-results - - configure-gpg: - steps: - - run: - name: 'Configure GPG keys' - command: | - echo -e "$GPG_KEY" | base64 -d | gpg --batch --yes --import - -# our job defaults -defaults: &defaults - environment: - # Customize the JVM maximum heap limit - MAVEN_OPTS: -Xmx3200m - JAVA_HOME: /usr/lib/jvm/java-25-openjdk-amd64 - -# branch filters -master-only: &master-only - branches: - only: - - master - - /querydsl-.*/ - -tags-only: &tags-only - branches: - ignore: /.*/ - tags: - only: /.*/ - -all-branches: &all-branches - branches: - ignore: - - master - - /querydsl-.*/ - tags: - ignore: /.*/ - -version: 2.1 - -jobs: - resolve: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - steps: - - checkout - - resolve-dependencies - - save_cache: - paths: - - ~/.m2/repository - key: m2repo-{{ checksum "pom.xml" }} - test: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - no_output_timeout: 60m - command: | - ./mvnw -ntp -B verify -Pno-databases - - save-test-results - - windows: - machine: - image: windows-server-2019-vs2019:current # Windows machine image - resource_class: windows.medium - environment: - MAVEN_OPTS: -Xmx3200m - - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Install JDK 25' - command: | - $ProgressPreference = 'SilentlyContinue' - Invoke-WebRequest -Uri "https://api.adoptium.net/v3/binary/latest/25/ga/windows/x64/jdk/hotspot/normal/eclipse?project=jdk" -OutFile "$env:TEMP\jdk.zip" - Expand-Archive -Path "$env:TEMP\jdk.zip" -DestinationPath "C:\jdk25" - $jdkDir = Get-ChildItem "C:\jdk25" -Directory | Select-Object -First 1 - [Environment]::SetEnvironmentVariable("JAVA_HOME", $jdkDir.FullName, "Machine") - Write-Host "JAVA_HOME set to $($jdkDir.FullName)" - & "$($jdkDir.FullName)\bin\java" -version - shell: powershell.exe - - run: - name: 'Test' - command: | - export JAVA_HOME="$(ls -d /c/jdk25/jdk-* | head -1)" - export PATH="$JAVA_HOME/bin:$PATH" - java -version - ./mvnw -ntp -B verify -Pno-databases -Dtoolchain.skip=true - shell: bash.exe - - buildExamples: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Prepare environment' - command: | - ./mvnw -ntp -B install -Pquickbuild -pl :querydsl-sql-spring,:querydsl-jpa-spring,:querydsl-kotlin-codegen,:querydsl-mongodb,:querydsl-r2dbc,:querydsl-sql-json -am - - run: - name: 'Build and test examples' - command: | - ./mvnw -ntp -B install -Pexamples -rf :querydsl-examples - - save-test-results - buildQuarkusExample: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: cimg/base:2022.06 - steps: - - checkout - - setup_remote_docker: - docker_layer_caching: true - - run: - name: 'Test' - command: | - cp querydsl-examples/querydsl-example-jpa-quarkus/Dockerfile . - docker build --progress=plain . - buildKotlinKspExample: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - steps: - - checkout - - run: - name: 'Prepare environment' - command: | - ./mvnw -N org.codehaus.mojo:properties-maven-plugin:1.2.1:write-project-properties -Dproperties.outputFile=querydsl-examples/querydsl-example-ksp-codegen/gradle.properties - ./mvnw -ntp -B install -Pquickbuild -pl :querydsl-ksp-codegen,:querydsl-jpa -am - - run: - name: 'Build and test examples' - environment: - JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64 - command: | - cd querydsl-examples/querydsl-example-ksp-codegen - ./gradlew --no-daemon --console=plain --info --stacktrace test - - run: - name: 'Save test results' - command: | - mkdir -p ~/test-results/junit/ - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; - when: always - - store_test_results: - path: ~/test-results - testMySQL: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - - image: mysql:5.6.38 - environment: - - MYSQL_ROOT_PASSWORD=querydsl - - MYSQL_USER=querydsl - - MYSQL_PASSWORD=querydsl - - MYSQL_DATABASE=querydsl - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.MySQL - - save-test-results - testPostgreSQL: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - - image: postgis/postgis:16-3.4-alpine - environment: - - POSTGRES_USER=querydsl - - POSTGRES_PASSWORD=querydsl - - POSTGRES_DB=querydsl - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.PostgreSQL - - save-test-results - testCUBRID: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - - image: cubrid/cubrid:11.3 - environment: - - CUBRID_DB=demodb - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.CUBRID - - save-test-results - testOracle: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - - image: gvenzl/oracle-xe:slim-faststart - environment: - - ORACLE_PASSWORD=querydsl - - APP_USER=querydsl - - APP_USER_PASSWORD=querydsl - - TZ=UTC - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.Oracle - - save-test-results - testMongo: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - - image: mongo:8.0.9 - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.MongoDB - - save-test-results - testFirebird: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - - image: jacobalberty/firebird:v4 - environment: - - ISC_PASSWORD=masterkey - - FIREBIRD_DATABASE=querydsl.fdb - - FIREBIRD_USER=querydsl - - FIREBIRD_PASSWORD=querydsl - - TZ=UTC - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.Firebird - - save-test-results - testEmbedded: - <<: *defaults - working_directory: ~/querydsl - docker: - - image: velo/toolchains-4-ci-builds:with-25 - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: 'Test' - command: | - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.EmbeddedDatabase - - save-test-results - testDB2: - # Use the machine executor so we have full VM capabilities (e.g. docker running as admin) - machine: true - working_directory: ~/querydsl - environment: - DB2INST1_PASSWORD: a3sd!fDj - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - run: - name: "Start DB2 container" - command: | - docker run -d --privileged --name db2 \ - -p 50000:50000 \ - -e DB2INST1_PASSWORD=a3sd!fDj \ - -e DB2INSTANCE=db2inst1 \ - -e DBNAME=sample \ - -e LICENSE=accept \ - -e ARCHIVE_LOGS=false \ - -e AUTOCONFIG=false \ - ibmcom/db2:11.5.0.0 - - echo "Waiting for DB2 to initialize..." - for i in {1..60}; do - if docker logs db2 2>&1 | grep -q "All databases are now active"; then - echo "DB2 appears to be up" - break - fi - echo "Waiting ($i/60)..." - sleep 10 - done - docker ps - - run: - name: "Run DB2 tests" - command: | - docker run --rm \ - --network host \ - -v $(pwd):/code \ - -v ~/.m2/repository:/root/.m2/repository \ - -w /code \ - -e MAVEN_OPTS=-Xmx3200m \ - -e JAVA_HOME=/usr/lib/jvm/java-25-openjdk-amd64 \ - velo/toolchains-4-ci-builds:with-25 \ - ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.DB2 - - run: - name: "Stop and remove DB2 container" - command: | - docker stop db2 && docker rm db2 - when: always - - save-test-results - - deploySnapshot: - executor: - name: java - <<: *defaults - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - configure-gpg - - run: - name: 'Deploy Core Modules Sonatype' - no_output_timeout: 4h - command: | - ./mvnw -ntp -B -nsu -s .circleci/settings.xml -DskipTests=true deploy -Prelease - - deployRelease: - executor: - name: java - <<: *defaults - steps: - - checkout - - restore_cache: - keys: - - m2repo-{{ checksum "pom.xml" }} - - configure-gpg - - run: - name: 'Deploy Core Modules Sonatype' - no_output_timeout: 4h - command: | - ./mvnw -ntp -B -nsu -s .circleci/settings.xml -DskipTests=true deploy -Prelease,staging - -workflows: - version: 2 - build: - jobs: - - resolve: - name: 'Resolve dependencies' - filters: - <<: *all-branches - - test: - name: 'Compile and package (no external databases)' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - windows: - name: 'Compile and package on Windows (no external databases)' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - buildExamples: - name: 'Compile and package Examples' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - buildQuarkusExample: - name: 'Compile and test Quarkus Native Example' - filters: - <<: *all-branches - - buildKotlinKspExample: - name: 'Compile and test Kotlin KSP Example' - filters: - <<: *all-branches - - testMySQL: - name: 'Test MySQL' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testPostgreSQL: - name: 'Test PostgreSQL' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testCUBRID: - name: 'Test CUBRID' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testOracle: - name: 'Test Oracle' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testMongo: - name: 'Test MongoDB' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testFirebird: - name: 'Test Firebird' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testEmbedded: - name: 'Test Embedded databases' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - testDB2: - name: 'Test DB2' - requires: - - 'Resolve dependencies' - filters: - <<: *all-branches - - snapshot: - jobs: - - resolve: - name: 'Resolve dependencies' - filters: - <<: *master-only - - test: - name: 'snapshot' - requires: - - 'Resolve dependencies' - filters: - <<: *master-only - - deploySnapshot: - name: 'deploy snapshot' - requires: - - 'snapshot' - context: central - filters: - <<: *master-only - - release: - jobs: - - deployRelease: - name: 'release to maven central' - context: central - filters: - <<: *tags-only diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml new file mode 100644 index 0000000000..42acb3179f --- /dev/null +++ b/.github/actions/setup-build/action.yml @@ -0,0 +1,47 @@ +name: "Setup build environment" +description: "Install JDKs (17/21/25), generate Maven toolchains.xml, and restore the Maven dependency cache" + +runs: + using: "composite" + steps: + - name: Set up JDKs 17, 21 and 25 + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: | + 17 + 21 + 25 + + - name: Generate Maven toolchains.xml + shell: bash + run: | + mkdir -p ~/.m2 + cat > ~/.m2/toolchains.xml < + + + jdk + 17 + ${JAVA_HOME_17_X64} + + + jdk + 21 + ${JAVA_HOME_21_X64} + + + jdk + 25 + ${JAVA_HOME_25_X64} + + + EOF + + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: maven-deps-${{ hashFiles('**/pom.xml') }} + restore-keys: | + maven-deps- diff --git a/.circleci/settings.xml b/.github/settings.xml similarity index 54% rename from .circleci/settings.xml rename to .github/settings.xml index f0f6ad85a5..6025416797 100644 --- a/.circleci/settings.xml +++ b/.github/settings.xml @@ -1,18 +1,3 @@ - + ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl ${{ env.SQL_MODULES }} + -Dgroups=fluentq.core.testutil.H2,fluentq.core.testutil.HSQLDB,fluentq.core.testutil.Derby,fluentq.core.testutil.SQLite,fluentq.core.testutil.Turso + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (embedded)" + + mysql: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + mysql: + image: mysql:5.6.38 + env: + MYSQL_ROOT_PASSWORD: fluentq + MYSQL_USER: fluentq + MYSQL_PASSWORD: fluentq + MYSQL_DATABASE: fluentq + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping -h localhost -uroot -pfluentq" + --health-interval=10s --health-timeout=5s --health-retries=20 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Test MySQL + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl ${{ env.SQL_MODULES }} -Dgroups=fluentq.core.testutil.MySQL + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (MySQL)" + + postgresql: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + postgres: + image: postgis/postgis:16-3.4-alpine + env: + POSTGRES_USER: fluentq + POSTGRES_PASSWORD: fluentq + POSTGRES_DB: fluentq + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U fluentq" --health-interval=10s + --health-timeout=5s --health-retries=20 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Test PostgreSQL + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl ${{ env.SQL_MODULES }} -Dgroups=fluentq.core.testutil.PostgreSQL + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (PostgreSQL)" + + oracle: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 40 + services: + oracle: + image: gvenzl/oracle-xe:slim-faststart + env: + ORACLE_PASSWORD: fluentq + APP_USER: fluentq + APP_USER_PASSWORD: fluentq + TZ: UTC + ports: + - 1521:1521 + options: >- + --health-cmd="healthcheck.sh" --health-interval=10s + --health-timeout=5s --health-retries=30 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Test Oracle + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl ${{ env.ORACLE_MODULES }} -Dgroups=fluentq.core.testutil.Oracle + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (Oracle)" + + cubrid: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + cubrid: + image: cubrid/cubrid:11.3 + env: + CUBRID_DB: demodb + ports: + - 30000:30000 + - 33000:33000 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Wait for CUBRID demodb to be ready + run: | + for i in $(seq 1 30); do + if docker logs "${{ job.services.cubrid.id }}" 2>&1 | grep -q "cubrid server start: demodb"; then + echo "CUBRID demodb server has started"; sleep 5; break + fi + echo "Waiting for CUBRID demodb ($i/30)..."; sleep 5 + done + - name: Test CUBRID + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl :fluentq-sql -Dgroups=fluentq.core.testutil.CUBRID + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (CUBRID)" + + firebird: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + firebird: + image: jacobalberty/firebird:v4 + env: + ISC_PASSWORD: masterkey + FIREBIRD_DATABASE: fluentq.fdb + FIREBIRD_USER: fluentq + FIREBIRD_PASSWORD: fluentq + TZ: UTC + ports: + - 3050:3050 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Wait for Firebird + run: | + for i in $(seq 1 30); do + if (echo > /dev/tcp/localhost/3050) >/dev/null 2>&1; then + echo "Firebird is accepting connections"; break + fi + echo "Waiting for Firebird ($i/30)..."; sleep 5 + done + - name: Test Firebird + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl :fluentq-sql -Dgroups=fluentq.core.testutil.Firebird + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (Firebird)" + + mongodb: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + mongo: + image: mongo:8.0.9 + ports: + - 27017:27017 + options: >- + --health-cmd="mongosh --eval 'db.runCommand({ ping: 1 })'" + --health-interval=10s --health-timeout=5s --health-retries=20 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Test MongoDB + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl :fluentq-mongodb -Dgroups=fluentq.core.testutil.MongoDB + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (MongoDB)" + + db2: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Start DB2 container + run: | + docker run -d --privileged --name db2 \ + -p 50000:50000 \ + -e DB2INST1_PASSWORD=a3sd!fDj \ + -e DB2INSTANCE=db2inst1 \ + -e DBNAME=sample \ + -e LICENSE=accept \ + -e ARCHIVE_LOGS=false \ + -e AUTOCONFIG=false \ + ibmcom/db2:11.5.0.0 + echo "Waiting for DB2 to initialize..." + for i in $(seq 1 60); do + if docker logs db2 2>&1 | grep -q "All databases are now active"; then + echo "DB2 appears to be up"; break + fi + echo "Waiting ($i/60)..."; sleep 10 + done + - name: Test DB2 + run: ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pci -pl :fluentq-sql -Dgroups=fluentq.core.testutil.DB2 + - name: Stop DB2 container + if: always() + run: docker stop db2 && docker rm db2 + - name: Publish test report + uses: mikepenz/action-junit-report@v5 + if: always() + with: + report_paths: "**/target/surefire-reports/TEST-*.xml" + check_name: "Test report (DB2)" + + examples: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Prepare example prerequisites + run: > + ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pquickbuild + -pl :querydsl-sql-spring,:querydsl-jpa-spring,:querydsl-kotlin-codegen,:querydsl-mongodb,:querydsl-r2dbc,:querydsl-sql-json -am + - name: Build and test examples + run: ./mvnw -ntp -B install -Pexamples -rf :querydsl-examples + + examples-quarkus: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Stage fluentQ artifacts for the image build + run: | + mkdir -p /tmp/m2inject/io/github + cp -r ~/.m2/repository/io/github/openfeign /tmp/m2inject/io/github/ + - name: Build Quarkus native example image (reusing compiled artifacts) + run: | + DOCKER_BUILDKIT=1 docker build --progress=plain \ + -f querydsl-examples/querydsl-example-jpa-quarkus/Dockerfile \ + --build-context m2=/tmp/m2inject \ + --build-arg REUSE_M2=true . + + examples-ksp: + if: ${{ !github.event.pull_request.draft }} + needs: compile + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Setup build environment + uses: ./.github/actions/setup-build + - name: Restore build artifacts + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/io/github/openfeign + key: build-artifacts-${{ github.sha }} + - name: Prepare KSP example prerequisites + run: | + ./mvnw -N org.codehaus.mojo:properties-maven-plugin:1.2.1:write-project-properties -Dproperties.outputFile=querydsl-examples/querydsl-example-ksp-codegen/gradle.properties + ./mvnw -ntp -B install -Deasyjacoco.skip=true -Pquickbuild -pl :querydsl-ksp-codegen,:querydsl-jpa -am + - name: Build and test KSP example + run: | + export JAVA_HOME="$JAVA_HOME_21_X64" + cd querydsl-examples/querydsl-example-ksp-codegen + ./gradlew --no-daemon --console=plain --info --stacktrace test + + # Single required status check that aggregates every test job. + build: + if: always() && !github.event.pull_request.draft + runs-on: ubuntu-latest + needs: + - compile + - windows + - embedded + - mysql + - postgresql + - oracle + - cubrid + - firebird + - mongodb + - db2 + - examples + - examples-quarkus + - examples-ksp + steps: + - name: Check upstream job results + run: | + echo "Aggregating upstream job results..." + FAILED="" + ALL_SKIPPED=true + NEEDS_JSON='${{ toJSON(needs) }}' + for job in $(echo "$NEEDS_JSON" | jq -r 'keys[]'); do + result=$(echo "$NEEDS_JSON" | jq -r ".[\"$job\"].result") + echo " $job: $result" + if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then + FAILED="$FAILED $job" + fi + if [[ "$result" != "skipped" ]]; then + ALL_SKIPPED=false + fi + done + if [[ "$ALL_SKIPPED" == "true" ]]; then + echo "All upstream jobs were skipped - refusing to report success." + exit 1 + fi + if [[ -n "$FAILED" ]]; then + echo "Failed jobs:$FAILED" + exit 1 + fi + echo "All upstream jobs passed." diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 00c18553a5..ba8ded2ae4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -96,7 +96,7 @@ jobs: java-version: '25' - name: Compile project - run: ./mvnw -B -ntp clean package -DskipTests=true -Dtoolchain.skip=true -pl '!:querydsl-kotlin-codegen,!:querydsl-ksp-codegen,!:querydsl-kotlin' + run: ./mvnw -B -ntp clean package -DskipTests=true -Dtoolchain.skip=true -pl '!:fluentq-kotlin-codegen,!:fluentq-ksp-codegen,!:fluentq-kotlin,!:querydsl-kotlin-codegen,!:querydsl-ksp-codegen,!:querydsl-kotlin' - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dependency-submission.yml b/.github/workflows/dependency-submission.yml new file mode 100644 index 0000000000..4644ccb45a --- /dev/null +++ b/.github/workflows/dependency-submission.yml @@ -0,0 +1,46 @@ +# The workflow name and job id form the snapshot job correlator ("build" via +# the dependency-submission-toolkit). They must stay identical to the workflow +# removed in 69d8be19c so submissions supersede the stale December 2024 +# snapshot that keeps old transitive versions alive in the dependency graph +# (and keeps spawning Dependabot alerts for them). +name: Dependabot Dependency Submission + +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + - cron: '23 5 * * 1' + workflow_dispatch: + +permissions: + contents: write + +jobs: + dependency-submission: + # Dependabot and fork PRs run with a read-only GITHUB_TOKEN, so the + # snapshot submission would 403 and fail the check — the likely reason the + # original workflow was flaky. Skip those; pushes to master are what keep + # the dependency graph fresh. + if: github.event_name != 'pull_request' || (github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + # .mvn/jvm.config uses JDK 23+ flags (--sun-misc-unsafe-memory-access); + # keep in sync with the JDK the build actually targets + java-version: '25' + cache: maven + + - name: Submit Dependency Snapshot + uses: advanced-security/maven-dependency-submission-action@v5.0.0 + with: + maven-args: -Pexamples -Dtoolchain.skip=true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..4ccaaa3cdf --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,66 @@ +name: Deploy + +on: + push: + branches: ["master", "querydsl-*"] + tags: ["*"] + +concurrency: + group: deploy-${{ github.ref }} + cancel-in-progress: false + +env: + MAVEN_OPTS: -Xmx3200m + +jobs: + # Deploy SNAPSHOT artifacts to Maven Central on every push to master / querydsl-* branches. + snapshot: + if: startsWith(github.ref, 'refs/heads/') + runs-on: ubuntu-latest + timeout-minutes: 60 + environment: central + steps: + - uses: actions/checkout@v4 + + - name: Setup build environment + uses: ./.github/actions/setup-build + + - name: Import GPG key + run: echo -e "$GPG_KEY" | base64 -d | gpg --batch --yes --import + env: + GPG_KEY: ${{ secrets.GPG_KEY }} + + - name: Deploy snapshot to Maven Central + env: + CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }} + CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: > + ./mvnw -ntp -B -nsu -s .github/settings.xml -DskipTests=true + deploy -Prelease -pl '!:fluentq-apt-test,!:querydsl-apt-test' + + # Deploy a release to Maven Central (staging) when a tag is pushed. + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + timeout-minutes: 60 + environment: central + steps: + - uses: actions/checkout@v4 + + - name: Setup build environment + uses: ./.github/actions/setup-build + + - name: Import GPG key + run: echo -e "$GPG_KEY" | base64 -d | gpg --batch --yes --import + env: + GPG_KEY: ${{ secrets.GPG_KEY }} + + - name: Deploy release to Maven Central + env: + CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }} + CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: > + ./mvnw -ntp -B -nsu -s .github/settings.xml -DskipTests=true + deploy -Prelease,staging -pl '!:fluentq-apt-test,!:querydsl-apt-test' diff --git a/docker-compose.yml b/docker-compose.yml index 3dfeffaf2b..ddf759bd32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,7 +66,7 @@ services: - "27017:27017" db2: - image: ibmcom/db2:11.5.0.0 + image: ibmcom/db2:11.5.8.0 platform: linux/amd64 privileged: true ports: diff --git a/fluentq-libraries/fluentq-collections/src/main/java/fluentq/collections/DefaultEvaluatorFactory.java b/fluentq-libraries/fluentq-collections/src/main/java/fluentq/collections/DefaultEvaluatorFactory.java index 7440af5234..5da35e8d2c 100644 --- a/fluentq-libraries/fluentq-collections/src/main/java/fluentq/collections/DefaultEvaluatorFactory.java +++ b/fluentq-libraries/fluentq-collections/src/main/java/fluentq/collections/DefaultEvaluatorFactory.java @@ -37,7 +37,7 @@ import fluentq.core.util.PrimitiveUtils; import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.tools.JavaCompiler; @@ -112,8 +112,8 @@ public Evaluator create( } serializer.append(";"); - var constantToLabel = serializer.getConstantToLabel(); - var constants = getConstants(metadata, constantToLabel); + var constants = + getConstants(metadata, serializer.getConstants(), serializer.getConstantToLabel()); var types = new Class[sources.size()]; var names = new String[sources.size()]; for (var i = 0; i < sources.size(); i++) { @@ -155,8 +155,7 @@ public Evaluator> createEvaluator( ser.append("}\n"); ser.append("return rv;"); - var constantToLabel = ser.getConstantToLabel(); - var constants = getConstants(metadata, constantToLabel); + var constants = getConstants(metadata, ser.getConstants(), ser.getConstantToLabel()); Type sourceType = new ClassType(TypeCategory.SIMPLE, source.getType()); var sourceListType = new ClassType(TypeCategory.SIMPLE, Iterable.class, sourceType); @@ -269,8 +268,7 @@ public Evaluator> createEvaluator( } ser.append("return rv;"); - var constantToLabel = ser.getConstantToLabel(); - var constants = getConstants(metadata, constantToLabel); + var constants = getConstants(metadata, ser.getConstants(), ser.getConstantToLabel()); var projectionType = new ClassType(TypeCategory.LIST, List.class, Types.OBJECTS); return factory.createEvaluator( @@ -283,19 +281,25 @@ public Evaluator> createEvaluator( } private Map getConstants( - QueryMetadata metadata, Map constantToLabel) { - Map constants = new HashMap<>(); - for (Map.Entry entry : constantToLabel.entrySet()) { - if (entry.getKey() instanceof ParamExpression) { - var value = metadata.getParams().get(entry.getKey()); + QueryMetadata metadata, List constants, Map constantToLabel) { + var result = new LinkedHashMap(); + + for (var constant : constants) { + var paramName = constantToLabel.get(constant); + + if (constant instanceof ParamExpression) { + var value = metadata.getParams().get(constant); if (value == null) { - throw new ParamNotSetException((ParamExpression) entry.getKey()); + throw new ParamNotSetException((ParamExpression) constant); } - constants.put(entry.getValue(), value); - } else { - constants.put(entry.getValue(), entry.getKey()); + + result.put(paramName, value); + continue; } + + result.put(paramName, constant); } - return constants; + + return result; } } diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AbstractQueryTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AbstractQueryTest.java index c75afebd08..d9dc6e0b4b 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AbstractQueryTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AbstractQueryTest.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public abstract class AbstractQueryTest { @@ -50,7 +50,7 @@ public abstract class AbstractQueryTest { protected TestQuery last; - @Before + @BeforeEach public void setUp() { myInts.addAll(Arrays.asList(1, 2, 3, 4)); Alias.resetAlias(); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AggregationTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AggregationTest.java index 8ebb859334..745717c46c 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AggregationTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AggregationTest.java @@ -1,11 +1,12 @@ package fluentq.collections; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.within; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AggregationTest extends AbstractQueryTest { @@ -14,7 +15,7 @@ public class AggregationTest extends AbstractQueryTest { private CollQuery query; @Override - @Before + @BeforeEach public void setUp() { var cat1 = new Cat(); cat1.setWeight(2); @@ -53,9 +54,10 @@ public void min() { } @SuppressWarnings("unchecked") - @Test(expected = UnsupportedOperationException.class) + @Test public void min_and_max() { - query.select(cat.weight.min(), cat.weight.max()).fetchOne(); + assertThatThrownBy(() -> query.select(cat.weight.min(), cat.weight.max()).fetchOne()) + .isInstanceOf(UnsupportedOperationException.class); } @Test diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AliasTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AliasTest.java index 6ddaef06d4..0dff7b7a61 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AliasTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AliasTest.java @@ -26,13 +26,13 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AliasTest extends AbstractQueryTest { @Override - @Before + @BeforeEach public void setUp() { myInts.add(1); myInts.add(2); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AnimalTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AnimalTest.java index da748f5edc..02e6fd3ec8 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AnimalTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/AnimalTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.dsl.SimplePath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnimalTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BigDecimalTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BigDecimalTest.java index dd574b6e5b..0aae80e879 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BigDecimalTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BigDecimalTest.java @@ -6,7 +6,7 @@ import fluentq.core.types.dsl.NumberPath; import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BigDecimalTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BooleanTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BooleanTest.java index 8d0e2eb31b..ce77ccc557 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BooleanTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/BooleanTest.java @@ -5,7 +5,7 @@ import fluentq.core.alias.Alias; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BooleanTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CastTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CastTest.java index 955911b303..5a0a0ceac6 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CastTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CastTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CastTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CatTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CatTest.java index a244dbbc11..ff78323d03 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CatTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CatTest.java @@ -14,15 +14,17 @@ package fluentq.collections; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.types.dsl.SimplePath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CatTest { - @Test(expected = NoSuchFieldException.class) - public void skippedField() throws SecurityException, NoSuchFieldException { - QCat.class.getField("skippedField"); + @Test + public void skippedField() { + assertThatThrownBy(() -> QCat.class.getField("skippedField")) + .isInstanceOf(NoSuchFieldException.class); } @Test diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollDeleteClauseTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollDeleteClauseTest.java index 7302336b22..bfeeb582a7 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollDeleteClauseTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollDeleteClauseTest.java @@ -18,7 +18,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollDeleteClauseTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryFunctionsTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryFunctionsTest.java index dc9261f6fc..af8653825b 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryFunctionsTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryFunctionsTest.java @@ -15,8 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class CollQueryFunctionsTest { @@ -28,7 +28,7 @@ public void coalesce() { } @Test - @Ignore + @Disabled public void likeSpeed() { // 3015 final var iterations = 1000000; diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryStandardTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryStandardTest.java index ff22b21f17..cc747f1b6b 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryStandardTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryStandardTest.java @@ -14,6 +14,7 @@ package fluentq.collections; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.Fetchable; import fluentq.core.FluentQModule; @@ -31,7 +32,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollQueryStandardTest { @@ -183,12 +184,16 @@ public void params_anon() { .isEqualTo("Bob"); } - @Test(expected = ParamNotSetException.class) + @Test public void params_not_set() { var name = new Param<>(String.class, "name"); - assertThat( - CollQueryFactory.from(cat, data).where(cat.name.eq(name)).select(cat.name).fetchOne()) - .isEqualTo("Bob"); + assertThatThrownBy( + () -> + CollQueryFactory.from(cat, data) + .where(cat.name.eq(name)) + .select(cat.name) + .fetchOne()) + .isInstanceOf(ParamNotSetException.class); } @Test diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTemplatesTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTemplatesTest.java index 3f0f44ac95..89870401ed 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTemplatesTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTemplatesTest.java @@ -5,7 +5,7 @@ import fluentq.core.types.Expression; import fluentq.core.types.TemplatesTestUtils; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollQueryTemplatesTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTest.java index 26e4dcd83a..f6877c244b 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollQueryTest.java @@ -15,6 +15,7 @@ import static fluentq.collections.CollQueryFactory.from; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.Tuple; import fluentq.core.types.Expression; @@ -26,7 +27,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollQueryTest extends AbstractQueryTest { @@ -178,13 +179,15 @@ public void bigDecimals() { assertThat(nums).isEqualTo(Arrays.asList(new BigDecimal("2.1"), new BigDecimal("20.21"))); } - @Test(expected = UnsupportedOperationException.class) + @Test public void groupBy() { - query().from(cat, cats).groupBy(cat.name); + assertThatThrownBy(() -> query().from(cat, cats).groupBy(cat.name)) + .isInstanceOf(UnsupportedOperationException.class); } - @Test(expected = UnsupportedOperationException.class) + @Test public void having() { - query().from(cat, cats).having(cat.name.isNull()); + assertThatThrownBy(() -> query().from(cat, cats).having(cat.name.isNull())) + .isInstanceOf(UnsupportedOperationException.class); } } diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollUpdateClauseTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollUpdateClauseTest.java index 4c4320dfb1..d5503bb986 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollUpdateClauseTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollUpdateClauseTest.java @@ -17,7 +17,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollUpdateClauseTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionAnyTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionAnyTest.java index bde1ed40c5..01ba7a8bfc 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionAnyTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionAnyTest.java @@ -4,7 +4,7 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollectionAnyTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionTest.java index 3c0c35228c..63fa8fe077 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CollectionTest.java @@ -18,8 +18,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class CollectionTest { @@ -29,7 +29,7 @@ public class CollectionTest { private List cats; - @Before + @BeforeEach public void setUp() { var cat1 = new Cat("1"); cat1.setKittens(Collections.singletonList(cat1)); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CompilationOverheadTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CompilationOverheadTest.java index ec89f7c765..727d3ac17c 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CompilationOverheadTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/CompilationOverheadTest.java @@ -17,7 +17,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CompilationOverheadTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DefaultEvaluatorFactoryTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DefaultEvaluatorFactoryTest.java new file mode 100644 index 0000000000..04f563f240 --- /dev/null +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DefaultEvaluatorFactoryTest.java @@ -0,0 +1,72 @@ +package fluentq.collections; + +import static org.assertj.core.api.Assertions.assertThat; + +import fluentq.codegen.utils.Evaluator; +import fluentq.codegen.utils.EvaluatorFactory; +import fluentq.codegen.utils.model.ClassType; +import fluentq.codegen.utils.model.Type; +import fluentq.core.DefaultQueryMetadata; +import fluentq.core.types.dsl.BooleanExpression; +import java.util.ArrayList; +import java.util.Map; +import org.junit.jupiter.api.Test; + +public class DefaultEvaluatorFactoryTest extends AbstractQueryTest { + + /** + * The compiled evaluator is cached by a key that does not encode constant ordering, and its + * arguments are supplied positionally. The factory must therefore emit constants in a + * deterministic order matching the AST traversal so that a cached method is always invoked with + * its arguments in the same positions it was compiled with. + */ + @Test + public void constants_follow_ast_order() { + var capturing = new CapturingEvaluatorFactory(); + var factory = new DefaultEvaluatorFactory(CollQueryTemplates.DEFAULT, capturing); + + BooleanExpression filter = cat.name.eq("c1"); + for (var i = 2; i <= 12; i++) { + filter = filter.or(cat.name.eq("c" + i)); + } + + factory.createEvaluator(new DefaultQueryMetadata(), cat, filter); + + var expectedKeys = new ArrayList(); + for (var i = 1; i <= 12; i++) { + expectedKeys.add("a" + i); + } + assertThat(capturing.constants.keySet()).containsExactlyElementsOf(expectedKeys); + for (var i = 1; i <= 12; i++) { + assertThat(capturing.constants.get("a" + i)).isEqualTo("c" + i); + } + } + + private static final class CapturingEvaluatorFactory implements EvaluatorFactory { + + private Map constants; + + @Override + public Evaluator createEvaluator( + String source, + Class projectionType, + String[] names, + Class[] classes, + Map constants) { + this.constants = constants; + return null; + } + + @Override + public Evaluator createEvaluator( + String source, + ClassType projection, + String[] names, + Type[] types, + Class[] classes, + Map constants) { + this.constants = constants; + return null; + } + } +} diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DistinctTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DistinctTest.java index f9ef018ebb..89fb7a10a0 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DistinctTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DistinctTest.java @@ -19,7 +19,7 @@ import fluentq.core.types.dsl.NumberPath; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DistinctTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DocumentTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DocumentTest.java index 77b5efa3fe..38f3a501f3 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DocumentTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/DocumentTest.java @@ -3,8 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Predicate; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class DocumentTest { @@ -12,7 +12,7 @@ public class DocumentTest { private QDocument qDoc = QDocument.document; - @Before + @BeforeEach public void setUp() { doc1 = new Document(); doc1.setId(1L); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/ECJEvaluatorFactoryTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/ECJEvaluatorFactoryTest.java index a0fae33984..b585b0e313 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/ECJEvaluatorFactoryTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/ECJEvaluatorFactoryTest.java @@ -1,7 +1,7 @@ package fluentq.collections; import fluentq.codegen.utils.ECJEvaluatorFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ECJEvaluatorFactoryTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EntityWithLongIdTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EntityWithLongIdTest.java index 2d2f4ce1fd..0d3e0073fb 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EntityWithLongIdTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EntityWithLongIdTest.java @@ -4,7 +4,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EntityWithLongIdTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EvaluatorTransformerTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EvaluatorTransformerTest.java index 71ac5b095c..43b7f36eeb 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EvaluatorTransformerTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/EvaluatorTransformerTest.java @@ -19,7 +19,7 @@ import fluentq.core.DefaultQueryMetadata; import fluentq.core.QueryMetadata; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EvaluatorTransformerTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FirstResultContractTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FirstResultContractTest.java index a23520ed7e..8cb85c27ab 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FirstResultContractTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FirstResultContractTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FirstResultContractTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FunctionalHelpersTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FunctionalHelpersTest.java index 88a2cee968..7180f94b21 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FunctionalHelpersTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/FunctionalHelpersTest.java @@ -4,7 +4,7 @@ import java.util.function.Function; import java.util.function.Predicate; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FunctionalHelpersTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy2Test.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy2Test.java index f4ea4df836..4fc8dc37ac 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy2Test.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy2Test.java @@ -11,8 +11,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class GroupBy2Test { @@ -74,7 +74,7 @@ public UserDto(Long id, String name, Map roles, Map private List users; - @Before + @BeforeEach public void setUp() { var r1 = new Role(); r1.id = 1L; diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy3Test.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy3Test.java index 69eb5f462a..5763c2c5a2 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy3Test.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy3Test.java @@ -14,7 +14,7 @@ import fluentq.core.types.Projections; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GroupBy3Test { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy4Test.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy4Test.java index 03d1af40da..b9644ce559 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy4Test.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupBy4Test.java @@ -34,7 +34,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GroupBy4Test { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupByTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupByTest.java index 7781b0be2c..74eb0dc8c4 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupByTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/GroupByTest.java @@ -22,6 +22,7 @@ import static fluentq.core.group.GroupBy.set; import static fluentq.core.group.GroupBy.sum; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.group.Group; import fluentq.core.types.ConstructorExpression; @@ -32,8 +33,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class GroupByTest { @@ -155,7 +156,7 @@ public void first_set_and_list() { } @Test - @Ignore + @Disabled public void group_by_null() { Map results = CollQueryFactory.from(post, posts) @@ -179,20 +180,25 @@ public void group_by_null() { // group.getSet(qComment); // } - @Test(expected = ClassCastException.class) + @Test public void classCastException() { - Map results = - CollQueryFactory.from(post, posts) - .from(comment, comments) - .where(comment.post.id.eq(post.id)) - .transform(groupBy(post.id).as(post.name, set(comment.id), list(comment.text))); - - var group = results.get(1); - group.getList(comment.id); + assertThatThrownBy( + () -> { + Map results = + CollQueryFactory.from(post, posts) + .from(comment, comments) + .where(comment.post.id.eq(post.id)) + .transform( + groupBy(post.id).as(post.name, set(comment.id), list(comment.text))); + + var group = results.get(1); + group.getList(comment.id); + }) + .isInstanceOf(ClassCastException.class); } @Test - @Ignore + @Disabled public void map_() { Map results = CollQueryFactory.from(post, posts) diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerClassTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerClassTest.java index 6ae4f9de8a..b298391f80 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerClassTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerClassTest.java @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InnerClassTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerJoinTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerJoinTest.java index b00526558b..51319ab2f0 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerJoinTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/InnerJoinTest.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class InnerJoinTest extends AbstractQueryTest { @@ -30,7 +30,7 @@ public class InnerJoinTest extends AbstractQueryTest { private List cats; @Override - @Before + @BeforeEach public void setUp() { super.setUp(); cat = new QCat("c"); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/IterationTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/IterationTest.java index a30547b263..b8a56cad6f 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/IterationTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/IterationTest.java @@ -19,7 +19,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class IterationTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JSR310TimeTemplatesTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JSR310TimeTemplatesTest.java index c01deaec3d..06191cd389 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JSR310TimeTemplatesTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JSR310TimeTemplatesTest.java @@ -9,7 +9,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310TimeTemplatesTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JacocoTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JacocoTest.java index 9cf14b44cd..4623c545b1 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JacocoTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/JacocoTest.java @@ -6,7 +6,7 @@ import fluentq.core.types.dsl.EntityPathBase; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JacocoTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LeftJoinTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LeftJoinTest.java index fab487c1b3..0d7192b0dc 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LeftJoinTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LeftJoinTest.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class LeftJoinTest extends AbstractQueryTest { @@ -30,7 +30,7 @@ public class LeftJoinTest extends AbstractQueryTest { private List cats; @Override - @Before + @BeforeEach public void setUp() { super.setUp(); cat = new QCat("c"); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LoadTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LoadTest.java index bc0e7b7260..fbfb55440f 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LoadTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/LoadTest.java @@ -17,15 +17,14 @@ import fluentq.core.DefaultQueryMetadata; import fluentq.core.QueryMetadata; -import fluentq.core.testutil.Performance; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(Performance.class) +@Tag("fluentq.core.testutil.Performance") public class LoadTest { private QCat cat = QCat.cat; diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MappingProjectionTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MappingProjectionTest.java index 34365ebd44..06e909cfc1 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MappingProjectionTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MappingProjectionTest.java @@ -4,7 +4,7 @@ import fluentq.core.Tuple; import fluentq.core.types.MappingProjection; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("serial") public class MappingProjectionTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MathTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MathTest.java index 0a167dbbd0..4cc5204d22 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MathTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MathTest.java @@ -8,7 +8,7 @@ import fluentq.core.types.dsl.MathExpressions; import fluentq.core.types.dsl.NumberPath; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MathTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MockTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MockTest.java index e623d2266c..bd58a261b7 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MockTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MockTest.java @@ -7,7 +7,7 @@ import java.util.Arrays; import java.util.List; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MockTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MultiComparatorTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MultiComparatorTest.java index 374235b518..0b0753bb9c 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MultiComparatorTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/MultiComparatorTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.codegen.utils.Evaluator; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MultiComparatorTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NullSafetyTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NullSafetyTest.java index 6d0b3fb082..0d7f0222e2 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NullSafetyTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NullSafetyTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NullSafetyTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NumberTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NumberTest.java index 8ea207b86b..fe37433817 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NumberTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/NumberTest.java @@ -6,7 +6,7 @@ import fluentq.core.types.dsl.NumberPath; import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NumberTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/OrderTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/OrderTest.java index 2f756e5413..12810622bd 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/OrderTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/OrderTest.java @@ -17,7 +17,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OrderTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PagingTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PagingTest.java index 20e6ace21d..331e783f65 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PagingTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PagingTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.dsl.NumberPath; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PagingTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PathComparatorTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PathComparatorTest.java index 255aeb14db..ae3fbe536b 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PathComparatorTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PathComparatorTest.java @@ -4,14 +4,14 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Comparator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class PathComparatorTest { private Comparator comparator; - @Before + @BeforeEach public void setUpComparator() { comparator = pathComparator(QCar.car.horsePower); } diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PatternsTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PatternsTest.java index 7f646592e4..dca7f1b295 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PatternsTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PatternsTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.regex.Pattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PatternsTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PropertiesTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PropertiesTest.java index 087555992f..8009b7e2e0 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PropertiesTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/PropertiesTest.java @@ -4,7 +4,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PropertiesTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMetadataTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMetadataTest.java index 60f387b622..502596684c 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMetadataTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMetadataTest.java @@ -19,7 +19,7 @@ import fluentq.core.JoinType; import fluentq.core.QueryMetadata; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryMetadataTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMutabilityTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMutabilityTest.java index a1f348736b..303d4f6b98 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMutabilityTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryMutabilityTest.java @@ -17,7 +17,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryMutabilityTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryPerformanceTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryPerformanceTest.java index 5047204657..90b5a2158a 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryPerformanceTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/QueryPerformanceTest.java @@ -1,15 +1,14 @@ package fluentq.collections; -import fluentq.core.testutil.Performance; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; @@ -18,15 +17,15 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; -@Ignore -@Category(Performance.class) +@Disabled +@Tag("fluentq.core.testutil.Performance") public class QueryPerformanceTest { private static final int size = 1000; private static List cats = new ArrayList<>(size); - @BeforeClass + @BeforeAll public static void setUpClass() throws SQLException, ClassNotFoundException { for (var i = 0; i < size; i++) { cats.add(new Cat(String.valueOf(i), i)); diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/SerializationTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/SerializationTest.java index 30d7c1de5c..6541633493 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/SerializationTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/SerializationTest.java @@ -18,8 +18,8 @@ import fluentq.core.types.QTuple; import java.util.ArrayList; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class SerializationTest extends AbstractQueryTest { @@ -105,7 +105,7 @@ public String oneSource_filtered_projectedUnique(List cats) { } @Test - @Ignore + @Disabled public void join_list() { query() .from(cat, cats) diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/StringHandlingTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/StringHandlingTest.java index 4f497af087..2bf68c7043 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/StringHandlingTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/StringHandlingTest.java @@ -20,7 +20,7 @@ import fluentq.core.types.dsl.StringPath; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StringHandlingTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/TypeCastTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/TypeCastTest.java index 84246c9494..3b7c9efe3e 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/TypeCastTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/TypeCastTest.java @@ -13,19 +13,25 @@ */ package fluentq.collections; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import fluentq.core.types.dsl.PathInits; import java.util.Collections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class TypeCastTest { - @Test(expected = IllegalStateException.class) - @Ignore + @Test + @Disabled public void cast() { - var animal = QAnimal.animal; - var cat = new QCat(animal.getMetadata(), new PathInits("*")); - CollQueryFactory.from(animal, Collections.emptyList()) - .from(cat, Collections.emptyList()); + assertThatThrownBy( + () -> { + var animal = QAnimal.animal; + var cat = new QCat(animal.getMetadata(), new PathInits("*")); + CollQueryFactory.from(animal, Collections.emptyList()) + .from(cat, Collections.emptyList()); + }) + .isInstanceOf(IllegalStateException.class); } } diff --git a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/UniqueResultContractTest.java b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/UniqueResultContractTest.java index 4a8d7632a5..28458ac190 100644 --- a/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/UniqueResultContractTest.java +++ b/fluentq-libraries/fluentq-collections/src/test/java/fluentq/collections/UniqueResultContractTest.java @@ -13,15 +13,19 @@ */ package fluentq.collections; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import fluentq.core.NonUniqueResultException; import fluentq.core.types.Expression; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UniqueResultContractTest extends AbstractQueryTest { - @Test(expected = NonUniqueResultException.class) + @Test public void unique_result_throws_exception_on_multiple_results() { - CollQueryFactory.from(cat, cats).where(cat.name.isNotNull()).fetchOne(); + assertThatThrownBy( + () -> CollQueryFactory.from(cat, cats).where(cat.name.isNotNull()).fetchOne()) + .isInstanceOf(NonUniqueResultException.class); } @Test diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/FilterFactory.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/FilterFactory.java index 5880a76a27..53518cada2 100644 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/FilterFactory.java +++ b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/FilterFactory.java @@ -329,6 +329,7 @@ public Collection string( && !target.equals(Target.HSQLDB) && !target.equals(Target.H2) && !target.equals(Target.SQLITE) + && !target.equals(Target.TURSO) && !target.equals(Target.SQLSERVER)) { rv.add(expr.matches(knownValue.substring(0, 1) + ".*")); rv.add(expr.matches(".*" + knownValue.substring(1))); diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/MatchingFiltersFactory.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/MatchingFiltersFactory.java index 316071af4d..c97f7bc82d 100644 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/MatchingFiltersFactory.java +++ b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/MatchingFiltersFactory.java @@ -103,6 +103,7 @@ public Collection date( && !target.equals(Target.MYSQL) && !target.equals(Target.CUBRID) && !target.equals(Target.POSTGRESQL) + && !target.equals(Target.H2) && !target.equals(Target.HSQLDB)) { rv.add(expr.week().eq(other.week())); } @@ -142,6 +143,7 @@ public Collection dateTime( && !target.equals(Target.MYSQL) && !target.equals(Target.CUBRID) && !target.equals(Target.POSTGRESQL) + && !target.equals(Target.H2) && !target.equals(Target.HSQLDB)) { rv.add(expr.week().eq(other.week())); } @@ -270,6 +272,7 @@ public Collection string(StringExpression expr, StringExpression othe && !target.equals(Target.DB2) && !target.equals(Target.DERBY) && !target.equals(Target.SQLITE) + && !target.equals(Target.TURSO) && !target.equals(Target.SQLSERVER))) { rv.add(expr.matches(other)); diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/Target.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/Target.java index cc582150e5..feba313d20 100644 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/Target.java +++ b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/Target.java @@ -41,6 +41,8 @@ public enum Target { SQLSERVER, /** SQLite */ SQLITE, + /** Turso (SQLite-compatible) */ + TURSO, /** */ TERADATA, /** */ diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/TemplatesTestBase.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/TemplatesTestBase.java index b44a8d58c6..6e8d3a3594 100644 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/TemplatesTestBase.java +++ b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/TemplatesTestBase.java @@ -15,22 +15,17 @@ */ package fluentq.core; -import static org.assertj.core.api.Assertions.assertThat; - import fluentq.core.types.Templates; import io.github.classgraph.ClassGraph; import java.util.Set; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.junit.Rule; +import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; -import org.junit.rules.ErrorCollector; public class TemplatesTestBase { - @Rule public final ErrorCollector errorCollector = new ErrorCollector(); - private final ClassGraph classGraph = new ClassGraph() .enableClassInfo() @@ -44,14 +39,16 @@ void default_instance() { Set> moduleSpecific = templates.stream().filter(MODULE_SPECIFIC).collect(Collectors.toSet()); + var softly = new SoftAssertions(); for (Class template : moduleSpecific) { try { var defaultInstance = (Templates) template.getField("DEFAULT").get(null); - errorCollector.checkSucceeds(() -> assertThat(defaultInstance).isInstanceOf(template)); + softly.assertThat(defaultInstance).isInstanceOf(template); } catch (Exception ex) { - errorCollector.addError(ex); + softly.fail("Failed to read DEFAULT of " + template.getName(), ex); } } + softly.assertAll(); } private final Predicate> objectPredicate = diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/Parallelized.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/Parallelized.java deleted file mode 100644 index 4f95517db0..0000000000 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/Parallelized.java +++ /dev/null @@ -1,39 +0,0 @@ -package fluentq.core.testutil; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.runners.Parameterized; -import org.junit.runners.model.RunnerScheduler; - -public class Parallelized extends Parameterized { - - public Parallelized(Class klass) throws Throwable { - super(klass); - setScheduler(new ThreadPoolScheduler()); - } - - private static class ThreadPoolScheduler implements RunnerScheduler { - private ExecutorService executor; - - ThreadPoolScheduler() { - var numThreads = Runtime.getRuntime().availableProcessors(); - executor = Executors.newFixedThreadPool(numThreads); - } - - @Override - public void finished() { - executor.shutdown(); - try { - executor.awaitTermination(10, TimeUnit.MINUTES); - } catch (InterruptedException exc) { - throw new RuntimeException(exc); - } - } - - @Override - public void schedule(Runnable childStatement) { - executor.submit(childStatement); - } - } -} diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/TravisFoldListener.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/TravisFoldListener.java deleted file mode 100644 index af70254632..0000000000 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/TravisFoldListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team). - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package fluentq.core.testutil; - -import org.junit.runner.Description; -import org.junit.runner.Result; -import org.junit.runner.notification.RunListener; - -/** - * @author Shredder121 - */ -public class TravisFoldListener extends RunListener { - - private static final long ID = System.currentTimeMillis(); - - @Override - public void testRunStarted(Description description) throws Exception { - IO.println("travis_fold:start:tests" + ID); - IO.println("Running tests"); - } - - @Override - public void testRunFinished(Result result) throws Exception { - IO.println("travis_fold:end:tests" + ID); - } -} diff --git a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/EmptyStatement.java b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/Turso.java similarity index 72% rename from fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/EmptyStatement.java rename to fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/Turso.java index e309b81dcf..585e41b1f3 100644 --- a/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/EmptyStatement.java +++ b/fluentq-libraries/fluentq-core/src/test/java/fluentq/core/testutil/Turso.java @@ -11,16 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package fluentq.core.testutil; - -import org.junit.runners.model.Statement; - -public final class EmptyStatement extends Statement { - public static final Statement DEFAULT = new EmptyStatement(); - - private EmptyStatement() {} +package fluentq.core.testutil; - @Override - public void evaluate() throws Throwable {} -} +public interface Turso extends EmbeddedDatabase {} diff --git a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/JpaInsertNativeHelper.java b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/JpaInsertNativeHelper.java index 748b8f39f3..4e845b32e1 100644 --- a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/JpaInsertNativeHelper.java +++ b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/JpaInsertNativeHelper.java @@ -30,8 +30,7 @@ /** * Helpers shared by {@link fluentq.jpa.impl.JPAInsertClause} and {@link - * fluentq.jpa.hibernate.HibernateInsertClause} to support {@code executeWithKey()} via native SQL - * INSERT. + * fluentq.jpa.hibernate.HibernateInsertClause} to execute INSERT statements via native SQL. * *

This is an internal API and not intended for direct use by application code. */ @@ -97,6 +96,25 @@ public static Object[] resolveConstants( return result; } + /** + * Execute a native SQL INSERT and return the number of affected rows. + * + * @param conn the JDBC connection (not closed by this method) + * @param sql the native SQL INSERT string + * @param params the parameter values to bind, in positional order + * @return the number of affected rows + * @throws SQLException if a database error occurs + */ + public static long executeUpdate(java.sql.Connection conn, String sql, Object[] params) + throws SQLException { + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + for (int i = 0; i < params.length; i++) { + stmt.setObject(i + 1, params[i]); + } + return stmt.executeUpdate(); + } + } + /** * Execute a native SQL INSERT with {@code RETURN_GENERATED_KEYS} and return the generated key. * diff --git a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/hibernate/HibernateInsertClause.java b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/hibernate/HibernateInsertClause.java index 55c5784b96..3f2de10637 100644 --- a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/hibernate/HibernateInsertClause.java +++ b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/hibernate/HibernateInsertClause.java @@ -21,6 +21,7 @@ import fluentq.core.types.Expression; import fluentq.core.types.Path; import fluentq.core.types.SubQueryExpression; +import fluentq.core.types.TemplateExpression; import fluentq.core.types.dsl.Expressions; import fluentq.jpa.HQLTemplates; import fluentq.jpa.JPAQueryMixin; @@ -89,21 +90,68 @@ public HibernateInsertClause( @Override public long execute() { - var serializer = new JPQLSerializer(templates, null); - serializer.serializeForInsert( - queryMixin.getMetadata(), - inserts.isEmpty() ? columns : inserts.keySet(), - values, - subQuery, - inserts); + if (subQuery != null || !hasTemplateValue()) { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForInsert( + queryMixin.getMetadata(), + inserts.isEmpty() ? columns : inserts.keySet(), + values, + subQuery, + inserts); + + Query query = session.createQuery(serializer.toString()); + for (Map.Entry, LockMode> entry : lockModes.entrySet()) { + query.setLockMode(entry.getKey().toString(), entry.getValue()); + } + HibernateUtil.setConstants( + query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + var effectiveColumns = JpaInsertNativeHelper.effectiveColumns(inserts, columns); + if (effectiveColumns.isEmpty()) { + throw new IllegalStateException("No columns specified for insert"); + } + var effectiveValues = JpaInsertNativeHelper.effectiveValues(inserts, values); - Query query = session.createQuery(serializer.toString()); - for (Map.Entry, LockMode> entry : lockModes.entrySet()) { - query.setLockMode(entry.getKey().toString(), entry.getValue()); + var entityClass = queryMixin.getMetadata().getJoins().get(0).getTarget().getType(); + + var serializer = new JpaNativeInsertSerializer(new Configuration(SQLTemplates.DEFAULT)); + serializer.serializeInsert(entityClass, effectiveColumns, effectiveValues); + + var sql = serializer.toString(); + var params = + JpaInsertNativeHelper.resolveConstants( + serializer.getConstants(), queryMixin.getMetadata().getParams()); + + return session.doReturningWork( + connection -> { + try { + return JpaInsertNativeHelper.executeUpdate(connection, sql, params); + } catch (SQLException e) { + throw new QueryException("Failed to execute insert", e); + } + }); + } + + /** + * Whether any value expression is a {@link TemplateExpression} — typically a schema-qualified + * function call from {@code SQLExpressions.function/stringFunction/numberFunction} that + * Hibernate's HQL parser cannot type-check. When true, we route through the native SQL path to + * bypass HQL semantic validation. + */ + private boolean hasTemplateValue() { + for (Object v : values) { + if (v instanceof TemplateExpression) { + return true; + } + } + for (Expression v : inserts.values()) { + if (v instanceof TemplateExpression) { + return true; + } } - HibernateUtil.setConstants( - query, serializer.getConstants(), queryMixin.getMetadata().getParams()); - return query.executeUpdate(); + return false; } /** diff --git a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/impl/JPAInsertClause.java b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/impl/JPAInsertClause.java index ce3407b96f..6725c73a3d 100644 --- a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/impl/JPAInsertClause.java +++ b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/impl/JPAInsertClause.java @@ -21,6 +21,7 @@ import fluentq.core.types.Expression; import fluentq.core.types.Path; import fluentq.core.types.SubQueryExpression; +import fluentq.core.types.TemplateExpression; import fluentq.core.types.dsl.Expressions; import fluentq.jpa.JPAQueryMixin; import fluentq.jpa.JPQLSerializer; @@ -75,20 +76,66 @@ public JPAInsertClause(EntityManager em, EntityPath entity, JPQLTemplates tem @Override public long execute() { - var serializer = new JPQLSerializer(templates, entityManager); - serializer.serializeForInsert( - queryMixin.getMetadata(), - inserts.isEmpty() ? columns : inserts.keySet(), - values, - subQuery, - inserts); + if (subQuery != null || !hasTemplateValue()) { + var serializer = new JPQLSerializer(templates, entityManager); + serializer.serializeForInsert( + queryMixin.getMetadata(), + inserts.isEmpty() ? columns : inserts.keySet(), + values, + subQuery, + inserts); + + var query = entityManager.createQuery(serializer.toString()); + if (lockMode != null) { + query.setLockMode(lockMode); + } + JPAUtil.setConstants(query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + var effectiveColumns = JpaInsertNativeHelper.effectiveColumns(inserts, columns); + if (effectiveColumns.isEmpty()) { + throw new IllegalStateException("No columns specified for insert"); + } + var effectiveValues = JpaInsertNativeHelper.effectiveValues(inserts, values); + + var entityClass = queryMixin.getMetadata().getJoins().get(0).getTarget().getType(); + + var serializer = new JpaNativeInsertSerializer(new Configuration(SQLTemplates.DEFAULT)); + serializer.serializeInsert(entityClass, effectiveColumns, effectiveValues); - var query = entityManager.createQuery(serializer.toString()); - if (lockMode != null) { - query.setLockMode(lockMode); + var sql = serializer.toString(); + var params = + JpaInsertNativeHelper.resolveConstants( + serializer.getConstants(), queryMixin.getMetadata().getParams()); + + // Provider-neutral native execute: use the JPA standard EntityManager.createNativeQuery + // instead of unwrapping a Hibernate Session, so this path also works under EclipseLink/OpenJPA. + var nativeQuery = entityManager.createNativeQuery(sql); + for (int i = 0; i < params.length; i++) { + nativeQuery.setParameter(i + 1, params[i]); + } + return nativeQuery.executeUpdate(); + } + + /** + * Whether any value expression is a {@link TemplateExpression} — typically a schema-qualified + * function call from {@code SQLExpressions.function/stringFunction/numberFunction} that + * Hibernate's HQL parser cannot type-check. When true, we route through the native SQL path to + * bypass HQL semantic validation. + */ + private boolean hasTemplateValue() { + for (Object v : values) { + if (v instanceof TemplateExpression) { + return true; + } + } + for (Expression v : inserts.values()) { + if (v instanceof TemplateExpression) { + return true; + } } - JPAUtil.setConstants(query, serializer.getConstants(), queryMixin.getMetadata().getParams()); - return query.executeUpdate(); + return false; } /** diff --git a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/DialectSupport.java b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/DialectSupport.java index 429a279f89..4bc0048213 100644 --- a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/DialectSupport.java +++ b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/DialectSupport.java @@ -70,9 +70,7 @@ public static void extendRegistry( var basicTypeRegistry = functionContributions.getTypeConfiguration().getBasicTypeRegistry(); functions.forEach( - (name, template) -> - functionRegistry.registerPattern( - name, template.pattern(), basicTypeRegistry.resolve(template.type()))); + (name, template) -> registerPattern(functionRegistry, basicTypeRegistry, name, template)); } public static void extendRegistry( @@ -82,8 +80,23 @@ public static void extendRegistry( var functionRegistry = functionContributions.getFunctionRegistry(); var basicTypeRegistry = functionContributions.getTypeConfiguration().getBasicTypeRegistry(); - functionRegistry.registerPattern( - name, template.pattern(), basicTypeRegistry.resolve(template.type())); + registerPattern(functionRegistry, basicTypeRegistry, name, template); + } + + private static void registerPattern( + org.hibernate.query.sqm.function.SqmFunctionRegistry functionRegistry, + org.hibernate.type.BasicTypeRegistry basicTypeRegistry, + String name, + DialectFunctionTemplate template) { + // Operators such as CURRENT_DATE are declared with a generic Comparable type that does not map + // to a Hibernate BasicType. In that case register the pattern without an explicit return type + // and let Hibernate infer it, instead of failing on a null type. + if (template.type() == null) { + functionRegistry.registerPattern(name, template.pattern()); + } else { + functionRegistry.registerPattern( + name, template.pattern(), basicTypeRegistry.resolve(template.type())); + } } static class DialectFunctionTemplate { diff --git a/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/QSQLServerDialect.java b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/QSQLServerDialect.java new file mode 100644 index 0000000000..4d44ff9b21 --- /dev/null +++ b/fluentq-libraries/fluentq-jpa/src/main/java/fluentq/jpa/support/QSQLServerDialect.java @@ -0,0 +1,33 @@ +/* + * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fluentq.jpa.support; + +import fluentq.core.types.Ops; +import fluentq.sql.SQLServer2012Templates; +import org.hibernate.boot.model.FunctionContributions; +import org.hibernate.dialect.SQLServerDialect; + +/** {@code QSQLServerDialect} extends {@code SQLServerDialect} with additional functions */ +public class QSQLServerDialect extends SQLServerDialect { + + @Override + public void initializeFunctionRegistry(FunctionContributions functionContributions) { + super.initializeFunctionRegistry(functionContributions); + DialectSupport.extendRegistry(SQLServer2012Templates.DEFAULT, functionContributions); + DialectSupport.extendRegistry( + "current_date", + DialectSupport.createFunction(SQLServer2012Templates.DEFAULT, Ops.DateTimeOps.CURRENT_DATE), + functionContributions); + } +} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/PackagelessEntityTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/PackagelessEntityTest.java index b3da73c067..07b6c7ab1a 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/PackagelessEntityTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/PackagelessEntityTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.dsl.PathBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PackagelessEntityTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractJPATest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractJPATest.java index ccab1c5fad..b8305b0d80 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractJPATest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractJPATest.java @@ -22,6 +22,7 @@ import static fluentq.core.Target.TERADATA; import static fluentq.jpa.JPAExpressions.select; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.within; import fluentq.core.Fetchable; @@ -111,9 +112,9 @@ import java.util.Map; import java.util.Map.Entry; import java.util.UUID; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @author tiwe @@ -166,7 +167,7 @@ protected Target getTarget() { protected abstract void save(Object entity); - @Before + @BeforeEach public void setUp() { if (query().from(cat).fetchCount() > 0) { savedCats.addAll(query().from(cat).orderBy(cat.id.asc()).select(cat).fetch()); @@ -1128,7 +1129,7 @@ public void groupBy_yearMonth() { } @Test - @Ignore // FIXME + @Disabled // FIXME public void groupBy_count() { var ids = query().from(cat).groupBy(cat.id).select(cat.id).fetch(); var count = query().from(cat).groupBy(cat.id).fetchCount(); @@ -1142,7 +1143,7 @@ public void groupBy_count() { } @Test - @Ignore // FIXME + @Disabled // FIXME public void groupBy_distinct_count() { var ids = query().from(cat).groupBy(cat.id).distinct().select(Expressions.ONE).fetch(); var results = @@ -1227,7 +1228,7 @@ public void in5() { } @Test - @Ignore + @Disabled public void in6() { // query().from(cat).where(cat.kittens.in(savedCats)).fetchCount(); } @@ -1489,7 +1490,7 @@ public void map_groupBy() { } @Test - @Ignore + @Disabled public void map_join() { // select m.text from Show s join s.acts a where key(a) = 'B' var show = QShow.show; @@ -1736,11 +1737,15 @@ public void params_anon() { .isEqualTo("Bob123"); } - @Test(expected = ParamNotSetException.class) + @Test public void params_not_set() { - var name = new Param<>(String.class, "name"); - assertThat(query().from(cat).where(cat.name.eq(name)).select(cat.name).fetchFirst()) - .isEqualTo("Bob123"); + assertThatThrownBy( + () -> { + var name = new Param<>(String.class, "name"); + assertThat(query().from(cat).where(cat.name.eq(name)).select(cat.name).fetchFirst()) + .isEqualTo("Bob123"); + }) + .isInstanceOf(ParamNotSetException.class); } @Test @@ -1773,7 +1778,7 @@ public void factoryExpression_in_groupBy() { } @Test - @Ignore + @Disabled public void size() { // NOT SUPPORTED query().from(cat).select(cat, cat.kittens.size()).fetch(); @@ -1911,7 +1916,7 @@ public void substring2() { } @Test - @Ignore // FIXME + @Disabled // FIXME @ExcludeIn(DERBY) public void substring_from_right() { assertThat( @@ -1958,14 +1963,14 @@ public void subtract_bigDecimal() { } @Test - @Ignore + @Disabled public void sum() { // NOT SUPPORTED query().from(cat).select(cat.kittens.size().sumLong()).fetch(); } @Test - @Ignore + @Disabled public void sum_2() { // NOT SUPPORTED query().from(cat).where(cat.kittens.size().sumLong().gt(0)).select(cat).fetch(); @@ -2231,7 +2236,7 @@ public void treat() { } @Test - @Ignore + @Disabled public void type() { assertThat( query() diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractSQLTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractSQLTest.java index 5e2dbb9a5c..f7f0c713d8 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractSQLTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AbstractSQLTest.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.UUID; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class AbstractSQLTest { @@ -65,7 +65,7 @@ public void enum_binding() { } @Test - @Ignore + @Disabled public void entityProjections() { var cats = query() @@ -283,7 +283,11 @@ public void list_with_offset() { @Test @ExcludeIn(Target.HSQLDB) public void no_from() { - assertThat(query().select(DateExpression.currentDate()).fetchFirst()).isNotNull(); + // the result type of current_date depends on the JPA provider (Hibernate -> LocalDate, + // EclipseLink -> java.sql.Date), so project through a wildcard to avoid a provider-specific + // cast + DateExpression currentDate = DateExpression.currentDate(); + assertThat(query().select(currentDate).fetchFirst()).isNotNull(); } @Test @@ -349,7 +353,7 @@ public void union_all() { @SuppressWarnings("unchecked") @Test @ExcludeIn({Target.DERBY, Target.POSTGRESQL}) - @Ignore // FIXME + @Disabled // FIXME public void union2() { var rows = query() @@ -367,7 +371,7 @@ public void union2() { @SuppressWarnings("unchecked") @Test @ExcludeIn(Target.DERBY) - @Ignore // FIXME + @Disabled // FIXME public void union3() { var cat2 = new SAnimal_("cat2"); var rows = @@ -391,7 +395,7 @@ public void union3() { @SuppressWarnings("unchecked") @Test @ExcludeIn({Target.DERBY, Target.POSTGRESQL}) - @Ignore // FIXME + @Disabled // FIXME public void union4() { query() .union( diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AggregationTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AggregationTest.java index 50f8aa2b3d..98b98abebc 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AggregationTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/AggregationTest.java @@ -15,7 +15,7 @@ import static fluentq.jpa.Constants.cat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AggregationTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/BooleanOperationsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/BooleanOperationsTest.java index dd3869bdb4..4196f23d3a 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/BooleanOperationsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/BooleanOperationsTest.java @@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.BooleanBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BooleanOperationsTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CastTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CastTest.java index e3fd599bb0..3d4d2531ca 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CastTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CastTest.java @@ -17,7 +17,7 @@ import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.NumberExpression; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CastTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CollectionTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CollectionTest.java index 9834365c20..c8e6fcf6b7 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CollectionTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CollectionTest.java @@ -17,7 +17,7 @@ import static fluentq.jpa.Constants.cat1; import fluentq.jpa.domain.Cat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollectionTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ComparableTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ComparableTest.java index 257ce6730b..bbcc48dfc5 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ComparableTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ComparableTest.java @@ -16,7 +16,7 @@ import static fluentq.jpa.Constants.cat; import static fluentq.jpa.Constants.kitten; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ComparableTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ConstructorsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ConstructorsTest.java index ec189ddeae..6c9c4c4594 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ConstructorsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ConstructorsTest.java @@ -18,8 +18,8 @@ import fluentq.core.types.ConstructorExpression; import fluentq.core.types.Expression; import fluentq.core.types.Projections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ConstructorsTest extends AbstractQueryTest { @@ -35,7 +35,7 @@ public QBookmarkDTO(Expression address) { } @Test - @Ignore + @Disabled public void constructors() { ConstructorExpression c = Projections.constructor( diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CustomExpressionsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CustomExpressionsTest.java index 8b4fdeefca..0df9de4e18 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CustomExpressionsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/CustomExpressionsTest.java @@ -20,7 +20,7 @@ import fluentq.core.types.TemplateFactory; import fluentq.core.types.dsl.StringTemplate; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CustomExpressionsTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DateTimeTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DateTimeTest.java index dd46860496..37c7860a3a 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DateTimeTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DateTimeTest.java @@ -20,7 +20,7 @@ import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.TimeExpression; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DateTimeTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DependenciesTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DependenciesTest.java index cb005ba207..0b558fa432 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DependenciesTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/DependenciesTest.java @@ -17,7 +17,7 @@ import java.io.IOException; import jdepend.framework.JDepend; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DependenciesTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/EJBQLTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/EJBQLTest.java index a9ca51b754..e1e50949f8 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/EJBQLTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/EJBQLTest.java @@ -15,7 +15,7 @@ import static fluentq.jpa.Constants.cat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EJBQLTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ExpressionSerializationTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ExpressionSerializationTest.java index 4e01d2dccf..dc74136a71 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ExpressionSerializationTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ExpressionSerializationTest.java @@ -7,7 +7,7 @@ import fluentq.core.types.Expression; import fluentq.jpa.domain.QCat; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExpressionSerializationTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/FeaturesTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/FeaturesTest.java index 88fde4d9e3..a2c1671409 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/FeaturesTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/FeaturesTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.dsl.NumberPath; import fluentq.jpa.domain.QAccount; import fluentq.jpa.domain.QInheritedProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FeaturesTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateBase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateBase.java index fb27e682e2..1d887b731a 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateBase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateBase.java @@ -32,29 +32,22 @@ import fluentq.jpa.hibernate.DefaultSessionHolder; import fluentq.jpa.hibernate.HibernateDeleteClause; import fluentq.jpa.hibernate.HibernateQuery; -import fluentq.jpa.testutil.HibernateTestRunner; +import fluentq.jpa.testutil.HibernateTestExtension; import java.io.IOException; import java.util.List; import org.hibernate.LockMode; import org.hibernate.Session; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * @author tiwe */ -@RunWith(HibernateTestRunner.class) +@ExtendWith({HibernateTestExtension.class, TargetExtension.class, JPAProviderExtension.class}) public class HibernateBase extends AbstractJPATest implements HibernateTest { private static final QCat cat = QCat.cat; - @Rule @ClassRule public static TestRule jpaProviderRule = new JPAProviderRule(); - - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); - private Session session; @Override diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateExecuteWithKeyTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateExecuteWithKeyTest.java index a065530e04..bfe195bcdb 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateExecuteWithKeyTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateExecuteWithKeyTest.java @@ -25,11 +25,11 @@ import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class HibernateExecuteWithKeyTest { @@ -37,7 +37,7 @@ public class HibernateExecuteWithKeyTest { private Session session; private Transaction tx; - @BeforeClass + @BeforeAll public static void setUpClass() { var cfg = new Configuration(); cfg.addAnnotatedClass(GeneratedKeyEntity.class); @@ -50,20 +50,20 @@ public static void setUpClass() { sessionFactory = cfg.buildSessionFactory(); } - @AfterClass + @AfterAll public static void tearDownClass() { if (sessionFactory != null) { sessionFactory.close(); } } - @Before + @BeforeEach public void setUp() { session = sessionFactory.openSession(); tx = session.beginTransaction(); } - @After + @AfterEach public void tearDown() { if (tx != null && tx.isActive()) { tx.rollback(); @@ -203,4 +203,43 @@ public void executeWithKey_rejects_subquery() { .executeWithKey(entity.id)) .isInstanceOf(UnsupportedOperationException.class); } + + @Test + public void execute_with_function_template_routes_through_native_sql() { + // Regression for #1757: execute() must route to native SQL when value expressions + // contain function templates, otherwise Hibernate's HQL parser rejects them. + var entity = QGeneratedKeyEntity.generatedKeyEntity; + long rows = + insert(entity) + .set( + entity.name, + Expressions.stringTemplate("upper({0})", Expressions.constant("hello"))) + .execute(); + + assertThat(rows).isEqualTo(1L); + + var stored = + (String) + session + .createNativeQuery("select name_ from generated_key_entity", String.class) + .getSingleResult(); + assertThat(stored).isEqualTo("HELLO"); + } + + @Test + public void execute_without_template_uses_jpql_path() { + // Regression for #1757: plain value INSERTs must keep using the JPQL path so + // JPA semantics (cascade, callbacks where applicable) are preserved. + var entity = QGeneratedKeyEntity.generatedKeyEntity; + long rows = insert(entity).set(entity.name, "plain").execute(); + + assertThat(rows).isEqualTo(1L); + + var stored = + (String) + session + .createNativeQuery("select name_ from generated_key_entity", String.class) + .getSingleResult(); + assertThat(stored).isEqualTo("plain"); + } } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateHandlerTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateHandlerTest.java index e030dce646..77ff5095bb 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateHandlerTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateHandlerTest.java @@ -1,6 +1,7 @@ package fluentq.jpa; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; @@ -20,7 +21,7 @@ import org.hibernate.query.NativeQuery; import org.hibernate.query.spi.ScrollableResultsImplementor; import org.hibernate.transform.ResultTransformer; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HibernateHandlerTest { @@ -40,19 +41,23 @@ public void should_add_entity() { verify(nativeQuery); } - @Test(expected = PersistenceException.class) + @Test public void addEntity_should_throw_persistence_exception_when_invalid_query_type() { - var notSupportedQuery = (Query) createMock(EJBQueryImpl.class); - var expectedThrow = - new PersistenceException( - ExceptionLocalization.buildMessage( - "unable_to_unwrap_jpa", - new String[] {Query.class.getName(), NativeQuery.class.getName()})); - - expect(notSupportedQuery.unwrap(NativeQuery.class)).andThrow(expectedThrow); - replay(notSupportedQuery); - - hibernateHandler.addEntity(notSupportedQuery, alias, classType); + assertThatThrownBy( + () -> { + var notSupportedQuery = (Query) createMock(EJBQueryImpl.class); + var expectedThrow = + new PersistenceException( + ExceptionLocalization.buildMessage( + "unable_to_unwrap_jpa", + new String[] {Query.class.getName(), NativeQuery.class.getName()})); + + expect(notSupportedQuery.unwrap(NativeQuery.class)).andThrow(expectedThrow); + replay(notSupportedQuery); + + hibernateHandler.addEntity(notSupportedQuery, alias, classType); + }) + .isInstanceOf(PersistenceException.class); } @Test @@ -66,19 +71,23 @@ public void should_add_scalar() { verify(nativeQuery); } - @Test(expected = PersistenceException.class) + @Test public void addScalar_should_throw_persistence_exception_when_invalid_query_type() { - var notSupportedQuery = (EJBQueryImpl) createMock(EJBQueryImpl.class); - var expectedThrow = - new PersistenceException( - ExceptionLocalization.buildMessage( - "unable_to_unwrap_jpa", - new String[] {Query.class.getName(), NativeQuery.class.getName()})); - - expect(notSupportedQuery.unwrap(NativeQuery.class)).andThrow(expectedThrow); - replay(notSupportedQuery); - - hibernateHandler.addScalar(notSupportedQuery, alias, classType); + assertThatThrownBy( + () -> { + var notSupportedQuery = (EJBQueryImpl) createMock(EJBQueryImpl.class); + var expectedThrow = + new PersistenceException( + ExceptionLocalization.buildMessage( + "unable_to_unwrap_jpa", + new String[] {Query.class.getName(), NativeQuery.class.getName()})); + + expect(notSupportedQuery.unwrap(NativeQuery.class)).andThrow(expectedThrow); + replay(notSupportedQuery); + + hibernateHandler.addScalar(notSupportedQuery, alias, classType); + }) + .isInstanceOf(PersistenceException.class); } @Test diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryFactoryTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryFactoryTest.java index 1a1093cc2e..104cdf7d51 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryFactoryTest.java @@ -20,14 +20,14 @@ import java.util.function.Supplier; import org.easymock.EasyMock; import org.hibernate.Session; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class HibernateQueryFactoryTest { private HibernateQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { Supplier provider = () -> EasyMock.createNiceMock(Session.class); queryFactory = new HibernateQueryFactory(JPQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryMutabilityTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryMutabilityTest.java index d295e47029..031e40b5be 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryMutabilityTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryMutabilityTest.java @@ -18,16 +18,16 @@ import fluentq.core.QueryMutability; import fluentq.jpa.domain.QCat; import fluentq.jpa.hibernate.HibernateQuery; -import fluentq.jpa.testutil.HibernateTestRunner; +import fluentq.jpa.testutil.HibernateTestExtension; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.hibernate.Session; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@Ignore -@RunWith(HibernateTestRunner.class) +@Disabled +@ExtendWith(HibernateTestExtension.class) public class HibernateQueryMutabilityTest implements HibernateTest { private Session session; diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryTest.java index bd31f73f1f..e42dd0776e 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateQueryTest.java @@ -20,7 +20,7 @@ import fluentq.jpa.domain.QEmployee; import fluentq.jpa.domain.QUser; import fluentq.jpa.hibernate.HibernateQuery; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HibernateQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateSQLBase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateSQLBase.java index 6a8e1d7e29..dc5ffcf71c 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateSQLBase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/HibernateSQLBase.java @@ -22,21 +22,16 @@ import fluentq.jpa.domain.QCat; import fluentq.jpa.domain.sql.SAnimal_; import fluentq.jpa.hibernate.sql.HibernateSQLQuery; -import fluentq.jpa.testutil.HibernateTestRunner; +import fluentq.jpa.testutil.HibernateTestExtension; import fluentq.sql.SQLTemplates; import org.hibernate.Session; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(HibernateTestRunner.class) +@ExtendWith({HibernateTestExtension.class, TargetExtension.class}) public class HibernateSQLBase extends AbstractSQLTest implements HibernateTest { - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); - private final SQLTemplates templates = Mode.getSQLTemplates(); private final SAnimal_ cat = new SAnimal_("cat"); @@ -53,7 +48,7 @@ public void setSession(Session session) { this.session = session; } - @Before + @BeforeEach public void setUp() { if (query().from(cat).fetchCount() == 0) { session.persist(new Cat("Beck", 1, Color.BLACK)); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/IntegrationBase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/IntegrationBase.java index 498a99c08f..c9e63523a0 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/IntegrationBase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/IntegrationBase.java @@ -25,15 +25,15 @@ import fluentq.jpa.hibernate.HibernateQuery; import fluentq.jpa.hibernate.HibernateUpdateClause; import fluentq.jpa.hibernate.HibernateUtil; -import fluentq.jpa.testutil.HibernateTestRunner; +import fluentq.jpa.testutil.HibernateTestExtension; import java.util.Arrays; import java.util.List; import org.hibernate.ScrollMode; import org.hibernate.Session; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(HibernateTestRunner.class) +@ExtendWith(HibernateTestExtension.class) public class IntegrationBase extends ParsingTest implements HibernateTest { private Session session; diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPABase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPABase.java index 0d49468413..2bd111d913 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPABase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPABase.java @@ -34,7 +34,7 @@ import fluentq.jpa.domain.QParent; import fluentq.jpa.impl.JPADeleteClause; import fluentq.jpa.impl.JPAQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; import jakarta.persistence.FlushModeType; import jakarta.persistence.LockModeType; @@ -42,25 +42,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * @author tiwe */ -@RunWith(JPATestRunner.class) +@ExtendWith({JPATestExtension.class, TargetExtension.class, JPAProviderExtension.class}) public class JPABase extends AbstractJPATest implements JPATest { private static final QCat cat = QCat.cat; - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); - - @Rule @ClassRule public static TestRule jpaProviderRule = new JPAProviderRule(); - private EntityManager entityManager; @Override @@ -97,7 +90,7 @@ public void connection_access() { } @Test - @Ignore + @Disabled public void delete() { delete(cat).execute(); } @@ -135,6 +128,9 @@ public void delete_where_subQuery_exists() { @Test @NoBatooJPA + // Hibernate wraps the correlated EXISTS subquery in a derived table, and MySQL cannot reference + // the deleted table's alias from inside a derived table ("Unknown column 'c1_0.parent_id'") + @ExcludeIn(Target.MYSQL) public void delete_where_subQuery2() { var child = QChild.child; var parent = QParent.parent; @@ -213,6 +209,9 @@ public void limit1_uniqueResult() { } @Test + // Hibernate 7.4 generates a malformed pessimistic-lock clause ("... with rs with rs") for Derby + // and a "for share of " clause that MySQL does not support + @ExcludeIn({Target.DERBY, Target.MYSQL}) public void lockMode() { var query = query().from(cat).setLockMode(LockModeType.PESSIMISTIC_READ).select(cat).createQuery(); @@ -221,6 +220,9 @@ public void lockMode() { } @Test + // Hibernate 7.4 generates a malformed pessimistic-lock clause ("... with rs with rs") for Derby + // and a "for share of " clause that MySQL does not support + @ExcludeIn({Target.DERBY, Target.MYSQL}) public void lockMode2() { assertThat(query().from(cat).setLockMode(LockModeType.PESSIMISTIC_READ).select(cat).fetch()) .isNotEmpty(); @@ -235,7 +237,7 @@ public void queryExposure() { } @Test - @Ignore // isn't a valid JPQL query + @Disabled // isn't a valid JPQL query public void subquery_uniqueResult() { var cat2 = new QCat("cat2"); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPACollectionAnyVisitorTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPACollectionAnyVisitorTest.java index 5df6c2a96a..7609e9c97a 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPACollectionAnyVisitorTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPACollectionAnyVisitorTest.java @@ -24,7 +24,7 @@ import fluentq.jpa.domain.QCompany; import fluentq.jpa.domain.QDomesticCat; import fluentq.jpa.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JPACollectionAnyVisitorTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAExecuteWithKeyTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAExecuteWithKeyTest.java index 2dfe83c8b9..48dbf10b93 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAExecuteWithKeyTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAExecuteWithKeyTest.java @@ -25,11 +25,11 @@ import jakarta.persistence.EntityTransaction; import jakarta.persistence.Persistence; import java.util.Map; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JPAExecuteWithKeyTest { @@ -37,7 +37,7 @@ public class JPAExecuteWithKeyTest { private EntityManager entityManager; private EntityTransaction tx; - @BeforeClass + @BeforeAll public static void setUpClass() { emf = Persistence.createEntityManagerFactory( @@ -51,21 +51,21 @@ public static void setUpClass() { "hibernate.show_sql", "false")); } - @AfterClass + @AfterAll public static void tearDownClass() { if (emf != null) { emf.close(); } } - @Before + @BeforeEach public void setUp() { entityManager = emf.createEntityManager(); tx = entityManager.getTransaction(); tx.begin(); } - @After + @AfterEach public void tearDown() { if (tx != null && tx.isActive()) { tx.rollback(); @@ -221,4 +221,43 @@ public void executeWithKey_rejects_subquery() { .executeWithKey(entity.id)) .isInstanceOf(UnsupportedOperationException.class); } + + @Test + public void execute_with_function_template_routes_through_native_sql() { + // Regression for #1757: execute() must route to native SQL when value expressions + // contain function templates, otherwise Hibernate's HQL parser rejects them. + var entity = QGeneratedKeyEntity.generatedKeyEntity; + long rows = + insert(entity) + .set( + entity.name, + Expressions.stringTemplate("upper({0})", Expressions.constant("hello"))) + .execute(); + + assertThat(rows).isEqualTo(1L); + + var stored = + (String) + entityManager + .createNativeQuery("select name_ from generated_key_entity") + .getSingleResult(); + assertThat(stored).isEqualTo("HELLO"); + } + + @Test + public void execute_without_template_uses_jpql_path() { + // Regression for #1757: plain value INSERTs must keep using the JPQL path so + // JPA semantics (cascade, callbacks where applicable) are preserved. + var entity = QGeneratedKeyEntity.generatedKeyEntity; + long rows = insert(entity).set(entity.name, "plain").execute(); + + assertThat(rows).isEqualTo(1L); + + var stored = + (String) + entityManager + .createNativeQuery("select name_ from generated_key_entity") + .getSingleResult(); + assertThat(stored).isEqualTo("plain"); + } } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAIntegrationBase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAIntegrationBase.java index 0758823eed..13bdc65b96 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAIntegrationBase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAIntegrationBase.java @@ -15,20 +15,13 @@ import fluentq.jpa.impl.JPAProvider; import fluentq.jpa.impl.JPAUtil; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(JPATestRunner.class) +@ExtendWith({JPATestExtension.class, TargetExtension.class, JPAProviderExtension.class}) public class JPAIntegrationBase extends ParsingTest implements JPATest { - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); - - @Rule @ClassRule public static TestRule hibernateOnly = new JPAProviderRule(); - private EntityManager em; private JPQLTemplates templates; diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderExtension.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderExtension.java new file mode 100644 index 0000000000..b813565dd0 --- /dev/null +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderExtension.java @@ -0,0 +1,58 @@ +/* + * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fluentq.jpa; + +import fluentq.core.Target; +import java.util.Arrays; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit 5 replacement for the former {@code JPAProviderRule}. Disables a test annotated with {@link + * NoEclipseLink}, {@link NoOpenJPA}, {@link NoBatooJPA} or {@link NoHibernate} when the active + * {@link Mode#mode} matches the corresponding provider. + */ +public class JPAProviderExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + var element = context.getElement().orElse(null); + if (element == null) { + return ConditionEvaluationResult.enabled("No annotated element"); + } + var mode = Mode.mode.get(); + if (mode == null) { + return ConditionEvaluationResult.enabled("No mode configured"); + } + var noEclipseLink = element.getAnnotation(NoEclipseLink.class); + var noOpenJPA = element.getAnnotation(NoOpenJPA.class); + var noBatooJPA = element.getAnnotation(NoBatooJPA.class); + var noHibernate = element.getAnnotation(NoHibernate.class); + if (noEclipseLink != null && applies(noEclipseLink.value()) && mode.contains("-eclipselink")) { + return ConditionEvaluationResult.disabled("Disabled for EclipseLink"); + } else if (noOpenJPA != null && applies(noOpenJPA.value()) && mode.contains("-openjpa")) { + return ConditionEvaluationResult.disabled("Disabled for OpenJPA"); + } else if (noBatooJPA != null && applies(noBatooJPA.value()) && mode.contains("-batoo")) { + return ConditionEvaluationResult.disabled("Disabled for BatooJPA"); + } else if (noHibernate != null && applies(noHibernate.value()) && !mode.contains("-")) { + return ConditionEvaluationResult.disabled("Disabled for Hibernate"); + } + return ConditionEvaluationResult.enabled("Enabled for mode " + mode); + } + + private boolean applies(Target[] targets) { + return targets.length == 0 || Arrays.asList(targets).contains(Mode.target.get()); + } +} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderRule.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderRule.java deleted file mode 100644 index 8cbd0ce074..0000000000 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderRule.java +++ /dev/null @@ -1,42 +0,0 @@ -package fluentq.jpa; - -import fluentq.core.Target; -import fluentq.core.testutil.EmptyStatement; -import java.util.Arrays; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * @author tiwe - */ -public class JPAProviderRule implements TestRule { - - @Override - public Statement apply(Statement base, Description description) { - var noEclipseLink = description.getAnnotation(NoEclipseLink.class); - var noOpenJPA = description.getAnnotation(NoOpenJPA.class); - var noBatooJPA = description.getAnnotation(NoBatooJPA.class); - var noHibernate = description.getAnnotation(NoHibernate.class); - var mode = Mode.mode.get(); - if (mode == null) { - return base; - } else if (noEclipseLink != null - && applies(noEclipseLink.value()) - && mode.contains("-eclipselink")) { - return EmptyStatement.DEFAULT; - } else if (noOpenJPA != null && applies(noOpenJPA.value()) && mode.contains("-openjpa")) { - return EmptyStatement.DEFAULT; - } else if (noBatooJPA != null && applies(noBatooJPA.value()) && mode.contains("-batoo")) { - return EmptyStatement.DEFAULT; - } else if (noHibernate != null && applies(noHibernate.value()) && !mode.contains("-")) { - return EmptyStatement.DEFAULT; - } else { - return base; - } - } - - private boolean applies(Target[] targets) { - return targets.length == 0 || Arrays.asList(targets).contains(Mode.target.get()); - } -} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderTest.java index 362593a240..496e2b2db8 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAProviderTest.java @@ -11,9 +11,9 @@ import java.lang.reflect.Proxy; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; // 5.664 public class JPAProviderTest { @@ -22,7 +22,7 @@ public class JPAProviderTest { private EntityManager em; - @After + @AfterEach public void tearDown() { if (em != null) { em.close(); @@ -91,7 +91,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl } @Test - @Ignore // doesn't work on JDK 7 + @Disabled // doesn't work on JDK 7 public void openJPA() { factory = Persistence.createEntityManagerFactory("derby-openjpa"); em = factory.createEntityManager(); @@ -101,7 +101,7 @@ public void openJPA() { } @Test - @Ignore // temporarily ignored, since Batoo hangs on EntityManager creation + @Disabled // temporarily ignored, since Batoo hangs on EntityManager creation public void batoo() { factory = Persistence.createEntityManagerFactory("h2-batoo"); em = factory.createEntityManager(); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryConverterCollectionContainsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryConverterCollectionContainsTest.java index 5996eb79ec..d4a2c1a18c 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryConverterCollectionContainsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryConverterCollectionContainsTest.java @@ -7,17 +7,17 @@ import fluentq.jpa.domain.PotionEffect; import fluentq.jpa.domain.QAlchemist; import fluentq.jpa.impl.JPAQueryFactory; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; import java.util.Collections; import java.util.EnumSet; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(JPATestRunner.class) +@ExtendWith(JPATestExtension.class) public class JPAQueryConverterCollectionContainsTest implements JPATest { private EntityManager em; @@ -33,7 +33,7 @@ public void setEntityManager(EntityManager em) { private static final QAlchemist qAlchemist = QAlchemist.alchemist; - @Before + @BeforeEach public void setUpData() { if (em == null) { throw new IllegalStateException("EntityManager has not been set by JPATestRunner."); @@ -66,7 +66,7 @@ public void setUpData() { em.clear(); } - @After + @AfterEach public void tearDown() { if (em != null && em.getTransaction().isActive()) { em.getTransaction().rollback(); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryCustomTypeWrapperTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryCustomTypeWrapperTest.java index 57a632eec9..5aa722ae61 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryCustomTypeWrapperTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryCustomTypeWrapperTest.java @@ -7,15 +7,15 @@ import fluentq.core.types.dsl.TypeWrapper; import fluentq.jpa.domain.*; import fluentq.jpa.impl.JPAQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; import java.math.BigDecimal; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(JPATestRunner.class) +@ExtendWith(JPATestExtension.class) public class JPAQueryCustomTypeWrapperTest implements JPATest { private EntityManager em; @@ -25,7 +25,7 @@ public void setEntityManager(EntityManager em) { this.em = em; } - @Before + @BeforeEach public void setupData() { em.createQuery("delete from Invoice").executeUpdate(); em.persist(new Invoice("00000000-0000-0000-0000-000000000001", "A", new Money("111"))); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryFactoryTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryFactoryTest.java index 9a93a5d0bf..9381add286 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryFactoryTest.java @@ -24,8 +24,8 @@ import java.util.Map; import java.util.function.Supplier; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JPAQueryFactoryTest { @@ -41,7 +41,7 @@ public class JPAQueryFactoryTest { private Map properties = new HashMap<>(); - @Before + @BeforeEach public void setUp() { factoryMock = EasyMock.createMock(EntityManagerFactory.class); mock = EasyMock.createMock(EntityManager.class); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMixinTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMixinTest.java index 72e34bef42..0280d106cf 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMixinTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMixinTest.java @@ -15,7 +15,7 @@ import fluentq.jpa.domain4.QBookVersion; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JPAQueryMixinTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutability2Test.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutability2Test.java index 76572128f0..c4e5abd246 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutability2Test.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutability2Test.java @@ -15,16 +15,17 @@ import static fluentq.core.types.dsl.Expressions.numberOperation; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.types.Operator; import fluentq.jpa.domain.QCat; import fluentq.jpa.impl.JPAQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(JPATestRunner.class) +@ExtendWith(JPATestExtension.class) public class JPAQueryMutability2Test implements JPATest { private EntityManager entityManager; @@ -121,14 +122,18 @@ public void clone_keep_templates() { .fetchOne(); } - @Test(expected = IllegalArgumentException.class) + @Test public void clone_lose_templates() { - var cat = QCat.cat; - JPAQuery query = query(customTemplates).from(cat); - // clone using the entitymanager's default templates - query - .clone(entityManager) - .select(numberOperation(Integer.class, customOperator, cat.floatProperty)) - .fetchOne(); + assertThatThrownBy( + () -> { + var cat = QCat.cat; + JPAQuery query = query(customTemplates).from(cat); + // clone using the entitymanager's default templates + query + .clone(entityManager) + .select(numberOperation(Integer.class, customOperator, cat.floatProperty)) + .fetchOne(); + }) + .isInstanceOf(IllegalArgumentException.class); } } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutabilityTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutabilityTest.java index 983f08508f..f5df0a56fe 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutabilityTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPAQueryMutabilityTest.java @@ -19,18 +19,18 @@ import fluentq.jpa.domain.Cat; import fluentq.jpa.domain.sql.SAnimal_; import fluentq.jpa.sql.JPASQLQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import fluentq.sql.DerbyTemplates; import fluentq.sql.SQLTemplates; import jakarta.persistence.EntityManager; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@Ignore -@RunWith(JPATestRunner.class) +@Disabled +@ExtendWith(JPATestExtension.class) public class JPAQueryMutabilityTest implements JPATest { private static final SQLTemplates derbyTemplates = new DerbyTemplates(); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPASQLBase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPASQLBase.java index 1d597ec3d2..bb21cf7466 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPASQLBase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPASQLBase.java @@ -24,25 +24,18 @@ import fluentq.jpa.domain.QCat; import fluentq.jpa.domain.sql.SAnimal_; import fluentq.jpa.sql.JPASQLQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import fluentq.sql.SQLTemplates; import jakarta.persistence.EntityManager; import java.util.Arrays; import java.util.HashMap; import java.util.List; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; - -@RunWith(JPATestRunner.class) -public class JPASQLBase extends AbstractSQLTest implements JPATest { - - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; - @Rule @ClassRule public static TestRule hibernateOnly = new JPAProviderRule(); +@ExtendWith({JPATestExtension.class, TargetExtension.class, JPAProviderExtension.class}) +public class JPASQLBase extends AbstractSQLTest implements JPATest { private final SQLTemplates templates = Mode.getSQLTemplates(); @@ -61,7 +54,7 @@ public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } - @Before + @BeforeEach public void setUp() { if (query().from(cat).fetchCount() == 0) { entityManager.persist(new Cat("Beck", 1, Color.BLACK)); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLQueryTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLQueryTest.java index 7d5cbe1c85..c08305cefe 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLQueryTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLQueryTest.java @@ -14,12 +14,13 @@ package fluentq.jpa; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.jpa.domain.QCat; import fluentq.jpa.hibernate.HibernateQuery; import fluentq.jpa.impl.JPAQuery; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JPQLQueryTest { @@ -27,39 +28,63 @@ public class JPQLQueryTest { private HibernateQuery query = new HibernateQuery(); - @Before + @BeforeEach public void setUp() { query.from(cat); } - @Test(expected = IllegalArgumentException.class) + @Test public void innerJoinPEntityOfPPEntityOfP() { - query.innerJoin(cat.mate, cat.mate); + assertThatThrownBy( + () -> { + query.innerJoin(cat.mate, cat.mate); + }) + .isInstanceOf(IllegalArgumentException.class); } - @Test(expected = IllegalArgumentException.class) + @Test public void innerJoinPathOfQextendsCollectionOfPPathOfP() { - query.innerJoin(cat.kittens, cat.mate); + assertThatThrownBy( + () -> { + query.innerJoin(cat.kittens, cat.mate); + }) + .isInstanceOf(IllegalArgumentException.class); } - @Test(expected = IllegalArgumentException.class) + @Test public void joinPEntityOfPPEntityOfP() { - query.join(cat.mate, cat.mate); + assertThatThrownBy( + () -> { + query.join(cat.mate, cat.mate); + }) + .isInstanceOf(IllegalArgumentException.class); } - @Test(expected = IllegalArgumentException.class) + @Test public void joinPathOfQextendsCollectionOfPPathOfP() { - query.join(cat.kittens, cat.mate); + assertThatThrownBy( + () -> { + query.join(cat.kittens, cat.mate); + }) + .isInstanceOf(IllegalArgumentException.class); } - @Test(expected = IllegalArgumentException.class) + @Test public void leftJoinPEntityOfPPEntityOfP() { - query.leftJoin(cat.mate, cat.mate); + assertThatThrownBy( + () -> { + query.leftJoin(cat.mate, cat.mate); + }) + .isInstanceOf(IllegalArgumentException.class); } - @Test(expected = IllegalArgumentException.class) + @Test public void leftJoinPathOfQextendsCollectionOfPPathOfP() { - query.leftJoin(cat.kittens, cat.mate); + assertThatThrownBy( + () -> { + query.leftJoin(cat.kittens, cat.mate); + }) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLSerializerTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLSerializerTest.java index 756df91f3b..c702bf968e 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLSerializerTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLSerializerTest.java @@ -32,7 +32,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JPQLSerializerTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLTemplatesTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLTemplatesTest.java index ae1a8efa38..d10d06bdb3 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JPQLTemplatesTest.java @@ -8,7 +8,7 @@ import fluentq.core.types.TemplatesTestUtils; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JPQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinFlagsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinFlagsTest.java index 99897ea873..eca01600b7 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinFlagsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinFlagsTest.java @@ -17,7 +17,7 @@ import static fluentq.jpa.Constants.cat1; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JoinFlagsTest extends AbstractQueryTest { @Test diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinTest.java index 390c6eb826..98d95f3c9c 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JoinTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.dsl.StringPath; import fluentq.jpa.hibernate.HibernateQuery; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JoinTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JpaNativeInsertSerializerTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JpaNativeInsertSerializerTest.java index 04e9597863..fe3a2be7c0 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JpaNativeInsertSerializerTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/JpaNativeInsertSerializerTest.java @@ -14,6 +14,7 @@ package fluentq.jpa; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.types.Expression; import fluentq.core.types.dsl.Expressions; @@ -26,7 +27,7 @@ import fluentq.sql.Configuration; import fluentq.sql.SQLTemplates; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JpaNativeInsertSerializerTest { @@ -134,14 +135,18 @@ public void serializeInsert_collects_constants_in_order() { assertThat(serializer.getConstants()).containsExactly("a", "b"); } - @Test(expected = IllegalArgumentException.class) + @Test public void serializeInsert_rejects_mismatched_column_value_counts() { - var entity = QGeneratedKeyEntity.generatedKeyEntity; - var serializer = newSerializer(SQLTemplates.DEFAULT); - - serializer.serializeInsert( - GeneratedKeyEntity.class, - List.of(entity.name), - List.of(Expressions.constant("a"), Expressions.constant("b"))); + assertThatThrownBy( + () -> { + var entity = QGeneratedKeyEntity.generatedKeyEntity; + var serializer = newSerializer(SQLTemplates.DEFAULT); + + serializer.serializeInsert( + GeneratedKeyEntity.class, + List.of(entity.name), + List.of(Expressions.constant("a"), Expressions.constant("b"))); + }) + .isInstanceOf(IllegalArgumentException.class); } } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MapOperationsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MapOperationsTest.java index c6749ff641..52626ba296 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MapOperationsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MapOperationsTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.jpa.impl.JPAQuery; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MapOperationsTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MathTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MathTest.java index f06456d8ee..84fa89007c 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MathTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/MathTest.java @@ -17,7 +17,7 @@ import static fluentq.jpa.Constants.kitten; import fluentq.jpa.domain.QCat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MathTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/Mode.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/Mode.java index cfad82dc99..2371c2b011 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/Mode.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/Mode.java @@ -12,6 +12,7 @@ import fluentq.sql.SQLTemplates; import fluentq.sql.SQLiteTemplates; import fluentq.sql.TeradataTemplates; +import fluentq.sql.TursoTemplates; /** * @author tiwe @@ -23,29 +24,20 @@ public final class Mode { public static final ThreadLocal target = new ThreadLocal<>(); public static SQLTemplates getSQLTemplates() { - switch (target.get()) { - case CUBRID: - return new CUBRIDTemplates(); - case DERBY: - return new DerbyTemplates(); - case H2: - return new H2Templates(); - case HSQLDB: - return new HSQLDBTemplates(); - case SQLSERVER: - return new SQLServer2008Templates(); - case MYSQL: - return new MySQLTemplates(); - case ORACLE: - return new OracleTemplates(); - case POSTGRESQL: - return new PostgreSQLTemplates(); - case SQLITE: - return new SQLiteTemplates(); - case TERADATA: - return new TeradataTemplates(); - } - throw new IllegalStateException("Unknown mode " + mode); + return switch (target.get()) { + case CUBRID -> new CUBRIDTemplates(); + case DERBY -> new DerbyTemplates(); + case H2 -> new H2Templates(); + case HSQLDB -> new HSQLDBTemplates(); + case SQLSERVER -> new SQLServer2008Templates(); + case MYSQL -> new MySQLTemplates(); + case ORACLE -> new OracleTemplates(); + case POSTGRESQL -> new PostgreSQLTemplates(); + case SQLITE -> new SQLiteTemplates(); + case TURSO -> new TursoTemplates(); + case TERADATA -> new TeradataTemplates(); + default -> throw new IllegalStateException("Unknown mode " + mode); + }; } private Mode() {} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/NativeSQLSerializerTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/NativeSQLSerializerTest.java index 3efd12c983..12c238a3fc 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/NativeSQLSerializerTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/NativeSQLSerializerTest.java @@ -22,7 +22,7 @@ import fluentq.sql.Configuration; import fluentq.sql.MySQLTemplates; import jakarta.persistence.Column; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NativeSQLSerializerTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderExpressionsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderExpressionsTest.java index fe12b8ca48..d9bc944213 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderExpressionsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderExpressionsTest.java @@ -16,7 +16,7 @@ import static fluentq.jpa.Constants.cat; import static fluentq.jpa.Constants.kitten; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OrderExpressionsTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderHelperTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderHelperTest.java index bb7061d2de..b8e6cbe9fe 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderHelperTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/OrderHelperTest.java @@ -6,7 +6,7 @@ import fluentq.core.types.dsl.PathBuilder; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OrderHelperTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PackageVerification.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PackageVerification.java index 6d3e25c572..6464fbd2b0 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PackageVerification.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PackageVerification.java @@ -25,7 +25,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.Scanner; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PackageVerification { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ParsingTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ParsingTest.java index 85a9412a13..983701def4 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ParsingTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/ParsingTest.java @@ -73,8 +73,8 @@ import fluentq.jpa.domain.QFooDTO; import fluentq.jpa.domain.QItem; import fluentq.jpa.domain.QProduct; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ParsingTest extends AbstractQueryTest { @@ -135,7 +135,7 @@ public void docoExamples910_2() throws Exception { } @Test - @Ignore + @Disabled public void docoExamples910_3() throws Exception { query() .from(cat) @@ -397,7 +397,7 @@ public void docoExamples97_9() throws Exception { } @Test - @Ignore + @Disabled // @NoEclipseLink public void docoExamples97_10() throws Exception { query() @@ -481,7 +481,7 @@ public void docoExamples98_10() throws Exception { @Test @NoEclipseLink @ExcludeIn({DERBY, HSQLDB, H2, MYSQL, ORACLE, POSTGRESQL}) - @Ignore + @Disabled public void docoExamples98_11() throws Exception { query() .from(item, ord) @@ -656,13 +656,13 @@ public void casts_2() throws Exception { } @Test - @Ignore + @Disabled public void groupBy() throws Exception { query().from(qat).groupBy(qat.breed).parse(); } @Test - @Ignore + @Disabled public void groupBy_2() throws Exception { query().from(qat).groupBy(qat.breed, qat.eyecolor).parse(); } @@ -708,7 +708,7 @@ public void not_8() throws Exception { } @Test - @Ignore + @Disabled public void orderBy() throws Exception { // NOT SUPPORTED query().from(qat).orderBy(qat.toes.avg().asc()).parse(); @@ -728,14 +728,14 @@ public void select1() throws Exception { } @Test - @Ignore + @Disabled public void sum() { // NOT SUPPORTED query().from(cat).select(cat.kittens.size().sumLong()).parse(); } @Test - @Ignore + @Disabled public void sum_2() { // NOT SUPPORTED query().from(cat).where(cat.kittens.size().sumLong().gt(0)).select(cat).parse(); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PlaintextEncryptor.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PlaintextEncryptor.java new file mode 100644 index 0000000000..8a2b68f1f0 --- /dev/null +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/PlaintextEncryptor.java @@ -0,0 +1,25 @@ +package fluentq.jpa; + +import org.eclipse.persistence.security.Securable; + +/** + * No-op EclipseLink password encryptor so the external-database test persistence units can use + * plain-text JDBC passwords. + * + *

EclipseLink 5.0 attempts to decrypt every configured JDBC password and aborts with {@code + * EclipseLink-7360} ("Database password was encrypted by deprecated algorithm") when the value is + * not a valid encrypted token. Registering this encryptor via {@code eclipselink.login.encryptor} + * makes EclipseLink treat the password verbatim. + */ +public class PlaintextEncryptor implements Securable { + + @Override + public String encryptPassword(String pswd) { + return pswd; + } + + @Override + public String decryptPassword(String encryptedPswd) { + return encryptedPswd; + } +} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryHandlerTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryHandlerTest.java index 109b5ec02c..4f1ea85f5b 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryHandlerTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryHandlerTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryHandlerTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryMutabilityTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryMutabilityTest.java index 82fb97a465..856464a599 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryMutabilityTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryMutabilityTest.java @@ -23,8 +23,8 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.hibernate.Session; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class QueryMutabilityTest { @@ -41,7 +41,7 @@ public void setSession(Session session) { } @Test - @Ignore + @Disabled public void queryMutability() throws SecurityException, IllegalArgumentException, diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryPerformanceTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryPerformanceTest.java index ca62a247f0..e920eef1c2 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryPerformanceTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/QueryPerformanceTest.java @@ -4,36 +4,35 @@ import fluentq.core.Target; import fluentq.core.Tuple; -import fluentq.core.testutil.Performance; import fluentq.jpa.domain.Cat; import fluentq.jpa.domain.QCat; import fluentq.jpa.impl.JPAQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(JPATestRunner.class) -@Ignore -@Category(Performance.class) +@ExtendWith(JPATestExtension.class) +@Disabled +@Tag("fluentq.core.testutil.Performance") public class QueryPerformanceTest implements JPATest { private static final int iterations = 1000; private EntityManager entityManager; - @BeforeClass + @BeforeAll public static void setUpClass() { Mode.mode.set("h2perf"); Mode.target.set(Target.H2); } - @AfterClass + @AfterAll public static void tearDownClass() { Mode.mode.remove(); Mode.target.remove(); @@ -43,7 +42,7 @@ private JPAQuery query() { return new JPAQuery(entityManager); } - @Before + @BeforeEach public void setUp() { if (query().from(QCat.cat).fetchCount() == 0) { for (var i = 0; i < iterations; i++) { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/RelationalFunctionCallTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/RelationalFunctionCallTest.java index e6b8c0c663..e63d6c4bf5 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/RelationalFunctionCallTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/RelationalFunctionCallTest.java @@ -26,7 +26,7 @@ import fluentq.sql.SQLExpressions; import fluentq.sql.SQLSerializer; import fluentq.sql.SQLServerTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationalFunctionCallTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SerializationBase.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SerializationBase.java index f9d3635bcf..57ce7c96fb 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SerializationBase.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SerializationBase.java @@ -19,7 +19,7 @@ import fluentq.core.types.Predicate; import fluentq.jpa.domain.QCat; import fluentq.jpa.impl.JPAQuery; -import fluentq.jpa.testutil.JPATestRunner; +import fluentq.jpa.testutil.JPATestExtension; import jakarta.persistence.EntityManager; import java.io.File; import java.io.FileInputStream; @@ -27,10 +27,10 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(JPATestRunner.class) +@ExtendWith(JPATestExtension.class) public class SerializationBase implements JPATest { private QCat cat = QCat.cat; diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SignatureTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SignatureTest.java index c73bd03939..43900015c2 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SignatureTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SignatureTest.java @@ -16,7 +16,7 @@ import fluentq.core.FilteredClause; import fluentq.jpa.hibernate.HibernateQuery; import fluentq.jpa.impl.JPAQuery; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SignatureTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/StringOperationsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/StringOperationsTest.java index 689c0a2d2b..a05cb1cc2f 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/StringOperationsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/StringOperationsTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StringOperationsTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SubQueryTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SubQueryTest.java index c024b514e6..acd5fc5791 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SubQueryTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/SubQueryTest.java @@ -19,14 +19,14 @@ import static fluentq.jpa.JPAExpressions.selectFrom; import static fluentq.jpa.JPAExpressions.selectOne; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import fluentq.core.domain.QCat; import fluentq.core.testutil.Serialization; import fluentq.jpa.domain.Cat; import fluentq.jpa.domain.QEmployee; import fluentq.jpa.domain.QUser; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SubQueryTest extends AbstractQueryTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TargetExtension.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TargetExtension.java new file mode 100644 index 0000000000..7f9f33e777 --- /dev/null +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TargetExtension.java @@ -0,0 +1,51 @@ +/* + * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fluentq.jpa; + +import fluentq.core.testutil.ExcludeIn; +import fluentq.core.testutil.IncludeIn; +import java.util.Arrays; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit 5 replacement for the former {@code TargetRule}. Disables a test (or container) when the + * active {@link Mode#target} is excluded via {@link ExcludeIn} or not part of {@link IncludeIn}. + */ +public class TargetExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + var target = Mode.target.get(); + if (target == null) { + return ConditionEvaluationResult.enabled("No target configured"); + } + var element = context.getElement().orElse(null); + if (element == null) { + return ConditionEvaluationResult.enabled("No annotated element"); + } + // excluded in given targets + var ex = element.getAnnotation(ExcludeIn.class); + if (ex != null && Arrays.asList(ex.value()).contains(target)) { + return ConditionEvaluationResult.disabled("Excluded in target " + target); + } + // included only in given targets + var in = element.getAnnotation(IncludeIn.class); + if (in != null && !Arrays.asList(in.value()).contains(target)) { + return ConditionEvaluationResult.disabled("Not included in target " + target); + } + return ConditionEvaluationResult.enabled("Enabled for target " + target); + } +} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TargetRule.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TargetRule.java deleted file mode 100644 index d142cf31b0..0000000000 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TargetRule.java +++ /dev/null @@ -1,37 +0,0 @@ -package fluentq.jpa; - -import fluentq.core.Target; -import fluentq.core.testutil.EmptyStatement; -import fluentq.core.testutil.ExcludeIn; -import fluentq.core.testutil.IncludeIn; -import java.util.Arrays; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * @author tiwe - */ -public class TargetRule implements TestRule { - - @Override - public Statement apply(Statement base, Description description) { - var target = Mode.target.get(); - var run = target == null || isExecuted(description, target); - return run ? base : EmptyStatement.DEFAULT; - } - - private boolean isExecuted(Description description, Target target) { - var ex = description.getAnnotation(ExcludeIn.class); - // excluded in given targets - if (ex != null && Arrays.asList(ex.value()).contains(target)) { - return false; - } - // included only in given targets - var in = description.getAnnotation(IncludeIn.class); - if (in != null && !Arrays.asList(in.value()).contains(target)) { - return false; - } - return true; - } -} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TupleTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TupleTest.java index 17cba4e42e..d7bcae8965 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TupleTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TupleTest.java @@ -18,13 +18,13 @@ import fluentq.core.types.Projections; import fluentq.core.types.SubQueryExpression; import fluentq.jpa.domain.QCat; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class TupleTest extends AbstractQueryTest { @Test - @Ignore // FIXME + @Disabled // FIXME public void test() { var cat = QCat.cat; diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TypeCastTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TypeCastTest.java index 03375921ec..f7e7ecbe5f 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TypeCastTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/TypeCastTest.java @@ -21,7 +21,7 @@ import fluentq.jpa.domain.QAnimal; import fluentq.jpa.domain.QCat; import fluentq.jpa.domain.QInheritedProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeCastTest { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/UniqueResultsTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/UniqueResultsTest.java index e419f9a22a..d7755c605d 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/UniqueResultsTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/UniqueResultsTest.java @@ -18,14 +18,14 @@ import fluentq.jpa.domain.Cat; import fluentq.jpa.domain.QCat; import fluentq.jpa.hibernate.HibernateQuery; -import fluentq.jpa.testutil.HibernateTestRunner; +import fluentq.jpa.testutil.HibernateTestExtension; import org.hibernate.Session; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@Ignore -@RunWith(HibernateTestRunner.class) +@Disabled +@ExtendWith(HibernateTestExtension.class) public class UniqueResultsTest implements HibernateTest { private Session session; diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/domain/Account.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/domain/Account.java index 2f8042776d..ad4bb462cc 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/domain/Account.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/domain/Account.java @@ -23,7 +23,7 @@ import jakarta.persistence.Table; import jakarta.persistence.Transient; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** The Class Account. */ @SuppressWarnings("serial") diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractJPASuite.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractJPASuite.java index b7a13daf3f..757c027b2f 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractJPASuite.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractJPASuite.java @@ -1,14 +1,11 @@ package fluentq.jpa.suites; import fluentq.jpa.Mode; -import org.junit.AfterClass; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; -@RunWith(Enclosed.class) public abstract class AbstractJPASuite { - @AfterClass + @AfterAll public static void tearDownClass() throws Exception { Mode.mode.remove(); Mode.target.remove(); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractSuite.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractSuite.java index bafedd2a16..630305460b 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractSuite.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/AbstractSuite.java @@ -1,14 +1,11 @@ package fluentq.jpa.suites; import fluentq.jpa.Mode; -import org.junit.AfterClass; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; -@RunWith(Enclosed.class) public abstract class AbstractSuite { - @AfterClass + @AfterAll public static void tearDownClass() throws Exception { Mode.mode.remove(); Mode.target.remove(); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbyEclipseLinkTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbyEclipseLinkTest.java index 44cfbdb4fd..23d9eda7f1 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbyEclipseLinkTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbyEclipseLinkTest.java @@ -1,19 +1,20 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.Derby; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Derby.class) +@Tag("fluentq.core.testutil.Derby") public class DerbyEclipseLinkTest extends AbstractJPASuite { - public static class JPA extends JPABase { + @Nested + class JPA extends JPABase { @Override public void order_stringValue() { // not supported in MySQL/EclipseLink @@ -35,13 +36,16 @@ public void order_stringValue_toBigInteger() { } } - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("derby-eclipselink"); Mode.target.set(Target.DERBY); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbySuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbySuiteTest.java index 30fce9eb5d..ac7d06167f 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbySuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/DerbySuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.Derby; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -9,25 +8,32 @@ import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Derby.class) +@Tag("fluentq.core.testutil.Derby") public class DerbySuiteTest extends AbstractSuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase {} + @Nested + class Hibernate extends HibernateBase {} - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("derby"); Mode.target.set(Target.DERBY); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2BatooTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2BatooTest.java index ae07363968..19bf3a2ef9 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2BatooTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2BatooTest.java @@ -1,29 +1,33 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.H2; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Ignore -@Category(H2.class) +@Disabled +@Tag("fluentq.core.testutil.H2") public class H2BatooTest extends AbstractJPASuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("h2-batoo"); Mode.target.set(Target.H2); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2EclipseLinkTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2EclipseLinkTest.java index 514ff58d96..66dbdd50d8 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2EclipseLinkTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2EclipseLinkTest.java @@ -1,27 +1,31 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.H2; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2EclipseLinkTest extends AbstractJPASuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("h2-eclipselink"); Mode.target.set(Target.H2); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2OpenJPATest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2OpenJPATest.java index 66708149fb..6849fc6318 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2OpenJPATest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2OpenJPATest.java @@ -1,29 +1,33 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.H2; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Ignore -@Category(H2.class) +@Disabled +@Tag("fluentq.core.testutil.H2") public class H2OpenJPATest extends AbstractJPASuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("h2-openjpa"); Mode.target.set(Target.H2); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2SuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2SuiteTest.java index 924892998a..26a4908df1 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2SuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/H2SuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.H2; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -9,25 +8,32 @@ import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2SuiteTest extends AbstractSuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase {} + @Nested + class Hibernate extends HibernateBase {} - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("h2"); Mode.target.set(Target.H2); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBEclipseLinkTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBEclipseLinkTest.java index 6793bbee14..31d89da6a6 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBEclipseLinkTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBEclipseLinkTest.java @@ -1,27 +1,31 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.HSQLDB; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(HSQLDB.class) +@Tag("fluentq.core.testutil.HSQLDB") public class HSQLDBEclipseLinkTest extends AbstractJPASuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("hsqldb-eclipselink"); Mode.target.set(Target.HSQLDB); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBSuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBSuiteTest.java index 4873a78097..13e529fc9f 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBSuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/HSQLDBSuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.HSQLDB; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -9,25 +8,32 @@ import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(HSQLDB.class) +@Tag("fluentq.core.testutil.HSQLDB") public class HSQLDBSuiteTest extends AbstractSuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase {} + @Nested + class Hibernate extends HibernateBase {} - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("hsqldb"); Mode.target.set(Target.HSQLDB); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MSSQLSuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MSSQLSuiteTest.java index 86cf75943a..b7b7956a85 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MSSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MSSQLSuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.SQLServer; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -9,25 +8,32 @@ import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLSuiteTest extends AbstractSuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase {} + @Nested + class Hibernate extends HibernateBase {} - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("mssql"); Mode.target.set(Target.SQLSERVER); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLEclipseLinkTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLEclipseLinkTest.java index 348beced25..6e67a30de5 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLEclipseLinkTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLEclipseLinkTest.java @@ -1,19 +1,20 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.MySQL; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLEclipseLinkTest extends AbstractJPASuite { - public static class JPA extends JPABase { + @Nested + class JPA extends JPABase { @Override public void cast() { // not supported in MySQL/EclipseLink @@ -55,13 +56,16 @@ public void order_nullsLast() { } } - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("mysql-eclipselink"); Mode.target.set(Target.MYSQL); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLSuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLSuiteTest.java index 578769bb8c..e25062e1a8 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLSuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/MySQLSuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.MySQL; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -9,35 +8,42 @@ import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLSuiteTest extends AbstractSuite { - public static class JPA extends JPABase { + @Nested + class JPA extends JPABase { @Override public void order_stringValue_toLong() { // not supported } } - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase { + @Nested + class Hibernate extends HibernateBase { @Override public void order_stringValue_toLong() { // not supported } } - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("mysql"); Mode.target.set(Target.MYSQL); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/OracleSuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/OracleSuiteTest.java index dc8999c189..5179a473bd 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/OracleSuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/OracleSuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.Oracle; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -10,28 +9,35 @@ import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; import java.util.TimeZone; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Oracle.class) +@Tag("fluentq.core.testutil.Oracle") public class OracleSuiteTest extends AbstractSuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase {} + @Nested + class Hibernate extends HibernateBase {} - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} private static TimeZone defaultZone; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("oracle"); Mode.target.set(Target.ORACLE); @@ -44,7 +50,7 @@ public static void setUp() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); } - @AfterClass + @AfterAll public static void tearDown() { TimeZone.setDefault(defaultZone); } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java index 10ce2d42dd..ffe03a1b38 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java @@ -1,27 +1,31 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.PostgreSQL; import fluentq.jpa.JPABase; import fluentq.jpa.JPAIntegrationBase; import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class PostgreSQLEclipseLinkSuiteTest extends AbstractJPASuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("postgresql-eclipselink"); Mode.target.set(Target.POSTGRESQL); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLSuiteTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLSuiteTest.java index b13199a075..48eaa93670 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/suites/PostgreSQLSuiteTest.java @@ -1,7 +1,6 @@ package fluentq.jpa.suites; import fluentq.core.Target; -import fluentq.core.testutil.PostgreSQL; import fluentq.jpa.HibernateBase; import fluentq.jpa.HibernateSQLBase; import fluentq.jpa.JPABase; @@ -9,25 +8,32 @@ import fluentq.jpa.JPASQLBase; import fluentq.jpa.Mode; import fluentq.jpa.SerializationBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class PostgreSQLSuiteTest extends AbstractSuite { - public static class JPA extends JPABase {} + @Nested + class JPA extends JPABase {} - public static class JPASQL extends JPASQLBase {} + @Nested + class JPASQL extends JPASQLBase {} - public static class JPAIntegration extends JPAIntegrationBase {} + @Nested + class JPAIntegration extends JPAIntegrationBase {} - public static class Serialization extends SerializationBase {} + @Nested + class Serialization extends SerializationBase {} - public static class Hibernate extends HibernateBase {} + @Nested + class Hibernate extends HibernateBase {} - public static class HibernateSQL extends HibernateSQLBase {} + @Nested + class HibernateSQL extends HibernateSQLBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Mode.mode.set("postgresql"); Mode.target.set(Target.POSTGRESQL); diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/DialectSupportTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/DialectSupportTest.java index b2f8bdd75c..7ff70c0b62 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/DialectSupportTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/DialectSupportTest.java @@ -5,7 +5,12 @@ import fluentq.core.types.Ops; import fluentq.core.types.Template; import fluentq.sql.HSQLDBTemplates; -import org.junit.Test; +import fluentq.sql.SQLServer2012Templates; +import org.hibernate.boot.model.FunctionContributions; +import org.hibernate.query.sqm.function.SqmFunctionRegistry; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.type.spi.TypeConfiguration; +import org.junit.jupiter.api.Test; public class DialectSupportTest { @@ -16,4 +21,67 @@ public void convert() { Template concat = HSQLDBTemplates.DEFAULT.getTemplate(Ops.CONCAT); assertThat(DialectSupport.convert(concat)).isEqualTo("?1 || ?2"); } + + @Test + public void createFunction_returns_null_type_for_operators_without_a_hibernate_basic_type() { + // CURRENT_DATE is declared with a generic Comparable type that does not map to a Hibernate + // BasicType, so HibernateUtil.getType(...) returns null. + var template = + DialectSupport.createFunction(SQLServer2012Templates.DEFAULT, Ops.DateTimeOps.CURRENT_DATE); + + assertThat(template.type()).isNull(); + assertThat(template.pattern()).isEqualTo("cast(getdate() as date)"); + } + + @Test + public void extendRegistry_registers_pattern_without_type_when_type_is_null() { + var functionRegistry = new SqmFunctionRegistry(); + FunctionContributions contributions = + contributionsBackedBy(functionRegistry, new TypeConfiguration()); + + var template = + DialectSupport.createFunction(SQLServer2012Templates.DEFAULT, Ops.DateTimeOps.CURRENT_DATE); + assertThat(template.type()).isNull(); + + // The null-type branch must register the pattern without resolving a return type instead of + // failing on the null type. + DialectSupport.extendRegistry("current_date", template, contributions); + + assertThat(functionRegistry.findFunctionDescriptor("current_date")).isNotNull(); + } + + @Test + public void extendRegistry_registers_typed_patterns_from_templates() { + var functionRegistry = new SqmFunctionRegistry(); + FunctionContributions contributions = + contributionsBackedBy(functionRegistry, new TypeConfiguration()); + + // The bulk overload registers the date-part functions, whose types (e.g. Integer) do map to a + // Hibernate BasicType and therefore exercise the typed branch. + DialectSupport.extendRegistry(SQLServer2012Templates.DEFAULT, contributions); + + assertThat(functionRegistry.findFunctionDescriptor("year")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("month")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("second")).isNotNull(); + } + + private static FunctionContributions contributionsBackedBy( + SqmFunctionRegistry functionRegistry, TypeConfiguration typeConfiguration) { + return new FunctionContributions() { + @Override + public SqmFunctionRegistry getFunctionRegistry() { + return functionRegistry; + } + + @Override + public TypeConfiguration getTypeConfiguration() { + return typeConfiguration; + } + + @Override + public ServiceRegistry getServiceRegistry() { + return null; + } + }; + } } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/JPAPathBuilderValidatorTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/JPAPathBuilderValidatorTest.java index c2b644535e..20337cc14d 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/JPAPathBuilderValidatorTest.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/JPAPathBuilderValidatorTest.java @@ -6,20 +6,20 @@ import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.Persistence; import java.util.Collection; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JPAPathBuilderValidatorTest { private EntityManagerFactory entityManagerFactory; - @Before + @BeforeEach public void setUp() { entityManagerFactory = Persistence.createEntityManagerFactory("h2"); } - @After + @AfterEach public void tearDown() { entityManagerFactory.close(); } diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/QSQLServerDialectTest.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/QSQLServerDialectTest.java new file mode 100644 index 0000000000..1219d2d420 --- /dev/null +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/support/QSQLServerDialectTest.java @@ -0,0 +1,76 @@ +package fluentq.jpa.support; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Properties; +import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.query.sqm.function.SqmFunctionRegistry; +import org.hibernate.service.ServiceRegistry; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +/** + * Boots an offline Hibernate {@link SessionFactory} with the dialect forced to {@link + * QSQLServerDialect} so that the functions it contributes through {@code + * initializeFunctionRegistry} can be inspected without a running SQL Server. JDBC metadata access + * is disabled so the throwaway H2 connection is never probed for dialect resolution. + */ +public class QSQLServerDialectTest { + + private static SessionFactory sessionFactory; + private static SqmFunctionRegistry functionRegistry; + + @BeforeAll + static void bootSessionFactory() { + var props = new Properties(); + props.put("hibernate.dialect", QSQLServerDialect.class.getName()); + props.put("hibernate.connection.driver_class", "org.h2.Driver"); + props.put("hibernate.connection.url", "jdbc:h2:mem:qsqlserverdialect;DB_CLOSE_DELAY=-1"); + props.put("hibernate.connection.username", "sa"); + props.put("hibernate.connection.password", ""); + // Keep the forced SQL Server dialect: never inspect the H2 connection to resolve a dialect. + props.put("hibernate.boot.allow_jdbc_metadata_access", "false"); + props.put("hibernate.hbm2ddl.auto", "none"); + + ServiceRegistry serviceRegistry = + new StandardServiceRegistryBuilder().applySettings(props).build(); + var cfg = new Configuration(); + cfg.setProperties(props); + sessionFactory = cfg.buildSessionFactory(serviceRegistry); + functionRegistry = + sessionFactory + .unwrap(SessionFactoryImplementor.class) + .getQueryEngine() + .getSqmFunctionRegistry(); + } + + @AfterAll + static void closeSessionFactory() { + if (sessionFactory != null) { + sessionFactory.close(); + } + } + + @Test + public void registers_fluentq_date_functions() { + // The date-part functions contributed from SQLServer2012Templates must be present. + assertThat(functionRegistry.findFunctionDescriptor("year")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("month")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("week")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("day")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("hour")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("minute")).isNotNull(); + assertThat(functionRegistry.findFunctionDescriptor("second")).isNotNull(); + } + + @Test + public void registers_current_date() { + // current_date has a null Hibernate type (Comparable) and is registered through the no-type + // branch of DialectSupport; the dialect must still expose it. + assertThat(functionRegistry.findFunctionDescriptor("current_date")).isNotNull(); + } +} diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/HibernateTestRunner.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/HibernateTestExtension.java similarity index 56% rename from fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/HibernateTestRunner.java rename to fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/HibernateTestExtension.java index 998355bac4..f8b298fed2 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/HibernateTestRunner.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/HibernateTestExtension.java @@ -13,34 +13,30 @@ */ package fluentq.jpa.testutil; -import static org.assertj.core.api.Assertions.assertThat; - import fluentq.core.Target; import fluentq.jpa.HibernateTest; import fluentq.jpa.Mode; import fluentq.jpa.domain.Domain; import java.sql.DriverManager; import java.sql.SQLException; -import java.util.List; import java.util.Properties; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; -import org.junit.rules.MethodRule; -import org.junit.runner.Description; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstancePostProcessor; /** - * @author tiwe + * JUnit 5 replacement for the former {@code HibernateTestRunner}. Builds a single {@link + * SessionFactory}/{@link Session} (with an open transaction) per test class, injects the session + * into every {@link HibernateTest} instance and rolls everything back afterwards. */ -public class HibernateTestRunner extends BlockJUnit4ClassRunner { +public class HibernateTestExtension + implements BeforeAllCallback, AfterAllCallback, TestInstancePostProcessor { private SessionFactory sessionFactory; @@ -48,55 +44,19 @@ public class HibernateTestRunner extends BlockJUnit4ClassRunner { private boolean isDerby = false; - public HibernateTestRunner(Class klass) throws InitializationError { - super(klass); - } + private String previousMode; - @Override - protected List rules(Object test) { - assertThat(test instanceof HibernateTest) - .as( - "In order to use the %s for %s, it should (directly or indirectly) implement %s" - .formatted( - HibernateTestRunner.class.getSimpleName(), - test.getClass(), - HibernateTest.class)) - .isTrue(); - - var rules = super.rules(test); - rules.add( - new MethodRule() { - @Override - public Statement apply( - final Statement base, FrameworkMethod method, final Object target) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - ((HibernateTest) target).setSession(session); - base.evaluate(); - } - }; - } - }); - return rules; - } + private Target previousTarget; @Override - public void run(final RunNotifier notifier) { - try { - start(); - super.run(notifier); - } catch (Exception e) { - e.printStackTrace(); - var failure = - new Failure(Description.createSuiteDescription(getTestClass().getJavaClass()), e); - notifier.fireTestFailure(failure); - } finally { - shutdown(); - } - } + public void beforeAll(ExtensionContext context) throws Exception { + // Mode.mode/target are ThreadLocals shared across the @Nested suites that run on the same + // thread. Remember the values set by the enclosing suite so they can be restored in afterAll, + // otherwise this extension would leak HSQLDB into sibling (e.g. H2/Derby) JPA suites and make + // @IncludeIn/@ExcludeIn evaluate against the wrong target. + previousMode = Mode.mode.get(); + previousTarget = Mode.target.get(); - private void start() throws Exception { Mode.mode.set("hsqldb"); Mode.target.set(Target.HSQLDB); @@ -110,7 +70,7 @@ private void start() throws Exception { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").getDeclaredConstructor().newInstance(); } var props = new Properties(); - var is = HibernateTestRunner.class.getResourceAsStream(mode); + var is = HibernateTestExtension.class.getResourceAsStream(mode); if (is == null) { throw new IllegalArgumentException("No configuration available at classpath:" + mode); } @@ -123,6 +83,41 @@ private void start() throws Exception { session.beginTransaction(); } + @Override + public void postProcessTestInstance(Object testInstance, ExtensionContext context) { + if (!(testInstance instanceof HibernateTest hibernateTest)) { + throw new IllegalStateException( + "In order to use the %s for %s, it should (directly or indirectly) implement %s" + .formatted( + HibernateTestExtension.class.getSimpleName(), + testInstance.getClass(), + HibernateTest.class)); + } + hibernateTest.setSession(session); + } + + @Override + public void afterAll(ExtensionContext context) { + try { + shutdown(); + } finally { + restoreMode(); + } + } + + private void restoreMode() { + if (previousMode == null) { + Mode.mode.remove(); + } else { + Mode.mode.set(previousMode); + } + if (previousTarget == null) { + Mode.target.remove(); + } else { + Mode.target.set(previousTarget); + } + } + private void shutdown() { if (session != null) { try { diff --git a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/JPATestRunner.java b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/JPATestExtension.java similarity index 56% rename from fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/JPATestRunner.java rename to fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/JPATestExtension.java index ed63a7ac53..79cb9ca9ad 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/JPATestRunner.java +++ b/fluentq-libraries/fluentq-jpa/src/test/java/fluentq/jpa/testutil/JPATestExtension.java @@ -13,8 +13,6 @@ */ package fluentq.jpa.testutil; -import static org.assertj.core.api.Assertions.assertThat; - import fluentq.jpa.JPATest; import fluentq.jpa.Mode; import jakarta.persistence.EntityManager; @@ -22,20 +20,18 @@ import jakarta.persistence.Persistence; import java.sql.DriverManager; import java.sql.SQLException; -import java.util.List; -import org.junit.rules.MethodRule; -import org.junit.runner.Description; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstancePostProcessor; /** - * @author tiwe + * JUnit 5 replacement for the former {@code JPATestRunner}. Creates a single {@link + * EntityManagerFactory}/{@link EntityManager} (with an open transaction) per test class, injects + * the entity manager into every {@link JPATest} instance and rolls everything back afterwards. */ -public class JPATestRunner extends BlockJUnit4ClassRunner { +public class JPATestExtension + implements BeforeAllCallback, AfterAllCallback, TestInstancePostProcessor { private EntityManagerFactory entityManagerFactory; @@ -43,52 +39,8 @@ public class JPATestRunner extends BlockJUnit4ClassRunner { private boolean isDerby; - public JPATestRunner(Class klass) throws InitializationError { - super(klass); - } - @Override - protected List rules(Object test) { - assertThat(test instanceof JPATest) - .as( - "In order to use the %s for %s, it should (directly or indirectly) implement %s" - .formatted(JPATestRunner.class.getSimpleName(), test.getClass(), JPATest.class)) - .isTrue(); - - var rules = super.rules(test); - rules.add( - new MethodRule() { - @Override - public Statement apply( - final Statement base, FrameworkMethod method, final Object target) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - ((JPATest) target).setEntityManager(entityManager); - base.evaluate(); - } - }; - } - }); - return rules; - } - - @Override - public void run(final RunNotifier notifier) { - try { - start(); - super.run(notifier); - } catch (Exception e) { - e.printStackTrace(); - var failure = - new Failure(Description.createSuiteDescription(getTestClass().getJavaClass()), e); - notifier.fireTestFailure(failure); - } finally { - shutdown(); - } - } - - private void start() throws Exception { + public void beforeAll(ExtensionContext context) throws Exception { var mode = Mode.mode.get(); if (mode == null) { mode = "h2perf"; @@ -103,6 +55,22 @@ private void start() throws Exception { entityManager.getTransaction().begin(); } + @Override + public void postProcessTestInstance(Object testInstance, ExtensionContext context) { + if (!(testInstance instanceof JPATest jpaTest)) { + throw new IllegalStateException( + "In order to use the %s for %s, it should (directly or indirectly) implement %s" + .formatted( + JPATestExtension.class.getSimpleName(), testInstance.getClass(), JPATest.class)); + } + jpaTest.setEntityManager(entityManager); + } + + @Override + public void afterAll(ExtensionContext context) { + shutdown(); + } + private void shutdown() { if (entityManager != null) { try { diff --git a/fluentq-libraries/fluentq-jpa/src/test/resources/META-INF/persistence.xml b/fluentq-libraries/fluentq-jpa/src/test/resources/META-INF/persistence.xml index 18bb641d98..9d401c1997 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/resources/META-INF/persistence.xml +++ b/fluentq-libraries/fluentq-jpa/src/test/resources/META-INF/persistence.xml @@ -220,7 +220,7 @@ org.hibernate.jpa.HibernatePersistenceProvider - + @@ -239,6 +239,7 @@ + @@ -251,7 +252,7 @@ org.hibernate.jpa.HibernatePersistenceProvider - + @@ -269,7 +270,7 @@ org.hibernate.jpa.HibernatePersistenceProvider - + @@ -288,6 +289,7 @@ + @@ -302,7 +304,7 @@ - + diff --git a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mssql.properties b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mssql.properties index 84daabc913..df56ea4ab7 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mssql.properties +++ b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mssql.properties @@ -1,5 +1,5 @@ ## MSSQL -hibernate.dialect=fluentq.jpa.support.QSQLServer2008Dialect +hibernate.dialect=fluentq.jpa.support.QSQLServerDialect hibernate.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver hibernate.connection.url=jdbc:sqlserver://localhost:1433;databaseName=tempdb;sendTimeAsDatetime=false;trustServerCertificate=true hibernate.connection.username=sa diff --git a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mysql.properties b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mysql.properties index d8e0767beb..602f24ea4c 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mysql.properties +++ b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/mysql.properties @@ -1,5 +1,5 @@ ## MySQL -hibernate.dialect=fluentq.jpa.support.QMySQL5InnoDBDialect +hibernate.dialect=fluentq.jpa.support.QMySQLDialect hibernate.connection.driver_class=com.mysql.jdbc.Driver hibernate.connection.url=jdbc:mysql://localhost:3306/fluentq hibernate.connection.username=fluentq diff --git a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/oracle.properties b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/oracle.properties index e5c7987e67..6526f1f204 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/oracle.properties +++ b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/oracle.properties @@ -2,7 +2,7 @@ #hibernate.dialect=org.hibernate.dialect.Oracle10gDialect hibernate.dialect=fluentq.jpa.support.QOracleDialect hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver -hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:xe +hibernate.connection.url=jdbc:oracle:thin:@localhost:1521/XEPDB1 hibernate.connection.username=fluentq hibernate.connection.password=fluentq diff --git a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/postgresql.properties b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/postgresql.properties index d42021916d..ed3a648c5d 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/postgresql.properties +++ b/fluentq-libraries/fluentq-jpa/src/test/resources/fluentq/jpa/testutil/postgresql.properties @@ -1,5 +1,5 @@ ## MySQL -hibernate.dialect=fluentq.jpa.support.QPostgreSQL9Dialect +hibernate.dialect=fluentq.jpa.support.QPostgreSQLDialect hibernate.connection.driver_class=org.postgresql.Driver hibernate.connection.url=jdbc:postgresql://localhost:5432/fluentq hibernate.connection.username=fluentq diff --git a/fluentq-libraries/fluentq-jpa/src/test/resources/hibernate.cfg.xml b/fluentq-libraries/fluentq-jpa/src/test/resources/hibernate.cfg.xml index c2ca1874f4..b4a8a48be6 100644 --- a/fluentq-libraries/fluentq-jpa/src/test/resources/hibernate.cfg.xml +++ b/fluentq-libraries/fluentq-jpa/src/test/resources/hibernate.cfg.xml @@ -5,7 +5,7 @@ - fluentq.jpa.support.ExtendedDerbyDialect + fluentq.jpa.support.QDerbyDialect org.apache.derby.jdbc.EmbeddedDriver jdbc:derby:target/derbydb;create=true diff --git a/fluentq-libraries/fluentq-kotlin/src/test/kotlin/fluentq/kotlin/CollectionTest.kt b/fluentq-libraries/fluentq-kotlin/src/test/kotlin/fluentq/kotlin/CollectionTest.kt index ecac0d010b..9a3ee383b9 100644 --- a/fluentq-libraries/fluentq-kotlin/src/test/kotlin/fluentq/kotlin/CollectionTest.kt +++ b/fluentq-libraries/fluentq-kotlin/src/test/kotlin/fluentq/kotlin/CollectionTest.kt @@ -15,7 +15,7 @@ package fluentq.kotlin import fluentq.core.types.dsl.* -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigDecimal import kotlin.test.assertEquals diff --git a/fluentq-libraries/fluentq-mongodb/src/test/java/fluentq/mongodb/PackageVerification.java b/fluentq-libraries/fluentq-mongodb/src/test/java/fluentq/mongodb/PackageVerification.java index 845f57963f..868085e702 100644 --- a/fluentq-libraries/fluentq-mongodb/src/test/java/fluentq/mongodb/PackageVerification.java +++ b/fluentq-libraries/fluentq-mongodb/src/test/java/fluentq/mongodb/PackageVerification.java @@ -23,7 +23,6 @@ import java.io.File; import java.net.URL; import java.net.URLClassLoader; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import org.junit.jupiter.api.Test; @@ -51,10 +50,7 @@ private void verify(File oneJar) throws Exception { oneJarClassLoader.loadClass(MorphiaAnnotationProcessor.class.getName()); // fluentq-apt cl.getDeclaredConstructor().newInstance(); var resourceKey = "META-INF/services/javax.annotation.processing.Processor"; - assertThat( - new String( - Files.readAllBytes(Path.of(oneJarClassLoader.findResource(resourceKey).toURI())), - StandardCharsets.UTF_8)) + assertThat(Files.readString(Path.of(oneJarClassLoader.findResource(resourceKey).toURI()))) .isEqualTo(MorphiaAnnotationProcessor.class.getName()); } } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractBaseTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractBaseTest.java index 24c154b8bf..5006d720bf 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractBaseTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractBaseTest.java @@ -26,13 +26,11 @@ import io.r2dbc.spi.Connection; import java.util.List; import org.jetbrains.annotations.Nullable; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.MethodRule; -import org.junit.rules.TestRule; +import org.junit.jupiter.api.extension.ExtendWith; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +@ExtendWith({TargetExtension.class, SkipForQuotedExtension.class}) public abstract class AbstractBaseTest { // protected static final Logger logger = LoggerFactory.getLogger(AbstractBaseTest.class); @@ -77,10 +75,6 @@ public TestQuery clone(Connection conn) { @Nullable protected String expectedQuery; - @Rule public MethodRule skipForQuotedRule = new SkipForQuotedRule(configuration); - - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); - protected void add(List list, T arg, Target... exclusions) { if (exclusions.length > 0) { for (Target t : exclusions) { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractSQLTemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractSQLTemplatesTest.java index 82d953f835..1dc1266874 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractSQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/AbstractSQLTemplatesTest.java @@ -25,8 +25,8 @@ import fluentq.core.types.dsl.NumberExpression; import fluentq.r2dbc.domain.QSurvey; import java.util.Collection; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class AbstractSQLTemplatesTest { @@ -40,7 +40,7 @@ public abstract class AbstractSQLTemplatesTest { protected abstract SQLTemplates createTemplates(); - @Before + @BeforeEach public void setUp() { templates = createTemplates(); templates.newLineToSingleSpace(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/BeanPopulationBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/BeanPopulationBase.java index ec1eee13c3..cea316d695 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/BeanPopulationBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/BeanPopulationBase.java @@ -27,15 +27,15 @@ import fluentq.r2dbc.dml.BeanMapper; import fluentq.r2dbc.domain.Employee; import fluentq.r2dbc.domain.QEmployee; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; @ExcludeIn({CUBRID, DB2, DERBY, ORACLE, SQLSERVER, POSTGRESQL, SQLITE, TERADATA}) public abstract class BeanPopulationBase extends AbstractBaseTest { private final QEmployee e = new QEmployee("e"); - @After + @AfterEach public void tearDown() { delete(e).where(e.firstname.eq("John")).execute().block(); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/CoalesceTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/CoalesceTest.java index 9519dafe0c..bf21d27285 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/CoalesceTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/CoalesceTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.dsl.Coalesce; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CoalesceTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ColumnMetadataTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ColumnMetadataTest.java index 36cc713d76..b1af8f4175 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ColumnMetadataTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ColumnMetadataTest.java @@ -5,7 +5,7 @@ import fluentq.r2dbc.domain.QEmployee; import fluentq.sql.ColumnMetadata; import java.sql.Types; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ColumnMetadataTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ConfigurationTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ConfigurationTest.java index e9ce7d497f..03e2bf957d 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ConfigurationTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ConfigurationTest.java @@ -14,6 +14,7 @@ package fluentq.r2dbc; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.alias.Gender; import fluentq.r2dbc.binding.BindTarget; @@ -35,7 +36,7 @@ import java.sql.Types; import java.util.Locale; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConfigurationTest { @@ -145,14 +146,22 @@ public void columnOverride() { .isEqualTo("lower"); } - @Test(expected = NullPointerException.class) + @Test public void npeWithNullParameterOfChainedNameMappingConstructor() { - new ChainedNameMapping((NameMapping[]) null); + assertThatThrownBy( + () -> { + new ChainedNameMapping((NameMapping[]) null); + }) + .isInstanceOf(NullPointerException.class); } - @Test(expected = NullPointerException.class) + @Test public void npeWithNullElementInParameterOfChainedNameMappingConstructor() { - new ChainedNameMapping(new NameMapping[] {null}); + assertThatThrownBy( + () -> { + new ChainedNameMapping(new NameMapping[] {null}); + }) + .isInstanceOf(NullPointerException.class); } @Test diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DateArithmeticTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DateArithmeticTest.java index 8ac02325b0..98078df3ab 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DateArithmeticTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DateArithmeticTest.java @@ -1,16 +1,15 @@ package fluentq.r2dbc; -import fluentq.core.testutil.ReportingOnly; import fluentq.core.types.Expression; import fluentq.core.types.dsl.DateTimePath; import fluentq.core.types.dsl.Expressions; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(ReportingOnly.class) +@Tag("fluentq.core.testutil.ReportingOnly") public class DateArithmeticTest { private String serialize(Expression expr, SQLTemplates templates) { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DeleteBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DeleteBase.java index 5a35d909a4..8402ba6d02 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DeleteBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DeleteBase.java @@ -26,9 +26,9 @@ import fluentq.core.types.dsl.Param; import fluentq.r2dbc.domain.QEmployee; import fluentq.r2dbc.domain.QSurvey; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class DeleteBase extends AbstractBaseTest { @@ -37,12 +37,12 @@ private void reset() { insert(survey).values(1, "Hello World", "Hello").execute().block(); } - @Before + @BeforeEach public void setUp() { reset(); } - @After + @AfterEach public void tearDown() { reset(); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DependenciesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DependenciesTest.java index 10eee67e17..3415b64fee 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DependenciesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/DependenciesTest.java @@ -17,13 +17,13 @@ import java.io.IOException; import jdepend.framework.JDepend; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class DependenciesTest { @Test - @Ignore + @Disabled public void test() throws IOException { var jdepend = new JDepend(); jdepend.addDirectory("target/classes/fluentq/r2dbc"); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ExtendedSQLTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ExtendedSQLTest.java index e7faba0207..e8625e590b 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ExtendedSQLTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ExtendedSQLTest.java @@ -12,7 +12,7 @@ import fluentq.sql.ColumnMetadata; import fluentq.sql.RelationalPathBase; import java.time.LocalDate; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExtendedSQLTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ForeignKeyTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ForeignKeyTest.java index 0f10fcfbdc..e72bb948fd 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ForeignKeyTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ForeignKeyTest.java @@ -19,7 +19,7 @@ import fluentq.r2dbc.domain.QEmployee; import fluentq.sql.ForeignKey; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ForeignKeyTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/H2TemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/H2TemplatesTest.java index b784e6d1a9..96e4e1bb6a 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/H2TemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/H2TemplatesTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class H2TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/InsertBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/InsertBase.java index 87d4799793..3078398720 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/InsertBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/InsertBase.java @@ -27,6 +27,7 @@ import static fluentq.r2dbc.Constants.survey; import static fluentq.r2dbc.Constants.survey2; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.QueryException; import fluentq.core.QueryFlag.Position; @@ -46,9 +47,9 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.UUID; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class InsertBase extends AbstractBaseTest { @@ -59,12 +60,12 @@ private void reset() { delete(QDateTest.qDateTest).execute().block(); } - @Before + @BeforeEach public void setUp() { reset(); } - @After + @AfterEach public void tearDown() { reset(); } @@ -182,21 +183,31 @@ public void insert_with_keys_Projected2() { assertThat(id).isNotNull(); } - @Test(expected = QueryException.class) + @Test @IncludeIn({DERBY, HSQLDB}) public void insert_with_keys_OverriddenColumn() { - var originalColumnName = ColumnMetadata.getName(survey.id); - try { - configuration.registerColumnOverride( - survey.getSchemaName(), survey.getTableName(), originalColumnName, "wrongColumnName"); - - var insert = new R2DBCInsertClause(connection, configuration, survey); - Object id = insert.set(survey.name, "Hello you").executeWithKey(survey.id); - assertThat(id).isNotNull(); - } finally { - configuration.registerColumnOverride( - survey.getSchemaName(), survey.getTableName(), originalColumnName, originalColumnName); - } + assertThatThrownBy( + () -> { + var originalColumnName = ColumnMetadata.getName(survey.id); + try { + configuration.registerColumnOverride( + survey.getSchemaName(), + survey.getTableName(), + originalColumnName, + "wrongColumnName"); + + var insert = new R2DBCInsertClause(connection, configuration, survey); + Object id = insert.set(survey.name, "Hello you").executeWithKey(survey.id); + assertThat(id).isNotNull(); + } finally { + configuration.registerColumnOverride( + survey.getSchemaName(), + survey.getTableName(), + originalColumnName, + originalColumnName); + } + }) + .isInstanceOf(QueryException.class); } // http://sourceforge.net/tracker/index.php?func=detail&aid=3513432&group_id=280608&atid=2377440 diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JDBCTypeMappingTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JDBCTypeMappingTest.java index 306df72534..ae4fd7b042 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JDBCTypeMappingTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JDBCTypeMappingTest.java @@ -15,13 +15,12 @@ import static org.assertj.core.api.Assertions.assertThat; -import fluentq.core.testutil.ReportingOnly; import io.r2dbc.spi.Blob; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Types; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class JDBCTypeMappingTest { @@ -83,7 +82,7 @@ public void numericTypes() { } @Test - @Category(ReportingOnly.class) + @Tag("fluentq.core.testutil.ReportingOnly") public void max() { System.err.println("Byte: " + String.valueOf(Byte.MAX_VALUE).length()); System.err.println("Short: " + String.valueOf(Short.MAX_VALUE).length()); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JavaTypeMappingTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JavaTypeMappingTest.java index 3e9e5e98fd..80d809a623 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JavaTypeMappingTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JavaTypeMappingTest.java @@ -28,7 +28,7 @@ import fluentq.r2dbc.types.ShortType; import java.io.FileInputStream; import java.io.InputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JavaTypeMappingTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinFlagsTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinFlagsTest.java index 5e7183553e..9fb536581f 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinFlagsTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinFlagsTest.java @@ -19,8 +19,8 @@ import fluentq.r2dbc.domain.QSurvey; import io.r2dbc.spi.Connection; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JoinFlagsTest { @@ -31,7 +31,7 @@ public class JoinFlagsTest { private R2DBCQuery query; @SuppressWarnings("unchecked") - @Before + @BeforeEach public void setUp() { s1 = new QSurvey("s"); s2 = new QSurvey("s2"); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinUsageTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinUsageTest.java index 70d5e67e66..a632e227f2 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinUsageTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/JoinUsageTest.java @@ -13,16 +13,22 @@ */ package fluentq.r2dbc; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import fluentq.r2dbc.domain.QSurvey; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class JoinUsageTest { - @Test(expected = IllegalStateException.class) - @Ignore + @Test + @Disabled public void join_already_declared() { - var survey = QSurvey.survey; - R2DBCExpressions.selectFrom(survey).fullJoin(survey); + assertThatThrownBy( + () -> { + var survey = QSurvey.survey; + R2DBCExpressions.selectFrom(survey).fullJoin(survey); + }) + .isInstanceOf(IllegalStateException.class); } } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyAccessorsTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyAccessorsTest.java index ea10189b5c..8529d0bbff 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyAccessorsTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyAccessorsTest.java @@ -22,7 +22,7 @@ import fluentq.sql.PrimaryKey; import fluentq.sql.RelationalPathBase; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class KeyAccessorsTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyTest.java index b907b3b876..1eda230de7 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeyTest.java @@ -19,7 +19,7 @@ import fluentq.sql.ForeignKey; import fluentq.sql.PrimaryKey; import fluentq.sql.RelationalPathBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("serial") public class KeyTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeywordQuotingBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeywordQuotingBase.java index 37f5ed17f6..9874ab3cf4 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeywordQuotingBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/KeywordQuotingBase.java @@ -25,9 +25,9 @@ import fluentq.r2dbc.ddl.DropTableClause; import fluentq.sql.ColumnMetadata; import fluentq.sql.RelationalPathBase; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class KeywordQuotingBase extends AbstractBaseTest { @@ -56,7 +56,7 @@ protected void addMetadata() { private final Quoting quoting = Quoting.quoting; - @Before + @BeforeEach public void setUp() throws Exception { new CreateTableClause(connection, configuration, "quoting") .column("from", String.class) @@ -67,7 +67,7 @@ public void setUp() throws Exception { execute(insert(quoting).columns(quoting.from, quoting.all).values("from", true)).block(); } - @After + @AfterEach public void tearDown() throws Exception { new DropTableClause(connection, configuration, "quoting").execute().block(); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/LikeEscapeBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/LikeEscapeBase.java index eb51617fcf..06e43ff517 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/LikeEscapeBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/LikeEscapeBase.java @@ -16,13 +16,13 @@ import static fluentq.r2dbc.Constants.survey; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class LikeEscapeBase extends AbstractBaseTest { - @Before + @BeforeEach public void setUp() { delete(survey).execute().block(); insert(survey) @@ -34,7 +34,7 @@ public void setUp() { .block(); } - @After + @AfterEach public void tearDown() { delete(survey).execute().block(); insert(survey).values(1, "Hello World", "Hello").execute().block(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ListSubQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ListSubQueryTest.java index 02aed6d78e..985f410ca7 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ListSubQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/ListSubQueryTest.java @@ -8,7 +8,7 @@ import fluentq.r2dbc.domain.QSurvey; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ListSubQueryTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MetadataTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MetadataTest.java index 83626f9448..b5df8c5da0 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MetadataTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MetadataTest.java @@ -1,9 +1,9 @@ package fluentq.r2dbc; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class MetadataTest { // H2 diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MultikeyTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MultikeyTest.java index 3a7f30781d..ab01e5fa16 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MultikeyTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MultikeyTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MultikeyTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MySQLTemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MySQLTemplatesTest.java index f5b9041413..0b8b45d9bf 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MySQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/MySQLTemplatesTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MySQLTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PaginationTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PaginationTest.java index 3888ed8284..5e2cceac19 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PaginationTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PaginationTest.java @@ -3,14 +3,13 @@ import fluentq.core.QueryMetadata; import fluentq.core.QueryModifiers; import fluentq.core.support.QueryMixin; -import fluentq.core.testutil.ReportingOnly; import fluentq.r2dbc.domain.QEmployee; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(ReportingOnly.class) +@Tag("fluentq.core.testutil.ReportingOnly") public class PaginationTest { private String serialize(QueryMetadata metadata, SQLTemplates templates) { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PostgreSQLTemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PostgreSQLTemplatesTest.java index dc53af2c8e..2061154550 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PostgreSQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PostgreSQLTemplatesTest.java @@ -18,7 +18,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PostgreSQLTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PrecedenceTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PrecedenceTest.java index cb52f34ae0..41943e62fb 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PrecedenceTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/PrecedenceTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PrecedenceTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBean2Test.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBean2Test.java index 8c9451c2d4..ba086097be 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBean2Test.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBean2Test.java @@ -24,7 +24,7 @@ import fluentq.core.types.dsl.StringPath; import fluentq.sql.ColumnMetadata; import fluentq.sql.RelationalPathBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QBean2Test { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBeanTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBeanTest.java index 5ae09c36f3..19bf0e3539 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBeanTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QBeanTest.java @@ -19,7 +19,7 @@ import fluentq.core.types.Projections; import fluentq.r2dbc.domain.Employee; import fluentq.r2dbc.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QBeanTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QPersonTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QPersonTest.java index b0b3a0ec30..f4dd83a63b 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QPersonTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QPersonTest.java @@ -17,7 +17,7 @@ import fluentq.core.types.Projections; import fluentq.core.types.QBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QPersonTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QueryPerformanceTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QueryPerformanceTest.java index 697a2632b8..158525b9ab 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QueryPerformanceTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/QueryPerformanceTest.java @@ -5,15 +5,13 @@ import fluentq.core.DefaultQueryMetadata; import fluentq.core.JoinType; import fluentq.core.QueryMetadata; -import fluentq.core.testutil.H2; -import fluentq.core.testutil.Performance; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; @@ -23,8 +21,9 @@ import org.openjdk.jmh.runner.options.TimeValue; import reactor.core.publisher.Mono; -@Category({H2.class, Performance.class}) -@Ignore( +@Tag("fluentq.core.testutil.H2") +@Tag("fluentq.core.testutil.Performance") +@Disabled( """ currently R2DBC has known READ performance issues - also there is a bug in the tests\ somewhere\ @@ -42,7 +41,7 @@ public class QueryPerformanceTest { private static final Configuration conf = new Configuration(templates); - @BeforeClass + @BeforeAll public static void setUpClass() { Connections.initH2(); var conn = Connections.getConnection(); @@ -61,7 +60,7 @@ public static void setUpClass() { conn.setAutoCommit(false); } - @AfterClass + @AfterAll public static void tearDownClass() { var conn = Connections.getConnection(); var stmt = conn.createStatement("drop table companies"); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryFactoryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryFactoryTest.java index 77f9662f93..db60e37aa1 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryFactoryTest.java @@ -18,15 +18,15 @@ import fluentq.r2dbc.domain.QSurvey; import io.r2dbc.spi.Connection; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; public class R2DBCQueryFactoryTest { private R2DBCQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { R2DBCConnectionProvider provider = () -> Mono.just(EasyMock.createNiceMock(Connection.class)); queryFactory = new R2DBCQueryFactory(SQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryTest.java index 8d6ab2738d..35d248d0f8 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCQueryTest.java @@ -1,13 +1,19 @@ package fluentq.r2dbc; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import fluentq.r2dbc.domain.QSurvey; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class R2DBCQueryTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var survey = QSurvey.survey; - R2DBCExpressions.select(survey.id).from(survey).fetch().collectList().block(); + assertThatThrownBy( + () -> { + var survey = QSurvey.survey; + R2DBCExpressions.select(survey.id).from(survey).fetch().collectList().block(); + }) + .isInstanceOf(IllegalStateException.class); } } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCRelationalFunctionCallTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCRelationalFunctionCallTest.java index dfac807884..c974306e6d 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCRelationalFunctionCallTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/R2DBCRelationalFunctionCallTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.dsl.PathBuilder; import fluentq.core.types.dsl.StringPath; import fluentq.sql.RelationalFunctionCall; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class R2DBCRelationalFunctionCallTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathExtractorTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathExtractorTest.java index 96382fbba6..31d6e8c38c 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathExtractorTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathExtractorTest.java @@ -7,7 +7,7 @@ import fluentq.core.types.dsl.Expressions; import fluentq.r2dbc.domain.QEmployee; import fluentq.sql.RelationalPathExtractor; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationalPathExtractorTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathTest.java index 72b4d6813b..4eb5e89319 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/RelationalPathTest.java @@ -7,7 +7,7 @@ import fluentq.r2dbc.domain.QSurvey; import java.io.IOException; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationalPathTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLBindingsTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLBindingsTest.java index ce417e497d..36b31f2c30 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLBindingsTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLBindingsTest.java @@ -5,7 +5,7 @@ import fluentq.core.types.dsl.Param; import fluentq.r2dbc.domain.QSurvey; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLBindingsTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSerializerTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSerializerTest.java index 26b7482f52..c7c8bc196c 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSerializerTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSerializerTest.java @@ -37,7 +37,7 @@ import java.util.List; import java.util.TimeZone; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLSerializerTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2005TemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2005TemplatesTest.java index ae9473b30a..dad95424e2 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2005TemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2005TemplatesTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; import fluentq.sql.SQLOps; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServer2005TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2012TemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2012TemplatesTest.java index c676173905..106ca83407 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2012TemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServer2012TemplatesTest.java @@ -23,7 +23,7 @@ import fluentq.r2dbc.dml.R2DBCDeleteClause; import fluentq.r2dbc.dml.R2DBCUpdateClause; import fluentq.sql.SQLOps; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServer2012TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServerTemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServerTemplatesTest.java index ac876a6eab..cc0a399b5b 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServerTemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLServerTemplatesTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; import fluentq.sql.SQLOps; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServerTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSubQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSubQueryTest.java index f6e7f4217a..ce0b066f04 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSubQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLSubQueryTest.java @@ -14,6 +14,7 @@ package fluentq.r2dbc; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.core.types.ConstantImpl; import fluentq.core.types.Expression; @@ -26,33 +27,37 @@ import fluentq.r2dbc.domain.QEmployee; import fluentq.r2dbc.domain.QSurvey; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLSubQueryTest { private static final QEmployee employee = QEmployee.employee; - @Test(expected = IllegalArgumentException.class) + @Test public void unknownOperator() { - Operator op = - new Operator() { - @Override - public String name() { - return "unknownfn"; - } - - @Override - public String toString() { - return name(); - } - - @Override - public Class getType() { - return Object.class; - } - }; - R2DBCQuery query = new R2DBCQuery(); - query.from(employee).where(Expressions.booleanOperation(op, employee.id)).toString(); + assertThatThrownBy( + () -> { + Operator op = + new Operator() { + @Override + public String name() { + return "unknownfn"; + } + + @Override + public String toString() { + return name(); + } + + @Override + public Class getType() { + return Object.class; + } + }; + R2DBCQuery query = new R2DBCQuery(); + query.from(employee).where(Expressions.booleanOperation(op, employee.id)).toString(); + }) + .isInstanceOf(IllegalArgumentException.class); } @SuppressWarnings("unchecked") diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTemplatesTest.java index bf7ba4195b..063c582391 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTemplatesTest.java @@ -29,7 +29,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTypeMappingTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTypeMappingTest.java index 84b93808a4..26fbb7f449 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTypeMappingTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SQLTypeMappingTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.fail; import java.lang.reflect.Field; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLTypeMappingTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SchemaAndTableTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SchemaAndTableTest.java index af490a07b5..2d9fef1d36 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SchemaAndTableTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SchemaAndTableTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.sql.SchemaAndTable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SchemaAndTableTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectBase.java index 6f3016a548..568e70ef0b 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectBase.java @@ -33,6 +33,7 @@ import static fluentq.r2dbc.Constants.survey2; import static fluentq.r2dbc.Constants.time; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -100,8 +101,8 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class SelectBase extends AbstractBaseTest { @@ -303,7 +304,7 @@ public void array2() { @Test @ExcludeIn({DERBY, HSQLDB}) - @Ignore("currently not supported by drivers") + @Disabled("currently not supported by drivers") public void array_null() { Expression expr = Expressions.template(Integer[].class, "null"); assertThat(firstResult(expr)).isNull(); @@ -676,7 +677,7 @@ public void dates() { } @Test - @Ignore // FIXME + @Disabled // FIXME @ExcludeIn({CUBRID, DB2, DERBY, HSQLDB, POSTGRESQL, SQLITE, TERADATA}) public void dates_cST() { var tz = TimeZone.getDefault(); @@ -689,7 +690,7 @@ public void dates_cST() { } @Test - @Ignore // FIXME + @Disabled // FIXME @ExcludeIn({CUBRID, DB2, DERBY, HSQLDB, POSTGRESQL, SQLITE, TERADATA}) public void dates_iOT() { var tz = TimeZone.getDefault(); @@ -1100,11 +1101,16 @@ public void groupBy_validate() { } @SuppressWarnings("unchecked") - @Test(expected = IllegalArgumentException.class) + @Test public void illegalUnion() { - SubQueryExpression sq1 = query().from(employee).select(employee.id.max()); - SubQueryExpression sq2 = query().from(employee).select(employee.id.max()); - assertEquals(0, query().from(employee).union(sq1, sq2).fetch().collectList().block().size()); + assertThatThrownBy( + () -> { + SubQueryExpression sq1 = query().from(employee).select(employee.id.max()); + SubQueryExpression sq2 = query().from(employee).select(employee.id.max()); + assertEquals( + 0, query().from(employee).union(sq1, sq2).fetch().collectList().block().size()); + }) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -1668,7 +1674,7 @@ public void number_as_boolean() { } @Test - @Ignore("not valid as streams cannot have nulls") + @Disabled("not valid as streams cannot have nulls") public void number_as_boolean_Null() { var numberTest = QNumberTest.numberTest; delete(numberTest).execute().block(); @@ -1790,17 +1796,21 @@ public void params_anon() { .block()); } - @Test(expected = ParamNotSetException.class) + @Test public void params_not_set() { - var name = new Param(String.class, "name"); - assertEquals( - "Mike", - query() - .from(employee) - .where(employee.firstname.eq(name)) - .select(employee.firstname) - .fetchFirst() - .block()); + assertThatThrownBy( + () -> { + var name = new Param(String.class, "name"); + assertEquals( + "Mike", + query() + .from(employee) + .where(employee.firstname.eq(name)) + .select(employee.firstname) + .fetchFirst() + .block()); + }) + .isInstanceOf(ParamNotSetException.class); } @Test @@ -2049,7 +2059,7 @@ public void rpad() { } @Test - @Ignore + @Disabled @ExcludeIn({ORACLE, DERBY, SQLSERVER}) public void select_booleanExpr() { // TODO : FIXME @@ -2057,7 +2067,7 @@ public void select_booleanExpr() { } @Test - @Ignore + @Disabled @ExcludeIn({ORACLE, DERBY, SQLSERVER}) public void select_booleanExpr2() { // TODO : FIXME @@ -2518,10 +2528,14 @@ public void unique_wildcard() { assertThat(row.get(1, Object.class)).as(row.get(0, Object.class) + " is not null").isNotNull(); } - @Ignore("we select the first result if one selected") - @Test(expected = NonUniqueResultException.class) + @Disabled("we select the first result if one selected") + @Test public void uniqueResultContract() { - query().from(employee).select(employee.all()).fetchOne().block(); + assertThatThrownBy( + () -> { + query().from(employee).select(employee.all()).fetchOne().block(); + }) + .isInstanceOf(NonUniqueResultException.class); } @Test diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectMySQLBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectMySQLBase.java index 90884f7246..d3b4fd6515 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectMySQLBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectMySQLBase.java @@ -5,7 +5,7 @@ import fluentq.core.testutil.IncludeIn; import fluentq.r2dbc.mysql.R2DBCMySQLQuery; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SelectMySQLBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectWindowFunctionsBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectWindowFunctionsBase.java index df9364acbe..fddce7ff05 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectWindowFunctionsBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SelectWindowFunctionsBase.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SelectWindowFunctionsBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SerializationTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SerializationTest.java index 550015413c..672b241561 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SerializationTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SerializationTest.java @@ -26,7 +26,7 @@ import fluentq.r2dbc.domain.QSurvey; import io.r2dbc.spi.Connection; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SerializationTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SkipForQuotedExtension.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SkipForQuotedExtension.java new file mode 100644 index 0000000000..60a45c2b12 --- /dev/null +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SkipForQuotedExtension.java @@ -0,0 +1,30 @@ +package fluentq.r2dbc; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit 5 replacement for the former {@code SkipForQuotedRule}. Disables test methods annotated + * with {@link SkipForQuoted} when the active configuration uses quoting, schema printing or + * literals. + */ +public class SkipForQuotedExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + var testMethod = context.getTestMethod().orElse(null); + if (testMethod == null || !testMethod.isAnnotationPresent(SkipForQuoted.class)) { + return ConditionEvaluationResult.enabled("No @SkipForQuoted"); + } + var configuration = Connections.getConfiguration(); + if (configuration == null) { + return ConditionEvaluationResult.enabled("No configuration"); + } + var templates = configuration.getTemplates(); + if (templates.isUseQuotes() || templates.isPrintSchema() || configuration.getUseLiterals()) { + return ConditionEvaluationResult.disabled("Skipped for quoted templates"); + } + return ConditionEvaluationResult.enabled("Not quoted"); + } +} diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SkipForQuotedRule.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SkipForQuotedRule.java deleted file mode 100644 index 6bc48c783f..0000000000 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SkipForQuotedRule.java +++ /dev/null @@ -1,26 +0,0 @@ -package fluentq.r2dbc; - -import fluentq.core.testutil.EmptyStatement; -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - -public class SkipForQuotedRule implements MethodRule { - - private final Configuration configuration; - - public SkipForQuotedRule(Configuration conf) { - this.configuration = conf; - } - - @Override - public Statement apply(Statement base, FrameworkMethod method, Object target) { - var templates = configuration.getTemplates(); - if (templates.isUseQuotes() || templates.isPrintSchema() || configuration.getUseLiterals()) { - var skip = method.getMethod().isAnnotationPresent(SkipForQuoted.class); - return skip ? EmptyStatement.DEFAULT : base; - } else { - return base; - } - } -} diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SubqueriesBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SubqueriesBase.java index 066be2e431..33720ed582 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SubqueriesBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/SubqueriesBase.java @@ -29,7 +29,7 @@ import fluentq.sql.ForeignKey; import java.math.BigDecimal; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SubqueriesBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TargetExtension.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TargetExtension.java new file mode 100644 index 0000000000..2857fa250d --- /dev/null +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TargetExtension.java @@ -0,0 +1,39 @@ +package fluentq.r2dbc; + +import fluentq.core.Target; +import fluentq.core.testutil.ExcludeIn; +import fluentq.core.testutil.IncludeIn; +import java.util.Arrays; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit 5 replacement for the former {@code TargetRule}. Disables a test (or container) when the + * configured {@link Target} is excluded via {@link ExcludeIn} or not part of {@link IncludeIn}. + */ +public class TargetExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + var target = Connections.getTarget(); + if (target == null) { + return ConditionEvaluationResult.enabled("No target configured"); + } + var element = context.getElement().orElse(null); + if (element == null) { + return ConditionEvaluationResult.enabled("No annotated element"); + } + // excluded in given targets + var ex = element.getAnnotation(ExcludeIn.class); + if (ex != null && Arrays.asList(ex.value()).contains(target)) { + return ConditionEvaluationResult.disabled("Excluded in target " + target); + } + // included only in given targets + var in = element.getAnnotation(IncludeIn.class); + if (in != null && !Arrays.asList(in.value()).contains(target)) { + return ConditionEvaluationResult.disabled("Not included in target " + target); + } + return ConditionEvaluationResult.enabled("Enabled for target " + target); + } +} diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TargetRule.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TargetRule.java deleted file mode 100644 index 93964ee3b5..0000000000 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TargetRule.java +++ /dev/null @@ -1,31 +0,0 @@ -package fluentq.r2dbc; - -import fluentq.core.Target; -import fluentq.core.testutil.EmptyStatement; -import fluentq.core.testutil.ExcludeIn; -import fluentq.core.testutil.IncludeIn; -import java.util.Arrays; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class TargetRule implements TestRule { - - @Override - public Statement apply(Statement base, Description description) { - var target = Connections.getTarget(); - var run = target == null || isExecuted(description, target); - return run ? base : EmptyStatement.DEFAULT; - } - - private boolean isExecuted(Description description, Target target) { - var ex = description.getAnnotation(ExcludeIn.class); - // excluded in given targets - if (ex != null && Arrays.asList(ex.value()).contains(target)) { - return false; - } - // included only in given targets - var in = description.getAnnotation(IncludeIn.class); - return in == null || Arrays.asList(in.value()).contains(target); - } -} diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplateTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplateTest.java index aff5ad53e8..caff8231d6 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplateTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplateTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.StringExpression; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TemplateTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplatesTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplatesTest.java index eca9738996..115be9554b 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplatesTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TemplatesTest.java @@ -14,7 +14,7 @@ package fluentq.r2dbc; import fluentq.core.TemplatesTestBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TemplatesTest extends TemplatesTestBase { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TypesBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TypesBase.java index ed20e8842b..1bc436e634 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TypesBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/TypesBase.java @@ -10,7 +10,7 @@ import java.math.BigInteger; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class TypesBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionBase.java index c40ff9851b..b37fab02b2 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionBase.java @@ -19,8 +19,8 @@ import fluentq.r2dbc.domain.QEmployee; import java.io.IOException; import java.util.Arrays; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class UnionBase extends AbstractBaseTest { @@ -180,7 +180,7 @@ public void union4() { @SuppressWarnings("unchecked") @Test @ExcludeIn({DERBY, CUBRID, FIREBIRD, TERADATA}) - @Ignore // FIXME + @Disabled // FIXME public void union5() { /* (select e.ID, e.FIRSTNAME, superior.ID as sup_id, superior.FIRSTNAME as sup_name * from EMPLOYEE e join EMPLOYEE superior on e.SUPERIOR_ID = superior.ID) diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionSubQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionSubQueryTest.java index e237a0531d..c36e14905d 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionSubQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UnionSubQueryTest.java @@ -20,7 +20,7 @@ import fluentq.core.types.dsl.NumberPath; import fluentq.core.types.dsl.SimpleExpression; import fluentq.core.types.dsl.SimplePath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UnionSubQueryTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UpdateBase.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UpdateBase.java index c8dd806e96..8cd96a4db3 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UpdateBase.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/UpdateBase.java @@ -32,9 +32,9 @@ import fluentq.r2dbc.domain.QSurvey; import java.util.Collections; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class UpdateBase extends AbstractBaseTest { @@ -43,12 +43,12 @@ protected void reset() { insert(survey).values(1, "Hello World", "Hello").execute().block(); } - @Before + @BeforeEach public void setUp() { reset(); } - @After + @AfterEach public void tearDown() { reset(); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WindowFunctionTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WindowFunctionTest.java index ccbc3dd8d3..e7dba1ffeb 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WindowFunctionTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WindowFunctionTest.java @@ -5,7 +5,7 @@ import fluentq.core.types.Expression; import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.NumberPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class WindowFunctionTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WithinGroupTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WithinGroupTest.java index 5696c0b7eb..650dbf628a 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WithinGroupTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/WithinGroupTest.java @@ -5,7 +5,7 @@ import fluentq.core.types.Expression; import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.NumberPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class WithinGroupTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AbstractMapperTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AbstractMapperTest.java index 016fdccb60..85b88fa112 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AbstractMapperTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AbstractMapperTest.java @@ -18,7 +18,7 @@ import java.math.BigDecimal; import java.sql.Date; import java.sql.Time; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public abstract class AbstractMapperTest { @@ -49,7 +49,7 @@ public static class EmployeeNames { protected Employee employee; - @Before + @BeforeEach public void setUp() { employee = new Employee(); employee.setDatefield(new Date(0)); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AnnotationMapperTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AnnotationMapperTest.java index 03e8a53d23..dc45495509 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AnnotationMapperTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/AnnotationMapperTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.r2dbc.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnnotationMapperTest extends AbstractMapperTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/BeanMapperTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/BeanMapperTest.java index 74c7b98970..0f5ee92c75 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/BeanMapperTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/BeanMapperTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.r2dbc.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BeanMapperTest extends AbstractMapperTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCDeleteClauseTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCDeleteClauseTest.java index 1261a1e938..aa8fc50d4c 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCDeleteClauseTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCDeleteClauseTest.java @@ -1,30 +1,39 @@ package fluentq.r2dbc.dml; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.r2dbc.KeyAccessorsTest.QEmployee; import fluentq.r2dbc.SQLTemplates; import java.util.Collections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class R2DBCDeleteClauseTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var emp1 = new QEmployee("emp1"); - var delete = new R2DBCDeleteClause(null, SQLTemplates.DEFAULT, emp1); - delete.where(emp1.id.eq(1)); - delete.execute().block(); + assertThatThrownBy( + () -> { + var emp1 = new QEmployee("emp1"); + var delete = new R2DBCDeleteClause(null, SQLTemplates.DEFAULT, emp1); + delete.where(emp1.id.eq(1)); + delete.execute().block(); + }) + .isInstanceOf(IllegalStateException.class); } - @Test(expected = IllegalArgumentException.class) - @Ignore + @Test + @Disabled public void error() { - var emp1 = new QEmployee("emp1"); - var emp2 = new QEmployee("emp2"); - var delete = new R2DBCDeleteClause(null, SQLTemplates.DEFAULT, emp1); - delete.where(emp2.id.eq(1)); + assertThatThrownBy( + () -> { + var emp1 = new QEmployee("emp1"); + var emp2 = new QEmployee("emp2"); + var delete = new R2DBCDeleteClause(null, SQLTemplates.DEFAULT, emp1); + delete.where(emp2.id.eq(1)); + }) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCInsertClauseTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCInsertClauseTest.java index 79eeab40cb..dacc9ce1f5 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCInsertClauseTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCInsertClauseTest.java @@ -1,20 +1,25 @@ package fluentq.r2dbc.dml; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.r2dbc.KeyAccessorsTest.QEmployee; import fluentq.r2dbc.SQLTemplates; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class R2DBCInsertClauseTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var emp1 = new QEmployee("emp1"); - var insert = new R2DBCInsertClause(null, SQLTemplates.DEFAULT, emp1); - insert.set(emp1.id, 1); - insert.execute().block(); + assertThatThrownBy( + () -> { + var emp1 = new QEmployee("emp1"); + var insert = new R2DBCInsertClause(null, SQLTemplates.DEFAULT, emp1); + insert.set(emp1.id, 1); + insert.execute().block(); + }) + .isInstanceOf(IllegalStateException.class); } @Test diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCUpdateClauseTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCUpdateClauseTest.java index ed870796df..61ceeaf898 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCUpdateClauseTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/dml/R2DBCUpdateClauseTest.java @@ -1,21 +1,26 @@ package fluentq.r2dbc.dml; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.r2dbc.KeyAccessorsTest.QEmployee; import fluentq.r2dbc.R2DBCExpressions; import fluentq.r2dbc.SQLTemplates; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class R2DBCUpdateClauseTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var emp1 = new QEmployee("emp1"); - var update = new R2DBCUpdateClause(null, SQLTemplates.DEFAULT, emp1); - update.set(emp1.id, 1); - update.execute().block(); + assertThatThrownBy( + () -> { + var emp1 = new QEmployee("emp1"); + var update = new R2DBCUpdateClause(null, SQLTemplates.DEFAULT, emp1); + update.set(emp1.id, 1); + update.execute().block(); + }) + .isInstanceOf(IllegalStateException.class); } @Test diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/GeneratedKeysH2Test.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/GeneratedKeysH2Test.java index 3c6a8eda50..9d3984f904 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/GeneratedKeysH2Test.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/GeneratedKeysH2Test.java @@ -22,22 +22,22 @@ import io.r2dbc.spi.Connection; import java.util.Collection; import java.util.Collections; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; public class GeneratedKeysH2Test { private Connection conn; - @Before + @BeforeEach public void setUp() { conn = Connections.getH2().getConnection().block(); } @Test - @Ignore("currently not supported") + @Disabled("currently not supported") public void test() { Mono.from(conn.createStatement("drop table GENERATED_KEYS if exists").execute()).block(); Mono.from( diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/H2QueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/H2QueryTest.java index 6aaef1bdb0..943a0d9cd5 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/H2QueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/h2/H2QueryTest.java @@ -3,8 +3,8 @@ import fluentq.r2dbc.H2Templates; import fluentq.r2dbc.R2DBCQuery; import fluentq.r2dbc.domain.QSurvey; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class H2QueryTest { @@ -12,7 +12,7 @@ public class H2QueryTest { private QSurvey survey = new QSurvey("survey"); - @Before + @BeforeEach public void setUp() { query = new R2DBCQuery(H2Templates.builder().newLineToSingleSpace().build()); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/SQLServerQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/SQLServerQueryTest.java index 71d8db129e..3b23b1ebbb 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/SQLServerQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/SQLServerQueryTest.java @@ -18,7 +18,7 @@ import fluentq.r2dbc.SQLServerTemplates; import fluentq.r2dbc.domain.QEmployee; import fluentq.r2dbc.domain.QSurvey; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServerQueryTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/WindowFunctionTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/WindowFunctionTest.java index 2b3e93f095..6642adc62a 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/WindowFunctionTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mssql/WindowFunctionTest.java @@ -21,7 +21,7 @@ import fluentq.r2dbc.R2DBCExpressions; import fluentq.r2dbc.SQLSerializer; import fluentq.r2dbc.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class WindowFunctionTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/GeneratedKeysMySQLTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/GeneratedKeysMySQLTest.java index eab1402610..7081da42de 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/GeneratedKeysMySQLTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/GeneratedKeysMySQLTest.java @@ -15,7 +15,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import fluentq.core.testutil.MySQL; import fluentq.r2dbc.Connections; import fluentq.r2dbc.H2Templates; import fluentq.r2dbc.QGeneratedKeysEntity; @@ -23,24 +22,24 @@ import io.r2dbc.spi.Connection; import java.util.Collection; import java.util.Collections; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class GeneratedKeysMySQLTest { private Connection conn; - @Before + @BeforeEach public void setUp() { conn = Connections.getMySQL().getConnection().block(); } @Test - @Ignore("currently not supported") + @Disabled("currently not supported") public void test() { Mono.from(conn.createStatement("drop table if exists GENERATED_KEYS").execute()).block(); Mono.from( diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/MyR2DBCQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/MyR2DBCQueryTest.java index db42641dd5..99e9587cec 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/MyR2DBCQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/MyR2DBCQueryTest.java @@ -18,15 +18,15 @@ import fluentq.r2dbc.MySQLTemplates; import fluentq.r2dbc.domain.QSurvey; import java.io.File; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MyR2DBCQueryTest { private R2DBCMySQLQuery query; private QSurvey survey = new QSurvey("survey"); - @Before + @BeforeEach public void setUp() { query = new R2DBCMySQLQuery(null, MySQLTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/R2DBCMySQLQueryFactoryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/R2DBCMySQLQueryFactoryTest.java index 43eef6f0fb..c50e734d0a 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/R2DBCMySQLQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/mysql/R2DBCMySQLQueryFactoryTest.java @@ -21,15 +21,15 @@ import fluentq.r2dbc.domain.QSurvey; import io.r2dbc.spi.Connection; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; public class R2DBCMySQLQueryFactoryTest { private R2DBCMySQLQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { R2DBCConnectionProvider provider = () -> Mono.just(EasyMock.createNiceMock(Connection.class)); queryFactory = new R2DBCMySQLQueryFactory(SQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryFactoryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryFactoryTest.java index d74b1ad948..80ff3eb25e 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryFactoryTest.java @@ -20,15 +20,15 @@ import fluentq.r2dbc.domain.QSurvey; import io.r2dbc.spi.Connection; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; public class R2DBCPostgreQueryFactoryTest { private R2DBCPostgreQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { R2DBCConnectionProvider provider = new R2DBCConnectionProvider() { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryTest.java index 54cf2fb261..6fa8201fd5 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/postgresql/R2DBCPostgreQueryTest.java @@ -5,8 +5,8 @@ import fluentq.r2dbc.PostgreSQLTemplates; import fluentq.r2dbc.domain.QEmployee; import fluentq.r2dbc.domain.QSurvey; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class R2DBCPostgreQueryTest { @@ -16,7 +16,7 @@ public class R2DBCPostgreQueryTest { private QEmployee employee = new QEmployee("employee"); - @Before + @BeforeEach public void setUp() { query = new R2DBCPostgreQuery( diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/AbstractSuite.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/AbstractSuite.java index 7b0078fbb4..b2a4cc39c7 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/AbstractSuite.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/AbstractSuite.java @@ -1,7 +1,3 @@ package fluentq.r2dbc.suites; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; - -@RunWith(Enclosed.class) public abstract class AbstractSuite {} diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2ExceptionSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2ExceptionSuiteTest.java index 533ec80aef..c3e5141f09 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2ExceptionSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2ExceptionSuiteTest.java @@ -3,25 +3,24 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.common.base.Throwables; -import fluentq.core.testutil.H2; import fluentq.r2dbc.AbstractBaseTest; import fluentq.r2dbc.Connections; import fluentq.r2dbc.H2Templates; import fluentq.sql.DefaultSQLExceptionTranslator; import fluentq.sql.SQLExceptionTranslator; import java.sql.SQLException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2ExceptionSuiteTest extends AbstractBaseTest { private static final SQLExceptionTranslator exceptionTranslator = DefaultSQLExceptionTranslator.DEFAULT; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(H2Templates.builder().build()); Connections.initH2(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2LiteralsSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2LiteralsSuiteTest.java index c7565579d9..4426de6b07 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2LiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2LiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.H2; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -13,33 +12,44 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2LiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(H2Templates.builder().newLineToSingleSpace().build()); Connections.getConfiguration().setUseLiterals(true); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2SuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2SuiteTest.java index a03c04ad15..be53219745 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2SuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2SuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.H2; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -13,33 +12,44 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2SuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(H2Templates.builder().newLineToSingleSpace().build()); Connections.initH2(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithQuotingTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithQuotingTest.java index a290f825ce..b85f2bb33c 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithQuotingTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithQuotingTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.H2; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -12,31 +11,41 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2WithQuotingTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(H2Templates.builder().quote().newLineToSingleSpace().build()); Connections.initH2(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithSchemaTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithSchemaTest.java index 502544194f..0cff937637 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithSchemaTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/H2WithSchemaTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.H2; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -13,33 +12,44 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2WithSchemaTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration( H2Templates.builder().printSchema().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLLiteralsSuiteTest.java index 4784224ed4..1bd5c27812 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.SQLServer; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(SQLServer2008Templates.builder().newLineToSingleSpace().build()); Connections.getConfiguration().setUseLiterals(true); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLSuiteTest.java index 19db77c6a8..3790ac77d2 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MSSQLSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.SQLServer; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(SQLServer2008Templates.builder().newLineToSingleSpace().build()); Connections.initSQLServer(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLLiteralsSuiteTest.java index 978c64d3c1..81715f834b 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.MySQL; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectMySQL extends SelectMySQLBase {} + @Nested + class SelectMySQL extends SelectMySQLBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(MySQLTemplates.builder().newLineToSingleSpace().build()); Connections.getConfiguration().setUseLiterals(true); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLSuiteTest.java index 7767cf580a..77ffdef87d 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.MySQL; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectMySQL extends SelectMySQLBase {} + @Nested + class SelectMySQL extends SelectMySQLBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(MySQLTemplates.builder().newLineToSingleSpace().build()); Connections.initMySQL(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLWithQuotingTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLWithQuotingTest.java index 45b3b446b3..1a36fbff58 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLWithQuotingTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/MySQLWithQuotingTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.MySQL; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Connections; import fluentq.r2dbc.DeleteBase; @@ -13,33 +12,44 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLWithQuotingTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration(MySQLTemplates.builder().quote().newLineToSingleSpace().build()); Connections.initMySQL(); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLLiteralsSuiteTest.java index 040b14e56e..8aeaf3b780 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.PostgreSQL; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Configuration; import fluentq.r2dbc.Connections; @@ -15,20 +14,25 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; // TODO r2dbc-postgres drops some inserts, readd after fix -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public abstract class PostgreSQLLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase { + @Nested + class KeywordQuoting extends KeywordQuotingBase { private Configuration previous; @@ -49,21 +53,28 @@ public void tearDown() throws Exception { } } - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration( PostgreSQLTemplates.builder().quote().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLSuiteTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLSuiteTest.java index 614e64cedd..b27da9cc9f 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/suites/PostgreSQLSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.r2dbc.suites; -import fluentq.core.testutil.PostgreSQL; import fluentq.r2dbc.BeanPopulationBase; import fluentq.r2dbc.Configuration; import fluentq.r2dbc.Connections; @@ -15,20 +14,25 @@ import fluentq.r2dbc.TypesBase; import fluentq.r2dbc.UnionBase; import fluentq.r2dbc.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; // TODO r2dbc-postgres drops some inserts, readd after fix -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public abstract class PostgreSQLSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase { + @Nested + class KeywordQuoting extends KeywordQuotingBase { private Configuration previous; @@ -49,21 +53,28 @@ public void tearDown() throws Exception { } } - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initConfiguration( PostgreSQLTemplates.builder().quote().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/AbstractJSR310DateTimeTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/AbstractJSR310DateTimeTypeTest.java index 37e8141267..27606953ee 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/AbstractJSR310DateTimeTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/AbstractJSR310DateTimeTypeTest.java @@ -3,9 +3,9 @@ import java.time.temporal.Temporal; import java.util.Calendar; import java.util.TimeZone; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class AbstractJSR310DateTimeTypeTest { @@ -23,12 +23,12 @@ public AbstractJSR310DateTimeTypeTest(AbstractJSR310DateTimeType type) { private TimeZone tz; - @Before + @BeforeEach public void before() { tz = TimeZone.getDefault(); } - @After + @AfterEach public void after() { TimeZone.setDefault(tz); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310InstantTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310InstantTypeTest.java index a3d6bdbc47..5bd630ba87 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310InstantTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310InstantTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.Instant; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310InstantTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTimeTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTimeTypeTest.java index 7cae9c30a0..bef7e8ef72 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTimeTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTimeTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.LocalDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310LocalDateTimeTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTypeTest.java index 679db70b0b..161632bebe 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalDateTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.LocalDate; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310LocalDateTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalTimeTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalTimeTypeTest.java index b8b84dc35b..f2384ca46a 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalTimeTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310LocalTimeTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.LocalTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310LocalTimeTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetDateTimeTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetDateTimeTypeTest.java index 748b8f6f5d..f496e0f67d 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetDateTimeTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetDateTimeTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.OffsetDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310OffsetDateTimeTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetTimeTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetTimeTypeTest.java index dde0b5e077..e5e9d96197 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetTimeTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310OffsetTimeTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.OffsetTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310OffsetTimeTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310ZonedDateTimeTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310ZonedDateTimeTypeTest.java index c51727e226..7efe6635ea 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310ZonedDateTimeTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/JSR310ZonedDateTimeTypeTest.java @@ -1,7 +1,7 @@ package fluentq.r2dbc.types; import java.time.ZonedDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310ZonedDateTimeTypeTest extends AbstractJSR310DateTimeTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocalDateTimeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocalDateTimeTest.java index 07a491978f..5186caa405 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocalDateTimeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocalDateTimeTest.java @@ -2,8 +2,8 @@ import java.util.Calendar; import java.util.TimeZone; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class LocalDateTimeTest { @@ -11,7 +11,7 @@ public class LocalDateTimeTest { // private LocalDateTimeType type = new LocalDateTimeType(); - @BeforeClass + @BeforeAll public static void setUpClass() { UTC.setTimeInMillis(0); } diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocaleTypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocaleTypeTest.java index aa6747a65f..0aa8960459 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocaleTypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/LocaleTypeTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LocaleTypeTest { diff --git a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/TypeTest.java b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/TypeTest.java index dcc6382b38..b9bd17a6be 100644 --- a/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/TypeTest.java +++ b/fluentq-libraries/fluentq-r2dbc/src/test/java/fluentq/r2dbc/types/TypeTest.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.UUID; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeTest implements InvocationHandler { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/CaseClassSerializerTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/CaseClassSerializerTest.scala index 1af1523956..b4a9b769b9 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/CaseClassSerializerTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/CaseClassSerializerTest.scala @@ -4,7 +4,7 @@ import java.io.StringWriter import fluentq.codegen.utils._ import fluentq.codegen._ -import org.junit._ +import org.junit.jupiter.api._ class CaseClassSerializerTest { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ExpressionTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ExpressionTest.scala index e317d3ab22..b81ef947c9 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ExpressionTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ExpressionTest.scala @@ -2,14 +2,14 @@ package fluentq.scala import fluentq.core.types._ import fluentq.scala.Matchers._ -import org.junit.{Assert, Test} +import org.junit.jupiter.api.{Assertions, Test} class ExpressionTest { val person = Person as "person" def assertEquals(expected: String, actual: Any): Unit = { - Assert.assertEquals(expected, actual.toString) + Assertions.assertEquals(expected, actual.toString) } @Test diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterJPATest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterJPATest.scala index 3d8e80823f..b9da6a9415 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterJPATest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterJPATest.scala @@ -3,7 +3,7 @@ package fluentq.scala import jakarta.persistence._ import fluentq.codegen.GenericExporter -import org.junit.Test +import org.junit.jupiter.api.Test class GenericExporterJPATest { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterTest.scala index f0d7604c7e..d34c0ba61f 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/GenericExporterTest.scala @@ -3,7 +3,7 @@ package fluentq.scala import java.io.File import fluentq.codegen.GenericExporter -import org.junit.Test +import org.junit.jupiter.api.Test class GenericExporterTest { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/QPersonTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/QPersonTest.scala index e5ac5465eb..cafa4333ba 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/QPersonTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/QPersonTest.scala @@ -1,6 +1,6 @@ package fluentq.scala -import org.junit.{Assert, Test} +import org.junit.jupiter.api.{Assertions, Test} class QPersonTest { @@ -28,7 +28,7 @@ class QPersonTest { } def assertEquals(expected: String, actual: Any): Unit = { - Assert.assertEquals(expected, actual.toString) + Assertions.assertEquals(expected, actual.toString) } } \ No newline at end of file diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ReflectionUtilsTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ReflectionUtilsTest.scala index 71c8e39617..70bdb2ca1d 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ReflectionUtilsTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ReflectionUtilsTest.scala @@ -1,7 +1,7 @@ package fluentq.scala -import org.junit.Assert._ -import org.junit._ +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api._ class ReflectionUtilsTest { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaBeanSerializerTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaBeanSerializerTest.scala index cb556de86e..f5245ac990 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaBeanSerializerTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaBeanSerializerTest.scala @@ -4,8 +4,8 @@ import java.io.StringWriter import fluentq.codegen.utils._ import fluentq.codegen._ -import org.junit.Assert._ -import org.junit._ +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api._ class ScalaBeanSerializerTest { @@ -47,7 +47,7 @@ class ScalaBeanSerializerTest { //println(str) toMatch.split("\\n").map(_.trim).foreach { line => - assertTrue(line, str.contains(line)) + assertTrue(str.contains(line), line) } } diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaEntitySerializerTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaEntitySerializerTest.scala index 4cac384069..0ee4d404a2 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaEntitySerializerTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/ScalaEntitySerializerTest.scala @@ -5,8 +5,8 @@ import java.io.StringWriter import fluentq.codegen.utils._ import fluentq.codegen.utils.model._ import fluentq.codegen._ -import org.junit.Assert._ -import org.junit.{Before, Test} +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api.{BeforeEach, Test} class ScalaEntitySerializerTest { @@ -14,7 +14,7 @@ class ScalaEntitySerializerTest { val writer = new StringWriter() - @Before + @BeforeEach def setUp(): Unit = { val typeModel = new ClassType(TypeCategory.ENTITY, classOf[Person]) entityType = new EntityType(typeModel) diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/JDBCIntegrationTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/JDBCIntegrationTest.scala index 3780da4e45..7139bd72d3 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/JDBCIntegrationTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/JDBCIntegrationTest.scala @@ -4,8 +4,8 @@ import java.sql.{Connection, DriverManager, Statement} import fluentq.sql.dml._ import fluentq.sql.{Configuration, HSQLDBTemplates, RelationalPath, SQLQuery} -import org.junit.Assert._ -import org.junit._ +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api._ import test._ object JDBCIntegrationTest { @@ -13,7 +13,7 @@ object JDBCIntegrationTest { private var connection: Connection = _ private var statement: Statement = _ - @BeforeClass + @BeforeAll def setUpClass(): Unit = { Class.forName("org.h2.Driver") val url = "jdbc:h2:mem:testdb" + System.currentTimeMillis() + ";MODE=legacy" @@ -46,7 +46,7 @@ object JDBCIntegrationTest { // TODO : create table with multi column primary key } - @AfterClass + @AfterAll def tearDownClass(): Unit = { try { statement.close() @@ -67,12 +67,12 @@ class JDBCIntegrationTest extends SQLHelpers { def connection = JDBCIntegrationTest.connection - @Before + @BeforeEach def setUp(): Unit = { connection.setAutoCommit(false) } - @After + @AfterEach def tearDown(): Unit = { connection.rollback() connection.setAutoCommit(true) diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/MetaDataExporterTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/MetaDataExporterTest.scala index c903dbd237..73d624bb0e 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/MetaDataExporterTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/MetaDataExporterTest.scala @@ -3,13 +3,13 @@ package fluentq.scala.sql import fluentq.scala._ import fluentq.sql._ import fluentq.sql.codegen._ -import org.junit._ +import org.junit.jupiter.api._ object MetaDataExporterTest { private var connection: java.sql.Connection = _ - @BeforeClass + @BeforeAll def setUp(): Unit = { Class.forName("org.h2.Driver") val url = "jdbc:h2:mem:testdb" + System.currentTimeMillis() + ";MODE=legacy" @@ -53,7 +53,7 @@ object MetaDataExporterTest { } } - @AfterClass + @AfterAll def tearDown(): Unit = { connection.close() } diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/PathsTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/PathsTest.scala index 1c38e3342d..75e91576e8 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/PathsTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/PathsTest.scala @@ -1,8 +1,8 @@ package fluentq.scala.sql import fluentq.core.types._ -import org.junit.Assert._ -import org.junit._ +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api._ import test._ class PathsTest { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/QuerySyntaxTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/QuerySyntaxTest.scala index 0889996772..6c15f67d3b 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/QuerySyntaxTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/QuerySyntaxTest.scala @@ -1,8 +1,8 @@ package fluentq.scala.sql import fluentq.sql._ -import org.junit.Assert._ -import org.junit.Test +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api.Test class QuerySyntaxTest { diff --git a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/ScalaMetaDataSerializerTest.scala b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/ScalaMetaDataSerializerTest.scala index f433cd8011..0ef0746647 100644 --- a/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/ScalaMetaDataSerializerTest.scala +++ b/fluentq-libraries/fluentq-scala/src/test/scala/fluentq/scala/sql/ScalaMetaDataSerializerTest.scala @@ -8,8 +8,8 @@ import fluentq.codegen._ import fluentq.scala._ import fluentq.sql._ import fluentq.sql.codegen._ -import org.junit.Assert._ -import org.junit._ +import org.junit.jupiter.api.Assertions._ +import org.junit.jupiter.api._ class ScalaMetaDataSerializerTest { @@ -17,7 +17,7 @@ class ScalaMetaDataSerializerTest { val writer = new StringWriter() - @Before + @BeforeEach def setUp(): Unit = { // type val typeModel = new SimpleType(TypeCategory.ENTITY, @@ -46,7 +46,7 @@ class ScalaMetaDataSerializerTest { serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new ScalaWriter(writer)) val str = writer.toString //System.err.println(str) - assertTrue("companion object isn't before class", str.indexOf("object") < str.indexOf("class")) + assertTrue(str.indexOf("object") < str.indexOf("class"), "companion object isn't before class") //assertTrue("companion object isn't before annotations", str.indexOf("object") < str.indexOf("@Table")) } diff --git a/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/GeometryPathTest.java b/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/GeometryPathTest.java index 3d158d288d..5c3665eb28 100644 --- a/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/GeometryPathTest.java +++ b/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/GeometryPathTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GeometryPathTest { diff --git a/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/hibernate/HibernateSpatialSupportTest.java b/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/hibernate/HibernateSpatialSupportTest.java index 68fad5047a..dd9befd0f0 100644 --- a/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/hibernate/HibernateSpatialSupportTest.java +++ b/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/hibernate/HibernateSpatialSupportTest.java @@ -4,7 +4,7 @@ import fluentq.core.types.Operator; import fluentq.spatial.SpatialOps; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HibernateSpatialSupportTest { diff --git a/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/jts/JTSGeometryPathTest.java b/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/jts/JTSGeometryPathTest.java index 803068be5f..4012fdd973 100644 --- a/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/jts/JTSGeometryPathTest.java +++ b/fluentq-libraries/fluentq-spatial/src/test/java/fluentq/spatial/jts/JTSGeometryPathTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JTSGeometryPathTest { diff --git a/fluentq-libraries/fluentq-sql-json/pom.xml b/fluentq-libraries/fluentq-sql-json/pom.xml index bf34bdc3ea..947ab6bc41 100644 --- a/fluentq-libraries/fluentq-sql-json/pom.xml +++ b/fluentq-libraries/fluentq-sql-json/pom.xml @@ -17,7 +17,7 @@ com.fasterxml.jackson jackson-bom - 2.21.3 + ${jackson.version} pom import diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/GeoDBTemplatesTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/GeoDBTemplatesTest.java index f1520e2cd6..2b8857f218 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/GeoDBTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/GeoDBTemplatesTest.java @@ -1,7 +1,7 @@ package fluentq.sql.spatial; import fluentq.sql.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GeoDBTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/MySQLSpatialTemplatesTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/MySQLSpatialTemplatesTest.java index 207e8e9259..aa1885d990 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/MySQLSpatialTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/MySQLSpatialTemplatesTest.java @@ -1,7 +1,7 @@ package fluentq.sql.spatial; import fluentq.sql.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MySQLSpatialTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/PostGISTemplatesTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/PostGISTemplatesTest.java index fa479997c6..acfc332b1f 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/PostGISTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/PostGISTemplatesTest.java @@ -1,7 +1,7 @@ package fluentq.sql.spatial; import fluentq.sql.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PostGISTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SQLServer2008SpatialTemplatesTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SQLServer2008SpatialTemplatesTest.java index 1492ee0074..409f088e1c 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SQLServer2008SpatialTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SQLServer2008SpatialTemplatesTest.java @@ -1,7 +1,7 @@ package fluentq.sql.spatial; import fluentq.sql.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServer2008SpatialTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SpatialBase.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SpatialBase.java index 8a09d1853b..7b7b68642b 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SpatialBase.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/SpatialBase.java @@ -31,7 +31,7 @@ import org.geolatte.geom.Polygon; import org.geolatte.geom.ProjectedGeometryOperations; import org.geolatte.geom.codec.Wkt; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SpatialBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/TeradataSpatialTemplatesTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/TeradataSpatialTemplatesTest.java index 75149ad548..cca88c5b7c 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/TeradataSpatialTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/TeradataSpatialTemplatesTest.java @@ -1,7 +1,7 @@ package fluentq.sql.spatial; import fluentq.sql.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TeradataSpatialTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2LiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2LiteralsSuiteTest.java index 57c4ba67de..8f6c58d3a9 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2LiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2LiteralsSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.H2; import fluentq.sql.Connections; import fluentq.sql.spatial.H2GISTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2LiteralsSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration(H2GISTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2SuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2SuiteTest.java index 76f92873e1..640f4a7ec9 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2SuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/H2SuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.H2; import fluentq.sql.Connections; import fluentq.sql.spatial.H2GISTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2SuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration(H2GISTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLLiteralsSuiteTest.java index 8a85439fc5..d6bc6043a0 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLLiteralsSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.SQLServer; import fluentq.sql.Connections; import fluentq.sql.spatial.SQLServer2008SpatialTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLLiteralsSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initSQLServer(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLSuiteTest.java index 0edc2b2fc8..19ea3c5973 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MSSQLSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.SQLServer; import fluentq.sql.Connections; import fluentq.sql.spatial.SQLServer2008SpatialTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initSQLServer(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLLiteralsSuiteTest.java index d071efbabe..c43f4e8aae 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLLiteralsSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.MySQL; import fluentq.sql.Connections; import fluentq.sql.spatial.MySQLSpatialTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLLiteralsSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initMySQL(); Connections.initConfiguration(MySQLSpatialTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLSuiteTest.java index 5d2e661d42..d3b5786dbc 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/MySQLSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.MySQL; import fluentq.sql.Connections; import fluentq.sql.spatial.MySQLSpatialTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initMySQL(); Connections.initConfiguration(MySQLSpatialTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLLiteralsSuiteTest.java index c8ce9432eb..89511f1ac5 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLLiteralsSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.PostgreSQL; import fluentq.sql.Connections; import fluentq.sql.spatial.PostGISTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class PostgreSQLLiteralsSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initPostgreSQL(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLSuiteTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLSuiteTest.java index 375369282a..8f60640427 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/PostgreSQLSuiteTest.java @@ -1,19 +1,20 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.PostgreSQL; import fluentq.sql.Connections; import fluentq.sql.spatial.PostGISTemplates; import fluentq.sql.spatial.SpatialBase; import fluentq.sql.suites.AbstractSuite; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class PostgreSQLSuiteTest extends AbstractSuite { - public static class Spatial extends SpatialBase {} + @Nested + class Spatial extends SpatialBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initPostgreSQL(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/SpatialTest.java b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/SpatialTest.java index 5ab5f83d66..51aea19ccd 100644 --- a/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/SpatialTest.java +++ b/fluentq-libraries/fluentq-sql-spatial/src/test/java/fluentq/sql/spatial/suites/SpatialTest.java @@ -1,17 +1,16 @@ package fluentq.sql.spatial.suites; -import fluentq.core.testutil.H2; import fluentq.sql.Connections; import java.sql.SQLException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class SpatialTest { - @Before + @BeforeEach public void setUp() throws ClassNotFoundException, SQLException { Connections.initH2(); // Connections.initMySQL(); @@ -19,7 +18,7 @@ public void setUp() throws ClassNotFoundException, SQLException { // Connections.initTeradata(); } - @After + @AfterEach public void tearDown() throws SQLException { Connections.close(); } diff --git a/fluentq-libraries/fluentq-sql/pom.xml b/fluentq-libraries/fluentq-sql/pom.xml index e973137294..4c86ef3a14 100644 --- a/fluentq-libraries/fluentq-sql/pom.xml +++ b/fluentq-libraries/fluentq-sql/pom.xml @@ -148,6 +148,13 @@ test + + tech.turso + turso + ${turso.version} + test + + io.github.openfeign.fluentq fluentq-core diff --git a/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/Keywords.java b/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/Keywords.java index e1eee5b8ce..7208ceb8f6 100644 --- a/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/Keywords.java +++ b/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/Keywords.java @@ -50,6 +50,7 @@ private static Set readLines(String path) { public static final Set ORACLE = readLines("oracle"); public static final Set POSTGRESQL = readLines("postgresql"); public static final Set SQLITE = readLines("sqlite"); + public static final Set TURSO = readLines("turso"); public static final Set SQLSERVER2005 = readLines("sqlserver2005"); public static final Set SQLSERVER2008 = readLines("sqlserver2008"); public static final Set SQLSERVER2012 = readLines("sqlserver2012"); diff --git a/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/SQLTemplatesRegistry.java b/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/SQLTemplatesRegistry.java index 7a69be161b..4e56cb5679 100644 --- a/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/SQLTemplatesRegistry.java +++ b/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/SQLTemplatesRegistry.java @@ -58,6 +58,8 @@ public SQLTemplates.Builder getBuilder(DatabaseMetaData md) throws SQLException return PostgreSQLTemplates.builder(); } else if (name.equals("sqlite")) { return SQLiteTemplates.builder(); + } else if (name.equals("turso")) { + return TursoTemplates.builder(); } else if (name.startsWith("teradata")) { return TeradataTemplates.builder(); } else if (name.equals("microsoft sql server")) { diff --git a/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/TursoTemplates.java b/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/TursoTemplates.java new file mode 100644 index 0000000000..b6868a9ab1 --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/main/java/fluentq/sql/TursoTemplates.java @@ -0,0 +1,166 @@ +/* + * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fluentq.sql; + +import fluentq.core.types.Ops; +import fluentq.sql.types.BigDecimalAsDoubleType; +import fluentq.sql.types.BigIntegerAsLongType; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoField; + +/** + * {@code TursoTemplates} is a SQL dialect for Turso (https://github.com/tursodatabase/turso), a + * SQLite-compatible database + * + * @author tiwe + */ +public class TursoTemplates extends SQLTemplates { + + private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + private static final DateTimeFormatter dateTimeFormatter = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + private static final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + + @SuppressWarnings("FieldNameHidesFieldInSuperclass") // Intentional + public static final TursoTemplates DEFAULT = new TursoTemplates(); + + public static Builder builder() { + return new Builder() { + @Override + protected SQLTemplates build(char escape, boolean quote) { + return new TursoTemplates(escape, quote); + } + }; + } + + public TursoTemplates() { + this('\\', false); + } + + public TursoTemplates(boolean quote) { + this('\\', quote); + } + + public TursoTemplates(char escape, boolean quote) { + super(Keywords.TURSO, "\"", escape, quote, false); + setDummyTable(null); + addCustomType(BigDecimalAsDoubleType.DEFAULT); + addCustomType(BigIntegerAsLongType.DEFAULT); + setUnionsWrapped(false); + setLimitRequired(true); + setNullsFirst(null); + setNullsLast(null); + setDefaultValues("\ndefault values"); + setArraysSupported(false); + setBatchToBulkSupported(false); + + setPrecedence(Precedence.COMPARISON - 1, Ops.LT, Ops.GT, Ops.LOE, Ops.GOE); + setPrecedence(Precedence.COMPARISON, Ops.EQ, Ops.EQ_IGNORE_CASE, Ops.NE); + + add(Ops.MOD, "{0} % {1}", Precedence.ARITH_HIGH); + + add(Ops.INDEX_OF, "charindex({1},{0},1)-1", Precedence.ARITH_LOW); + add(Ops.INDEX_OF_2ARGS, "charindex({1},{0},{2s}+1)-1", Precedence.ARITH_LOW); + + add(Ops.StringOps.LOCATE, "charindex({0},{1})"); + add(Ops.StringOps.LOCATE2, "charindex({0},{1},{2s})"); + + // TODO : optimize + add( + Ops.DateTimeOps.YEAR, + "cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.MONTH, + "cast(strftime('%m',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.WEEK, + "cast(strftime('%W',{0} / 1000, 'unixepoch', 'localtime') as integer) + 1"); + add( + Ops.DateTimeOps.DAY_OF_MONTH, + "cast(strftime('%d',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.DAY_OF_WEEK, + "cast(strftime('%w',{0} / 1000, 'unixepoch', 'localtime') as integer) + 1"); + add( + Ops.DateTimeOps.DAY_OF_YEAR, + "cast(strftime('%j',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.HOUR, + "cast(strftime('%H',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.MINUTE, + "cast(strftime('%M',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.SECOND, + "cast(strftime('%S',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + + add( + Ops.DateTimeOps.YEAR_MONTH, + """ + cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') * 100 + strftime('%m',{0} / 1000,\ + 'unixepoch', 'localtime') as integer)\ + """); + add( + Ops.DateTimeOps.YEAR_WEEK, + "cast(strftime('%Y%W',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + + add(Ops.DateTimeOps.ADD_YEARS, "date({0}, '+{1s} year')"); + add(Ops.DateTimeOps.ADD_MONTHS, "date({0}, '+{1s} month')"); + add(Ops.DateTimeOps.ADD_WEEKS, "date({0}, '+{1s} week')"); + add(Ops.DateTimeOps.ADD_DAYS, "date({0}, '+{1s} day')"); + add(Ops.DateTimeOps.ADD_HOURS, "date({0}, '+{1s} hour')"); + add(Ops.DateTimeOps.ADD_MINUTES, "date({0}, '+{1s} minute')"); + add(Ops.DateTimeOps.ADD_SECONDS, "date({0}, '+{1s} second')"); + + add(Ops.MathOps.RANDOM, "random()"); + add(Ops.MathOps.RANDOM2, "random({0})"); + add(Ops.MathOps.LN, "log({0})"); + add(Ops.MathOps.LOG, "log({0}) / log({1})", Precedence.ARITH_HIGH); + + add(SQLOps.GROUP_CONCAT2, "group_concat({0},{1})"); + + addTypeNameToCode("text", Types.VARCHAR); + } + + @Override + public String serialize(String literal, int jdbcType) { + // XXX doesn't work with LocalDate, LocalDateTime and LocalTime + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> + String.valueOf( + dateTimeFormatter + .parse(literal, LocalDateTime::from) + .toInstant(ZoneOffset.UTC) + .toEpochMilli()); + case Types.DATE -> + String.valueOf( + dateFormatter + .parse(literal, LocalDate::from) + .atStartOfDay(ZoneOffset.UTC) + .toInstant() + .toEpochMilli()); + case Types.TIME, TIME_WITH_TIMEZONE -> + String.valueOf( + timeFormatter.parse(literal, LocalTime::from).get(ChronoField.MILLI_OF_DAY)); + default -> super.serialize(literal, jdbcType); + }; + } +} diff --git a/fluentq-libraries/fluentq-sql/src/main/resources/keywords/turso b/fluentq-libraries/fluentq-sql/src/main/resources/keywords/turso new file mode 100644 index 0000000000..9eded2e9c9 --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/main/resources/keywords/turso @@ -0,0 +1,146 @@ +# source https://github.com/tursodatabase/turso (SQLite-compatible) +ABORT +ACTION +ADD +AFTER +ALL +ALTER +ALWAYS +ANALYZE +AND +AS +ASC +ATTACH +AUTOINCREMENT +BEFORE +BEGIN +BETWEEN +BY +CASCADE +CASE +CAST +CHECK +COLLATE +COLUMN +COMMIT +CONFLICT +CONSTRAINT +CREATE +CROSS +CURRENT +CURRENT_DATE +CURRENT_TIME +CURRENT_TIMESTAMP +DATABASE +DEFAULT +DEFERRABLE +DEFERRED +DELETE +DESC +DETACH +DISTINCT +DO +DROP +EACH +ELSE +END +ESCAPE +EXCEPT +EXCLUSIVE +EXISTS +EXPLAIN +FAIL +FILTER +FIRST +FOLLOWING +FOR +FOREIGN +FROM +FULL +GENERATED +GLOB +GROUP +GROUPS +HAVING +IF +IGNORE +IMMEDIATE +IN +INDEX +INDEXED +INITIALLY +INNER +INSERT +INSTEAD +INTERSECT +INTO +IS +ISNULL +JOIN +KEY +LAST +LEFT +LIKE +LIMIT +MATCH +MATERIALIZED +NATURAL +NO +NOT +NOTHING +NOTNULL +NULL +NULLS +OF +OFFSET +ON +OR +ORDER +OTHERS +OUTER +OVER +PARTITION +PLAN +PRAGMA +PRECEDING +PRIMARY +QUERY +RAISE +RECURSIVE +REFERENCES +REGEXP +REINDEX +RELEASE +RENAME +REPLACE +RESTRICT +RETURNING +RIGHT +ROLLBACK +ROW +ROWS +SAVEPOINT +SELECT +SET +TABLE +TEMP +TEMPORARY +THEN +TIES +TO +TRANSACTION +TRIGGER +UNBOUNDED +UNION +UNIQUE +UPDATE +USING +VACUUM +VALUES +VIEW +VIRTUAL +WHEN +WHERE +WINDOW +WITH +WITHOUT diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractBaseTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractBaseTest.java index 8e04680137..0700c13960 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractBaseTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractBaseTest.java @@ -30,11 +30,10 @@ import java.util.List; import java.util.logging.Logger; import org.jetbrains.annotations.Nullable; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.MethodRule; -import org.junit.rules.TestRule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; +@ExtendWith({TargetExtension.class, SkipForQuotedExtension.class}) public abstract class AbstractBaseTest { protected static final Logger logger = Logger.getLogger(AbstractBaseTest.class.getName()); @@ -86,9 +85,21 @@ public AbstractBaseTest() { } } - @Rule public MethodRule skipForQuotedRule = new SkipForQuotedRule(configuration); - - @Rule @ClassRule public static TestRule targetRule = new TargetRule(); + // Turso (early-stage SQLite reimplementation) closes the shared connection when a statement + // errors, which would otherwise cascade "database connection closed" across every later test. + // Reconnecting per test isolates each test so we see its true pass/fail result. + @BeforeEach + public void reconnectClosedTursoConnection() throws java.sql.SQLException { + if (target == Target.TURSO && (connection == null || connection.isClosed())) { + try { + Connections.initTurso(); + } catch (ClassNotFoundException e) { + throw new IllegalStateException(e); + } + connection = Connections.getConnection(); + configuration = Connections.getConfiguration(); + } + } protected void add(List list, T arg, Target... exclusions) { if (exclusions.length > 0) { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractJDBCTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractJDBCTest.java index 5a023b5f4b..5241c0f075 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractJDBCTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractJDBCTest.java @@ -17,8 +17,8 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; public abstract class AbstractJDBCTest { @@ -26,7 +26,7 @@ public abstract class AbstractJDBCTest { protected Statement statement; - @Before + @BeforeEach public void setUp() throws ClassNotFoundException, SQLException { Class.forName("org.hsqldb.jdbcDriver"); var url = "jdbc:hsqldb:mem:testdb"; @@ -34,7 +34,7 @@ public void setUp() throws ClassNotFoundException, SQLException { statement = connection.createStatement(); } - @After + @AfterEach public void tearDown() throws SQLException { try { statement.close(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractSQLTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractSQLTemplatesTest.java index ed72c0cf28..972d358fe8 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractSQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/AbstractSQLTemplatesTest.java @@ -26,8 +26,8 @@ import fluentq.core.types.dsl.NumberExpression; import fluentq.sql.domain.QSurvey; import java.util.Collection; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class AbstractSQLTemplatesTest { @@ -41,7 +41,7 @@ public abstract class AbstractSQLTemplatesTest { protected abstract SQLTemplates createTemplates(); - @Before + @BeforeEach public void setUp() { templates = createTemplates(); templates.newLineToSingleSpace(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ArrayTypesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ArrayTypesTest.java index 475fe921fb..2de7d93a64 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ArrayTypesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ArrayTypesTest.java @@ -3,14 +3,14 @@ import static org.assertj.core.api.Assertions.assertThat; import java.sql.Types; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ArrayTypesTest { private Configuration configuration; - @Before + @BeforeEach public void setUp() { configuration = Configuration.DEFAULT; } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/BeanPopulationBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/BeanPopulationBase.java index 00aa2c730f..2bc0212b0c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/BeanPopulationBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/BeanPopulationBase.java @@ -21,25 +21,27 @@ import static fluentq.core.Target.SQLITE; import static fluentq.core.Target.SQLSERVER; import static fluentq.core.Target.TERADATA; +import static fluentq.core.Target.TURSO; import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.testutil.ExcludeIn; import fluentq.sql.dml.BeanMapper; import fluentq.sql.domain.Employee; import fluentq.sql.domain.QEmployee; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; @ExcludeIn({CUBRID, DB2, DERBY, ORACLE, SQLSERVER, POSTGRESQL, SQLITE, TERADATA}) public abstract class BeanPopulationBase extends AbstractBaseTest { private final QEmployee e = new QEmployee("e"); - @After + @AfterEach public void tearDown() { delete(e).where(e.firstname.eq("John")).execute(); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void custom_projection() { // Insert @@ -87,6 +89,7 @@ public void custom_projection() { assertThat(delete(e).where(e.id.eq(employee.getId())).execute()).isEqualTo(1L); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void insert_update_query_and_delete() { // Insert @@ -109,6 +112,7 @@ public void insert_update_query_and_delete() { assertThat(delete(e).where(e.id.eq(employee.getId())).execute()).isEqualTo(1L); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void populate_with_beanMapper() { var employee = new Employee(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CUBRIDTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CUBRIDTemplatesTest.java index ee54ff691f..3313d09e04 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CUBRIDTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CUBRIDTemplatesTest.java @@ -13,9 +13,9 @@ */ package fluentq.sql; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class CUBRIDTemplatesTest extends AbstractSQLTemplatesTest { @Override diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CoalesceTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CoalesceTest.java index a8f896a012..7cde6ec10c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CoalesceTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/CoalesceTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.dsl.Coalesce; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CoalesceTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ColumnMetadataTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ColumnMetadataTest.java index f43f67faf1..ce9429ed65 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ColumnMetadataTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ColumnMetadataTest.java @@ -4,7 +4,7 @@ import fluentq.sql.domain.QEmployee; import java.sql.Types; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ColumnMetadataTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConfigurationTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConfigurationTest.java index 3a5d797015..3fa69359cd 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConfigurationTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConfigurationTest.java @@ -14,6 +14,7 @@ package fluentq.sql; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.core.alias.Gender; import fluentq.sql.domain.QSurvey; @@ -34,7 +35,7 @@ import java.sql.Types; import java.util.Locale; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConfigurationTest { @@ -140,14 +141,22 @@ public void columnOverride() { .isEqualTo("lower"); } - @Test(expected = NullPointerException.class) + @Test public void npeWithNullParameterOfChainedNameMappingConstructor() { - new ChainedNameMapping((NameMapping[]) null); + assertThrows( + NullPointerException.class, + () -> { + new ChainedNameMapping((NameMapping[]) null); + }); } - @Test(expected = NullPointerException.class) + @Test public void npeWithNullElementInParameterOfChainedNameMappingConstructor() { - new ChainedNameMapping(new NameMapping[] {null}); + assertThrows( + NullPointerException.class, + () -> { + new ChainedNameMapping(new NameMapping[] {null}); + }); } @Test diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/Connections.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/Connections.java index 02bdfd0e29..26ddb6917c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/Connections.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/Connections.java @@ -22,6 +22,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Time; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import org.hsqldb.types.Types; @@ -74,6 +75,7 @@ public final class Connections { oracleInited, postgresqlInited, sqliteInited, + tursoInited, teradataInited, firebirdInited; @@ -169,6 +171,11 @@ private static Connection getSQLite() throws SQLException, ClassNotFoundExceptio return DriverManager.getConnection("jdbc:sqlite:target/sample.db"); } + private static Connection getTurso() throws SQLException, ClassNotFoundException { + Class.forName("tech.turso.JDBC"); + return DriverManager.getConnection("jdbc:turso:target/turso-sample.db"); + } + private static Connection getTeradata() throws SQLException, ClassNotFoundException { Class.forName("com.teradata.jdbc.TeraDriver"); return DriverManager.getConnection("jdbc:teradata://teradata/dbc", "fluentq", "fluentq"); @@ -750,6 +757,26 @@ public static void initMySQL() throws SQLException, ClassNotFoundException { return; } + // The shared MySQL database accumulates tables from other suites under two naming conventions: + // Hibernate keeps the entity case (Child2) while EclipseLink upper-cases it (CHILD2). On a + // case-sensitive server (lower_case_table_names=0) both survive, and the metadata export then + // maps CHILD2 and Child2 to the same QChild2 and fails. Drop every table up front so the test + // schema is deterministic regardless of what previous runs left behind. + var leftovers = new ArrayList(); + try (var rs = + stmt.executeQuery( + "select table_name from information_schema.tables" + + " where table_schema = database() and table_type = 'BASE TABLE'")) { + while (rs.next()) { + leftovers.add(rs.getString(1)); + } + } + stmt.execute("SET FOREIGN_KEY_CHECKS = 0"); + for (String table : leftovers) { + stmt.execute("drop table if exists `" + table + "`"); + } + stmt.execute("SET FOREIGN_KEY_CHECKS = 1"); + // shapes stmt.execute("drop table if exists SHAPES"); stmt.execute("create table SHAPES (ID int not null primary key, GEOMETRY geometry)"); @@ -1086,6 +1113,78 @@ CONSTRAINT FK_SUPERIOR FOREIGN KEY(SUPERIOR_ID) REFERENCES EMPLOYEE(ID) \ sqliteInited = true; } + public static void initTurso() throws SQLException, ClassNotFoundException { + targetHolder.set(Target.TURSO); + var c = getTurso(); + connHolder.set(c); + var stmt = c.createStatement(); + stmtHolder.set(stmt); + + if (tursoInited) { + return; + } + + // qtest + stmt.execute("drop table if exists QTEST"); + stmt.execute("create table QTEST (ID int IDENTITY(1,1) NOT NULL, C1 int NULL)"); + + // survey + stmt.execute("drop table if exists SURVEY"); + stmt.execute( + """ + create table SURVEY(ID int auto_increment, \ + NAME varchar(30),\ + NAME2 varchar(30),\ + constraint survey_pk primary key(ID))\ + """); + stmt.execute("insert into SURVEY values (1,'Hello World','Hello');"); + + // test + stmt.execute("drop table if exists TEST"); + stmt.execute(CREATE_TABLE_TEST); + try (var pstmt = c.prepareStatement(INSERT_INTO_TEST_VALUES)) { + for (var i = 0; i < TEST_ROW_COUNT; i++) { + pstmt.setString(1, "name" + i); + pstmt.addBatch(); + } + pstmt.executeBatch(); + } + + // employee + stmt.execute("drop table if exists EMPLOYEE"); + stmt.execute( + """ + create table EMPLOYEE ( \ + ID INT AUTO_INCREMENT, \ + FIRSTNAME VARCHAR(50), \ + LASTNAME VARCHAR(50), \ + SALARY DECIMAL, \ + DATEFIELD DATE, \ + TIMEFIELD TIME, \ + SUPERIOR_ID INT, \ + CONSTRAINT PK_EMPLOYEE PRIMARY KEY(ID),\ + CONSTRAINT FK_SUPERIOR FOREIGN KEY(SUPERIOR_ID) REFERENCES EMPLOYEE(ID) \ + )\ + """); + addEmployees(INSERT_INTO_EMPLOYEE); + + // date_test and time_test + stmt.execute("drop table if exists TIME_TEST"); + stmt.execute("drop table if exists DATE_TEST"); + stmt.execute(CREATE_TABLE_TIMETEST); + stmt.execute(CREATE_TABLE_DATETEST); + + // numbers + stmt.execute("drop table if exists NUMBER_TEST"); + stmt.execute("create table NUMBER_TEST(col1 integer)"); + + // xml + stmt.execute("drop table if exists XML_TEST"); + stmt.execute("create table XML_TEST(COL varchar(128))"); + + tursoInited = true; + } + public static void initSQLServer() throws SQLException, ClassNotFoundException { targetHolder.set(Target.SQLSERVER); SQLTemplates templates = new SQLServerTemplates(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConnectionsTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConnectionsTest.java index b86b549d1d..95349f4c79 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConnectionsTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ConnectionsTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.geolatte.geom.codec.Wkt; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConnectionsTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DB2TemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DB2TemplatesTest.java index cccd9481d8..2635cd0b43 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DB2TemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DB2TemplatesTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DB2TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DateArithmeticTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DateArithmeticTest.java index bc8b8a5b60..61338954c7 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DateArithmeticTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DateArithmeticTest.java @@ -1,16 +1,15 @@ package fluentq.sql; -import fluentq.core.testutil.ReportingOnly; import fluentq.core.types.Expression; import fluentq.core.types.dsl.DateTimePath; import fluentq.core.types.dsl.Expressions; import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(ReportingOnly.class) +@Tag("fluentq.core.testutil.ReportingOnly") public class DateArithmeticTest { private String serialize(Expression expr, SQLTemplates templates) { @@ -30,6 +29,7 @@ public void test() { list.add(new OracleTemplates()); list.add(new PostgreSQLTemplates()); list.add(new SQLiteTemplates()); + list.add(new TursoTemplates()); list.add(new SQLServerTemplates()); list.add(new SQLServer2005Templates()); list.add(new SQLServer2012Templates()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DeleteBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DeleteBase.java index fc6bc50908..eb2c6f1adb 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DeleteBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DeleteBase.java @@ -20,6 +20,7 @@ import static fluentq.core.Target.ORACLE; import static fluentq.core.Target.SQLITE; import static fluentq.core.Target.SQLSERVER; +import static fluentq.core.Target.TURSO; import static fluentq.sql.Constants.survey; import static org.assertj.core.api.Assertions.assertThat; @@ -30,9 +31,9 @@ import fluentq.sql.domain.QEmployee; import fluentq.sql.domain.QSurvey; import java.sql.SQLException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class DeleteBase extends AbstractBaseTest { @@ -41,16 +42,17 @@ private void reset() throws SQLException { insert(survey).values(1, "Hello World", "Hello").execute(); } - @Before + @BeforeEach public void setUp() throws SQLException { reset(); } - @After + @AfterEach public void tearDown() throws SQLException { reset(); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void batch() throws SQLException { insert(survey).values(2, "A", "B").execute(); @@ -65,7 +67,7 @@ public void batch() throws SQLException { } @Test - @ExcludeIn({CUBRID, SQLITE, FIREBIRD}) + @ExcludeIn({CUBRID, SQLITE, FIREBIRD, TURSO}) public void batch_templates() throws SQLException { insert(survey).values(2, "A", "B").execute(); insert(survey).values(3, "B", "C").execute(); @@ -77,7 +79,7 @@ public void batch_templates() throws SQLException { } @Test - @ExcludeIn(MYSQL) + @ExcludeIn({MYSQL, TURSO}) public void delete() throws SQLException { var count = query().from(survey).fetchCount(); assertThat(delete(survey).where(survey.name.eq("XXX")).execute()).isEqualTo(0); @@ -94,6 +96,7 @@ public void delete_limit() { assertThat(delete(survey).limit(2).execute()).isEqualTo(2); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void delete_with_subQuery_exists() { var survey1 = new QSurvey("s1"); @@ -104,6 +107,7 @@ public void delete_with_subQuery_exists() { assertThat(delete.execute()).isEqualTo(0); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void delete_with_subQuery_exists_Params() { var survey1 = new QSurvey("s1"); @@ -118,6 +122,7 @@ public void delete_with_subQuery_exists_Params() { assertThat(delete.execute()).isEqualTo(0); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void delete_with_subQuery_exists2() { var survey1 = new QSurvey("s1"); @@ -130,7 +135,7 @@ public void delete_with_subQuery_exists2() { } @Test - @ExcludeIn({CUBRID, SQLITE, FIREBIRD}) + @ExcludeIn({CUBRID, SQLITE, FIREBIRD, TURSO}) public void delete_with_tempateExpression_in_batch() { assertThat( delete(survey) diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DependenciesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DependenciesTest.java index 147beca98c..cdd099c197 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DependenciesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DependenciesTest.java @@ -17,13 +17,13 @@ import java.io.IOException; import jdepend.framework.JDepend; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class DependenciesTest { @Test - @Ignore + @Disabled public void test() throws IOException { var jdepend = new JDepend(); jdepend.addDirectory("target/classes/fluentq/sql"); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DerbyTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DerbyTemplatesTest.java index 83588141d6..4b8c865d3d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DerbyTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/DerbyTemplatesTest.java @@ -20,7 +20,7 @@ import fluentq.core.types.Operation; import fluentq.core.types.Ops; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DerbyTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ExtendedSQLTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ExtendedSQLTest.java index 71b7626d97..ee3e9a1bc7 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ExtendedSQLTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ExtendedSQLTest.java @@ -10,7 +10,7 @@ import fluentq.core.types.dsl.Wildcard; import fluentq.sql.mysql.MySQLQuery; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExtendedSQLTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/FirebirdTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/FirebirdTemplatesTest.java index 1fcd947881..4f12ad32c4 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/FirebirdTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/FirebirdTemplatesTest.java @@ -19,7 +19,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FirebirdTemplatesTest extends AbstractSQLTemplatesTest { @@ -29,6 +29,7 @@ protected SQLTemplates createTemplates() { } @Override + @Test public void arithmetic() { // uses additional casts } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ForeignKeyTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ForeignKeyTest.java index 10fd37ba6a..d43a4fbb58 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ForeignKeyTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ForeignKeyTest.java @@ -18,7 +18,7 @@ import fluentq.sql.domain.Employee; import fluentq.sql.domain.QEmployee; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ForeignKeyTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/H2TemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/H2TemplatesTest.java index 10a4bb705c..97df4afbf9 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/H2TemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/H2TemplatesTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class H2TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/HSQLDBTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/HSQLDBTemplatesTest.java index 7aef74893e..f02cfc718f 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/HSQLDBTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/HSQLDBTemplatesTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HSQLDBTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/InsertBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/InsertBase.java index 34a4642e93..d45f85f8fb 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/InsertBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/InsertBase.java @@ -24,10 +24,12 @@ import static fluentq.core.Target.POSTGRESQL; import static fluentq.core.Target.SQLITE; import static fluentq.core.Target.SQLSERVER; +import static fluentq.core.Target.TURSO; import static fluentq.sql.Constants.survey; import static fluentq.sql.Constants.survey2; import static fluentq.sql.SQLExpressions.select; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.core.QueryException; import fluentq.core.QueryFlag.Position; @@ -51,10 +53,10 @@ import java.time.LocalDateTime; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class InsertBase extends AbstractBaseTest { @@ -65,19 +67,19 @@ private void reset() throws SQLException { delete(QDateTest.qDateTest).execute(); } - @Before + @BeforeEach public void setUp() throws SQLException { reset(); } - @After + @AfterEach public void tearDown() throws SQLException { reset(); } @Test @ExcludeIn({ - CUBRID, SQLITE, DERBY, ORACLE + CUBRID, SQLITE, DERBY, ORACLE, TURSO }) // https://bitbucket.org/xerial/sqlite-jdbc/issue/133/prepstmtsetdate-int-date-calendar-seems public void insert_dates() { var dateTest = QDateTest.qDateTest; @@ -226,7 +228,7 @@ public void insert_nulls_in_batch() { } @Test - @Ignore + @Disabled @ExcludeIn({DERBY}) public void insert_nulls_in_batch2() { Mapper mapper = DefaultMapper.WITH_NULL_BINDINGS; @@ -255,7 +257,7 @@ public void insert_with_columns() { } @Test - @ExcludeIn({CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({CUBRID, SQLSERVER, SQLITE, TURSO}) public void insert_with_keys() throws SQLException { var rs = insert(survey).set(survey.name, "Hello World").executeWithKeys(); assertThat(rs.next()).isTrue(); @@ -264,7 +266,7 @@ public void insert_with_keys() throws SQLException { } @Test - @ExcludeIn({CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({CUBRID, SQLSERVER, SQLITE, TURSO}) public void insert_with_keys_listener() throws SQLException { final var result = new AtomicBoolean(); SQLListener listener = @@ -285,35 +287,45 @@ public void end(SQLListenerContext context) { } @Test - @ExcludeIn({CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({CUBRID, SQLSERVER, SQLITE, TURSO}) public void insert_with_keys_Projected() throws SQLException { assertThat(insert(survey).set(survey.name, "Hello you").executeWithKey(survey.id)).isNotNull(); } @Test - @ExcludeIn({CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({CUBRID, SQLSERVER, SQLITE, TURSO}) public void insert_with_keys_Projected2() throws SQLException { Path idPath = ExpressionUtils.path(Object.class, "id"); Object id = insert(survey).set(survey.name, "Hello you").executeWithKey(idPath); assertThat(id).isNotNull(); } - @Test(expected = QueryException.class) + @Test @IncludeIn({DERBY, HSQLDB}) public void insert_with_keys_OverriddenColumn() throws SQLException { - var originalColumnName = ColumnMetadata.getName(survey.id); - try { - configuration.registerColumnOverride( - survey.getSchemaName(), survey.getTableName(), originalColumnName, "wrongColumnName"); - - var sqlInsertClause = new SQLInsertClause(connection, configuration, survey); - sqlInsertClause.addListener(new TestLoggingListener()); - Object id = sqlInsertClause.set(survey.name, "Hello you").executeWithKey(survey.id); - assertThat(id).isNotNull(); - } finally { - configuration.registerColumnOverride( - survey.getSchemaName(), survey.getTableName(), originalColumnName, originalColumnName); - } + assertThrows( + QueryException.class, + () -> { + var originalColumnName = ColumnMetadata.getName(survey.id); + try { + configuration.registerColumnOverride( + survey.getSchemaName(), + survey.getTableName(), + originalColumnName, + "wrongColumnName"); + + var sqlInsertClause = new SQLInsertClause(connection, configuration, survey); + sqlInsertClause.addListener(new TestLoggingListener()); + Object id = sqlInsertClause.set(survey.name, "Hello you").executeWithKey(survey.id); + assertThat(id).isNotNull(); + } finally { + configuration.registerColumnOverride( + survey.getSchemaName(), + survey.getTableName(), + originalColumnName, + originalColumnName); + } + }); } // http://sourceforge.net/tracker/index.php?func=detail&aid=3513432&group_id=280608&atid=2377440 diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JDBCTypeMappingTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JDBCTypeMappingTest.java index 7d29150a09..aa00703c45 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JDBCTypeMappingTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JDBCTypeMappingTest.java @@ -15,13 +15,12 @@ import static org.assertj.core.api.Assertions.assertThat; -import fluentq.core.testutil.ReportingOnly; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Blob; import java.sql.Types; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class JDBCTypeMappingTest { @@ -83,7 +82,7 @@ public void numericTypes() { } @Test - @Category(ReportingOnly.class) + @Tag("fluentq.core.testutil.ReportingOnly") public void max() { System.err.println("Byte: " + String.valueOf(Byte.MAX_VALUE).length()); System.err.println("Short: " + String.valueOf(Short.MAX_VALUE).length()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JavaTypeMappingTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JavaTypeMappingTest.java index 0f457bee88..5a7c53309f 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JavaTypeMappingTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JavaTypeMappingTest.java @@ -28,7 +28,7 @@ import fluentq.sql.types.ShortType; import java.io.FileInputStream; import java.io.InputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JavaTypeMappingTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinFlagsTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinFlagsTest.java index 3f141eeee2..adde9d45df 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinFlagsTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinFlagsTest.java @@ -19,8 +19,8 @@ import fluentq.sql.domain.QSurvey; import java.sql.Connection; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JoinFlagsTest { @@ -31,7 +31,7 @@ public class JoinFlagsTest { private SQLQuery query; @SuppressWarnings("unchecked") - @Before + @BeforeEach public void setUp() { s1 = new QSurvey("s"); s2 = new QSurvey("s2"); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinUsageTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinUsageTest.java index ec6fc7f77f..201634d0a2 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinUsageTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/JoinUsageTest.java @@ -14,17 +14,22 @@ package fluentq.sql; import static fluentq.sql.SQLExpressions.selectFrom; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.sql.domain.QSurvey; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class JoinUsageTest { - @Test(expected = IllegalStateException.class) - @Ignore + @Test + @Disabled public void join_already_declared() { - var survey = QSurvey.survey; - selectFrom(survey).fullJoin(survey); + assertThrows( + IllegalStateException.class, + () -> { + var survey = QSurvey.survey; + selectFrom(survey).fullJoin(survey); + }); } } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyAccessorsTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyAccessorsTest.java index 01533c06ee..e0ac7d385f 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyAccessorsTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyAccessorsTest.java @@ -18,7 +18,7 @@ import fluentq.core.types.dsl.NumberPath; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class KeyAccessorsTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyTest.java index 01c24c97cd..6a9c731c37 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeyTest.java @@ -17,7 +17,7 @@ import fluentq.core.types.PathMetadataFactory; import fluentq.core.types.dsl.NumberPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("serial") public class KeyTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeywordQuotingBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeywordQuotingBase.java index b64c63f006..a15340a530 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeywordQuotingBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/KeywordQuotingBase.java @@ -15,9 +15,11 @@ */ package fluentq.sql; +import static fluentq.core.Target.CUBRID; import static org.assertj.core.api.Assertions.assertThat; import com.google.common.base.Splitter; +import fluentq.core.testutil.ExcludeIn; import fluentq.core.types.PathMetadata; import fluentq.core.types.PathMetadataFactory; import fluentq.core.types.dsl.BooleanPath; @@ -25,9 +27,9 @@ import fluentq.sql.ddl.CreateTableClause; import fluentq.sql.ddl.DropTableClause; import java.sql.SQLException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class KeywordQuotingBase extends AbstractBaseTest { @@ -58,7 +60,7 @@ protected void addMetadata() { private final Quoting quoting = Quoting.quoting; - @Before + @BeforeEach public void setUp() throws Exception { new CreateTableClause(connection, configuration, "quoting") .column("from", String.class) @@ -68,7 +70,7 @@ public void setUp() throws Exception { execute(insert(quoting).columns(quoting.from, quoting.all).values("from", true)); } - @After + @AfterEach public void tearDown() throws Exception { new DropTableClause(connection, configuration, "quoting").execute(); } @@ -86,6 +88,9 @@ public void keywords() { } @Test + // The bundled CUBRID 9.3.9 JDBC driver reports a malformed keyword list (e.g. "TATISTICS", + // "DATA_TYPE___"), so completeness against the curated keyword file cannot be asserted. + @ExcludeIn(CUBRID) public void validateKeywordsCompleteness() throws SQLException { var keywords = switch (target) { @@ -101,6 +106,7 @@ public void validateKeywordsCompleteness() throws SQLException { case ORACLE -> Keywords.ORACLE; case POSTGRESQL -> Keywords.POSTGRESQL; case SQLITE -> Keywords.SQLITE; + case TURSO -> Keywords.TURSO; case SQLSERVER -> Keywords.SQLSERVER2012; case TERADATA -> Keywords.DEFAULT; }; diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/LikeEscapeBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/LikeEscapeBase.java index 236ae91e8a..b5e82513b5 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/LikeEscapeBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/LikeEscapeBase.java @@ -17,13 +17,13 @@ import static org.assertj.core.api.Assertions.assertThat; import java.sql.SQLException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class LikeEscapeBase extends AbstractBaseTest { - @Before + @BeforeEach public void setUp() throws SQLException { delete(survey).execute(); var insert = insert(survey); @@ -33,7 +33,7 @@ public void setUp() throws SQLException { insert.execute(); } - @After + @AfterEach public void tearDown() throws SQLException { delete(survey).execute(); insert(survey).values(1, "Hello World", "Hello").execute(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ListSubQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ListSubQueryTest.java index 47eef801e0..b98cb309e9 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ListSubQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/ListSubQueryTest.java @@ -9,7 +9,7 @@ import fluentq.sql.domain.QSurvey; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ListSubQueryTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeBase.java index 331423827a..8c65661763 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeBase.java @@ -21,6 +21,7 @@ import static fluentq.core.Target.SQLITE; import static fluentq.core.Target.SQLSERVER; import static fluentq.core.Target.TERADATA; +import static fluentq.core.Target.TURSO; import static fluentq.sql.Constants.survey; import static fluentq.sql.Constants.survey2; import static org.assertj.core.api.Assertions.assertThat; @@ -34,9 +35,9 @@ import java.sql.SQLException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class MergeBase extends AbstractBaseTest { @@ -45,18 +46,18 @@ private void reset() throws SQLException { insert(survey).values(1, "Hello World", "Hello").execute(); } - @Before + @BeforeEach public void setUp() throws SQLException { reset(); } - @After + @AfterEach public void tearDown() throws SQLException { reset(); } @Test - @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE, TURSO}) public void merge_with_keys() throws SQLException { var rs = merge(survey) @@ -70,7 +71,7 @@ public void merge_with_keys() throws SQLException { } @Test - @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE, TURSO}) public void merge_with_keys_listener() throws SQLException { final var result = new AtomicBoolean(); SQLListener listener = @@ -139,7 +140,7 @@ public void merge_with_keys_columns_and_values_using_null() { } @Test - @ExcludeIn({CUBRID, DB2, DERBY, POSTGRESQL, SQLSERVER, TERADATA, SQLITE}) + @ExcludeIn({CUBRID, DB2, DERBY, POSTGRESQL, SQLSERVER, TERADATA, SQLITE, TURSO}) public void merge_with_keys_Null_Id() throws SQLException { var rs = merge(survey) @@ -153,7 +154,7 @@ public void merge_with_keys_Null_Id() throws SQLException { } @Test - @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE, TURSO}) public void merge_with_keys_Projected() throws SQLException { assertThat( merge(survey) @@ -165,7 +166,7 @@ public void merge_with_keys_Projected() throws SQLException { } @Test - @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE}) + @ExcludeIn({H2, CUBRID, SQLSERVER, SQLITE, TURSO}) public void merge_with_keys_Projected2() throws SQLException { Path idPath = ExpressionUtils.path(Object.class, "id"); Object id = diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeUsingBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeUsingBase.java index f31e163f12..a08a86f9bf 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeUsingBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MergeUsingBase.java @@ -29,9 +29,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MergeUsingBase extends AbstractBaseTest { @@ -40,12 +40,12 @@ private void reset() throws SQLException { insert(survey).values(1, "Hello World", "Hello").execute(); } - @Before + @BeforeEach public void setUp() throws SQLException { reset(); } - @After + @AfterEach public void tearDown() throws SQLException { reset(); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MetadataTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MetadataTest.java index 42eba67b16..795fd054ec 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MetadataTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MetadataTest.java @@ -1,10 +1,10 @@ package fluentq.sql; import java.sql.SQLException; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class MetadataTest { // CUBRID diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MultikeyTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MultikeyTest.java index a86902c007..4e3a713901 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MultikeyTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MultikeyTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MultikeyTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MySQLTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MySQLTemplatesTest.java index 7ad34b742b..484886a88a 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MySQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/MySQLTemplatesTest.java @@ -17,7 +17,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MySQLTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTemplatesTest.java index ce9bbc436f..2e822e6118 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTemplatesTest.java @@ -26,7 +26,7 @@ import fluentq.core.types.dsl.SimpleExpression; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OracleTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTimeTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTimeTest.java index 839b766b36..cc30a3ecdf 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTimeTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/OracleTimeTest.java @@ -1,14 +1,14 @@ package fluentq.sql; import java.sql.SQLException; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class OracleTimeTest { - @After + @AfterEach public void tearDown() throws SQLException { Connections.close(); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PaginationTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PaginationTest.java index 3e84dfd549..a025851e1c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PaginationTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PaginationTest.java @@ -3,14 +3,13 @@ import fluentq.core.QueryMetadata; import fluentq.core.QueryModifiers; import fluentq.core.support.QueryMixin; -import fluentq.core.testutil.ReportingOnly; import fluentq.sql.domain.QEmployee; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(ReportingOnly.class) +@Tag("fluentq.core.testutil.ReportingOnly") public class PaginationTest { private String serialize(QueryMetadata metadata, SQLTemplates templates) { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PostgreSQLTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PostgreSQLTemplatesTest.java index c170312a08..5679973988 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PostgreSQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PostgreSQLTemplatesTest.java @@ -19,7 +19,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PostgreSQLTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PrecedenceTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PrecedenceTest.java index 27b3fed109..0dcf61a609 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PrecedenceTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/PrecedenceTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PrecedenceTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBean2Test.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBean2Test.java index f4b8c14e7c..f0c91deffe 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBean2Test.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBean2Test.java @@ -22,7 +22,7 @@ import fluentq.core.types.dsl.BeanPath; import fluentq.core.types.dsl.NumberPath; import fluentq.core.types.dsl.StringPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QBean2Test { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBeanTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBeanTest.java index d98984f36a..583d07d4b0 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBeanTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QBeanTest.java @@ -19,7 +19,7 @@ import fluentq.core.types.Projections; import fluentq.sql.domain.Employee; import fluentq.sql.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QBeanTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QPersonTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QPersonTest.java index d559726cd6..f08c5d55ae 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QPersonTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QPersonTest.java @@ -17,7 +17,7 @@ import fluentq.core.types.Projections; import fluentq.core.types.QBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QPersonTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryMutabilityTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryMutabilityTest.java index 497f6aa571..e2abe16fb1 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryMutabilityTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryMutabilityTest.java @@ -16,31 +16,30 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.QueryMutability; -import fluentq.core.testutil.Derby; import fluentq.sql.domain.QSurvey; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.Connection; import java.sql.SQLException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(Derby.class) +@Tag("fluentq.core.testutil.Derby") public class QueryMutabilityTest { private static final QSurvey survey = new QSurvey("survey"); private Connection connection; - @Before + @BeforeEach public void setUp() throws Exception { Connections.initDerby(); connection = Connections.getConnection(); } - @After + @AfterEach public void tearDown() throws SQLException { Connections.close(); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryPerformanceTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryPerformanceTest.java index fdf7a9aa6b..7c5c559f4b 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryPerformanceTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/QueryPerformanceTest.java @@ -5,15 +5,13 @@ import fluentq.core.DefaultQueryMetadata; import fluentq.core.JoinType; import fluentq.core.QueryMetadata; -import fluentq.core.testutil.H2; -import fluentq.core.testutil.Performance; import java.sql.SQLException; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; @@ -22,7 +20,8 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; -@Category({H2.class, Performance.class}) +@Tag("fluentq.core.testutil.H2") +@Tag("fluentq.core.testutil.Performance") public class QueryPerformanceTest { private static final String QUERY = @@ -36,7 +35,7 @@ public class QueryPerformanceTest { private static final Configuration conf = new Configuration(templates); - @BeforeClass + @BeforeAll public static void setUpClass() throws SQLException, ClassNotFoundException { Connections.initH2(); var conn = Connections.getConnection(); @@ -57,7 +56,7 @@ public static void setUpClass() throws SQLException, ClassNotFoundException { conn.setAutoCommit(false); } - @AfterClass + @AfterAll public static void tearDownClass() throws SQLException { var conn = Connections.getConnection(); var stmt = conn.createStatement(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalFunctionCallTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalFunctionCallTest.java index e98c30d63b..462e6eb5fd 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalFunctionCallTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalFunctionCallTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.dsl.PathBuilder; import fluentq.core.types.dsl.StringPath; import fluentq.sql.domain.QSurvey; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationalFunctionCallTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathExtractorTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathExtractorTest.java index 79f7fd3d06..706f68adb7 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathExtractorTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathExtractorTest.java @@ -9,7 +9,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationalPathExtractorTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathTest.java index ef476269b2..9daf4b8167 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/RelationalPathTest.java @@ -7,7 +7,7 @@ import fluentq.sql.domain.QSurvey; import java.io.IOException; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationalPathTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLBindingsTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLBindingsTest.java index 29ede859a6..241328c170 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLBindingsTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLBindingsTest.java @@ -6,7 +6,7 @@ import fluentq.sql.domain.QSurvey; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLBindingsTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLCloseListenerTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLCloseListenerTest.java index 40a63d780f..615eec7239 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLCloseListenerTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLCloseListenerTest.java @@ -3,20 +3,19 @@ import static fluentq.sql.Constants.employee; import static org.assertj.core.api.Assertions.assertThat; -import fluentq.core.testutil.H2; import fluentq.sql.domain.Employee; import java.sql.SQLException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class SQLCloseListenerTest { private SQLQuery query; - @Before + @BeforeEach public void setUp() throws SQLException, ClassNotFoundException { Connections.initH2(); var conf = new Configuration(H2Templates.DEFAULT); @@ -24,7 +23,7 @@ public void setUp() throws SQLException, ClassNotFoundException { query = new SQLQuery(Connections.getConnection(), conf).select(employee).from(employee); } - @After + @AfterEach public void tearDown() throws SQLException { Connections.close(); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLExpressionsFunctionTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLExpressionsFunctionTest.java index ad1755c027..c1100007df 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLExpressionsFunctionTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLExpressionsFunctionTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.dsl.StringTemplate; import fluentq.sql.dml.SQLInsertClause; import fluentq.sql.domain.QSurvey; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLExpressionsFunctionTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLListenersTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLListenersTest.java index 0efbd2ba9a..3bba79d890 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLListenersTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLListenersTest.java @@ -18,7 +18,7 @@ import fluentq.sql.dml.SQLUpdateBatch; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLListenersTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryFactoryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryFactoryTest.java index 1d02a93770..4171e2e721 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryFactoryTest.java @@ -19,14 +19,14 @@ import java.sql.Connection; import java.util.function.Supplier; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SQLQueryFactoryTest { private SQLQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { Supplier provider = () -> EasyMock.createNiceMock(Connection.class); queryFactory = new SQLQueryFactory(SQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryTest.java index bf05969190..95604c086e 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLQueryTest.java @@ -1,13 +1,19 @@ package fluentq.sql; +import static org.junit.jupiter.api.Assertions.assertThrows; + import fluentq.sql.domain.QSurvey; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLQueryTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var survey = QSurvey.survey; - SQLExpressions.select(survey.id).from(survey).fetch(); + assertThrows( + IllegalStateException.class, + () -> { + var survey = QSurvey.survey; + SQLExpressions.select(survey.id).from(survey).fetch(); + }); } } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSerializerTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSerializerTest.java index 2436d8168c..e264ace8b1 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSerializerTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSerializerTest.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.TimeZone; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLSerializerTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2005TemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2005TemplatesTest.java index 2c6d5b20e5..0e9d961989 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2005TemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2005TemplatesTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServer2005TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2012TemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2012TemplatesTest.java index 00ddc43de2..6dd380d0ed 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2012TemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServer2012TemplatesTest.java @@ -23,7 +23,7 @@ import fluentq.core.types.dsl.Expressions; import fluentq.sql.dml.SQLDeleteClause; import fluentq.sql.dml.SQLUpdateClause; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServer2012TemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServerTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServerTemplatesTest.java index d7155dfb40..10b425202c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServerTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLServerTemplatesTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.Operation; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServerTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSubQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSubQueryTest.java index 35567860fa..c2b6190f15 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSubQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLSubQueryTest.java @@ -16,6 +16,7 @@ import static fluentq.sql.SQLExpressions.select; import static fluentq.sql.SQLExpressions.union; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.core.types.ConstantImpl; import fluentq.core.types.Expression; @@ -28,33 +29,37 @@ import fluentq.sql.domain.QEmployee; import fluentq.sql.domain.QSurvey; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLSubQueryTest { private static final QEmployee employee = QEmployee.employee; - @Test(expected = IllegalArgumentException.class) + @Test public void unknownOperator() { - Operator op = - new Operator() { - @Override - public String name() { - return "unknownfn"; - } - - @Override - public String toString() { - return name(); - } - - @Override - public Class getType() { - return Object.class; - } - }; - SQLQuery query = new SQLQuery(); - query.from(employee).where(Expressions.booleanOperation(op, employee.id)).toString(); + assertThrows( + IllegalArgumentException.class, + () -> { + Operator op = + new Operator() { + @Override + public String name() { + return "unknownfn"; + } + + @Override + public String toString() { + return name(); + } + + @Override + public Class getType() { + return Object.class; + } + }; + SQLQuery query = new SQLQuery(); + query.from(employee).where(Expressions.booleanOperation(op, employee.id)).toString(); + }); } @SuppressWarnings("unchecked") diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTemplatesTest.java index 269e6ec42e..ea27a97d20 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTemplatesTest.java @@ -28,7 +28,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTypeMappingTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTypeMappingTest.java index ab368b17ed..a2cfa52dff 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTypeMappingTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLTypeMappingTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.fail; import java.lang.reflect.Field; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLTypeMappingTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLiteTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLiteTemplatesTest.java index 73efc00e4b..33e3f9b7d6 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLiteTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SQLiteTemplatesTest.java @@ -19,7 +19,7 @@ import fluentq.core.types.Ops; import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLiteTemplatesTest extends AbstractSQLTemplatesTest { @@ -29,6 +29,7 @@ protected SQLTemplates createTemplates() { } @SuppressWarnings("unchecked") + @Test @Override public void union() { var one = Expressions.ONE; diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SchemaAndTableTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SchemaAndTableTest.java index f57f3b459e..7db82210ad 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SchemaAndTableTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SchemaAndTableTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SchemaAndTableTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectBase.java index 27c32bfb82..77bef69720 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectBase.java @@ -26,6 +26,7 @@ import static fluentq.core.Target.SQLITE; import static fluentq.core.Target.SQLSERVER; import static fluentq.core.Target.TERADATA; +import static fluentq.core.Target.TURSO; import static fluentq.sql.Constants.date; import static fluentq.sql.Constants.employee; import static fluentq.sql.Constants.employee2; @@ -102,8 +103,8 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.compress.utils.Sets; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class SelectBase extends AbstractBaseTest { @@ -130,6 +131,7 @@ private Tuple firstResult(Expression... exprs) { return query().select(exprs).fetchFirst(); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void aggregate_list() { int min = 30000, avg = 65000, max = 160000; @@ -142,6 +144,7 @@ public void aggregate_list() { .isEqualTo(max); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void aggregate_uniqueResult() { int min = 30000, avg = 65000, max = 160000; @@ -214,6 +217,7 @@ private void arithmeticTests( assertThat(firstResult(four.divide(two.multiply(two))).intValue()).isEqualTo(1); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void arithmetic() { NumberExpression one = Expressions.numberTemplate(Integer.class, "(1.0)"); @@ -289,6 +293,7 @@ public void array_projection() { } } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void beans() { var rows = query().from(employee, employee2).select(new QBeans(employee, employee2)).fetch(); @@ -313,7 +318,7 @@ public void between() { } @Test - @ExcludeIn({ORACLE, CUBRID, FIREBIRD, DB2, DERBY, SQLSERVER, SQLITE, TERADATA}) + @ExcludeIn({ORACLE, CUBRID, FIREBIRD, DB2, DERBY, SQLSERVER, SQLITE, TERADATA, TURSO}) public void boolean_all() { assertThat( query() @@ -324,7 +329,7 @@ public void boolean_all() { } @Test - @ExcludeIn({ORACLE, CUBRID, FIREBIRD, DB2, DERBY, SQLSERVER, SQLITE, TERADATA}) + @ExcludeIn({ORACLE, CUBRID, FIREBIRD, DB2, DERBY, SQLSERVER, SQLITE, TERADATA, TURSO}) public void boolean_any() { assertThat( query() @@ -415,6 +420,7 @@ public void complex_boolean() { .isEqualTo(0); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void complex_subQuery() { // alias for the salary @@ -533,7 +539,7 @@ public void custom_projection() { } @Test - @ExcludeIn({CUBRID, DB2, DERBY, HSQLDB, POSTGRESQL, SQLITE, TERADATA, H2, FIREBIRD}) + @ExcludeIn({CUBRID, DB2, DERBY, HSQLDB, POSTGRESQL, SQLITE, TERADATA, H2, FIREBIRD, TURSO}) public void dates() throws SQLException { if (!configuration.getUseLiterals()) { dates(false); @@ -541,7 +547,7 @@ public void dates() throws SQLException { } @Test - @ExcludeIn({CUBRID, DB2, DERBY, SQLITE, TERADATA, FIREBIRD}) + @ExcludeIn({CUBRID, DB2, DERBY, SQLITE, TERADATA, FIREBIRD, TURSO}) public void dates_literals() throws SQLException { if (configuration.getUseLiterals()) { dates(true); @@ -647,7 +653,7 @@ private void dates(boolean literals) throws SQLException { } @Test - @ExcludeIn({SQLITE}) + @ExcludeIn({SQLITE, TURSO}) public void date_add() { SQLQuery query = query().from(employee); var date1 = query.select(employee.datefield).fetchFirst(); @@ -661,7 +667,7 @@ public void date_add() { } @Test - @ExcludeIn({SQLITE}) + @ExcludeIn({SQLITE, TURSO}) public void date_add_Timestamp() { List> exprs = new ArrayList<>(); var dt = Expressions.currentTimestamp(); @@ -679,7 +685,7 @@ public void date_add_Timestamp() { } @Test - @ExcludeIn({DB2, SQLITE, TERADATA}) + @ExcludeIn({DB2, SQLITE, TERADATA, TURSO}) public void date_diff() { var employee2 = new QEmployee("employee2"); SQLQuery query = query().from(employee).orderBy(employee.id.asc()); @@ -720,7 +726,7 @@ public void date_diff() { // TDO Date_diff with timestamps @Test - @ExcludeIn({DB2, HSQLDB, SQLITE, TERADATA, ORACLE}) + @ExcludeIn({DB2, HSQLDB, SQLITE, TERADATA, ORACLE, TURSO}) public void date_diff2() { SQLQuery query = query().from(employee).orderBy(employee.id.asc()); @@ -757,7 +763,7 @@ public void date_diff2() { } @Test - @ExcludeIn({SQLITE, H2}) // FIXME + @ExcludeIn({SQLITE, H2, TURSO}) // FIXME public void date_trunc() { var expr = DateTimeExpression.currentTimestamp(); @@ -776,7 +782,7 @@ public void date_trunc() { } @Test - @ExcludeIn({SQLITE, TERADATA, DERBY, H2}) // FIXME + @ExcludeIn({SQLITE, TERADATA, DERBY, H2, TURSO, CUBRID}) // FIXME public void date_trunc2() { DateTimeExpression expr = DateTimeExpression.currentTimestamp(LocalDateTime.class); @@ -854,6 +860,7 @@ public void date_trunc2() { assertThat(toSecond.getSecond()).isEqualTo(date.getSecond()); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void dateTime() { SQLQuery query = query().from(employee).orderBy(employee.id.asc()); @@ -867,7 +874,7 @@ public void dateTime() { } @Test - @ExcludeIn({SQLITE}) + @ExcludeIn({SQLITE, TURSO}) public void dateTime_to_date() { firstResult(SQLExpressions.date(DateTimeExpression.currentTimestamp())); } @@ -920,7 +927,7 @@ public void factoryExpression_in_groupBy() { } @Test - @ExcludeIn({H2, SQLITE, DERBY, CUBRID, MYSQL}) + @ExcludeIn({H2, SQLITE, DERBY, CUBRID, MYSQL, TURSO}) public void full_join() throws SQLException { assertThat( query() @@ -990,7 +997,7 @@ public void groupBy_yearMonth() { } @Test - @ExcludeIn({H2, DB2, DERBY, ORACLE, SQLSERVER}) + @ExcludeIn({H2, DB2, DERBY, ORACLE, SQLSERVER, TURSO}) public void groupBy_validate() { NumberPath alias = Expressions.numberPath(BigDecimal.class, "alias"); assertThat( @@ -1050,13 +1057,18 @@ public void having_count() { } @SuppressWarnings("unchecked") - @Test(expected = IllegalArgumentException.class) + @Test public void illegalUnion() throws SQLException { - SubQueryExpression sq1 = query().from(employee).select(employee.id.max()); - SubQueryExpression sq2 = query().from(employee).select(employee.id.max()); - assertThat(query().from(employee).union(sq1, sq2).list()).isEmpty(); + assertThrows( + IllegalArgumentException.class, + () -> { + SubQueryExpression sq1 = query().from(employee).select(employee.id.max()); + SubQueryExpression sq2 = query().from(employee).select(employee.id.max()); + assertThat(query().from(employee).union(sq1, sq2).list()).isEmpty(); + }); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void in() { assertThat( @@ -1251,6 +1263,7 @@ public void limit_and_offset() throws SQLException { .isEqualTo(Arrays.asList(20, 13, 10, 2)); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void limit_and_offset_Group() { assertThat( @@ -1373,6 +1386,7 @@ public void listResults2() { assertThat(results.getTotal()).isEqualTo(10); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void listResults_factoryExpression() { var results = @@ -1415,7 +1429,7 @@ private double log(double x, int y) { } @Test - @ExcludeIn({SQLITE, DERBY}) + @ExcludeIn({SQLITE, DERBY, TURSO}) public void lPad() { assertThat(firstResult(StringExpressions.lpad(ConstantImpl.create("ab"), 4))).isEqualTo(" ab"); assertThat(firstResult(StringExpressions.lpad(ConstantImpl.create("ab"), 4, '!'))) @@ -1455,13 +1469,13 @@ protected Pair map(Tuple row) { } @Test - @ExcludeIn({HSQLDB, SQLITE}) // FIXME + @ExcludeIn({HSQLDB, SQLITE, TURSO}) // FIXME public void math() { math(Expressions.numberTemplate(Double.class, "0.50")); } @Test - @ExcludeIn({FIREBIRD, SQLSERVER, HSQLDB, SQLITE}) // FIXME + @ExcludeIn({FIREBIRD, SQLSERVER, HSQLDB, SQLITE, TURSO}) // FIXME public void math2() { math(Expressions.constant(0.5)); } @@ -1532,7 +1546,7 @@ public void nested_tuple_projection() { } @Test - @ExcludeIn({SQLITE}) + @ExcludeIn({SQLITE, TURSO}) public void no_from() { assertThat(firstResult(DateExpression.currentDate())).isNotNull(); } @@ -1670,20 +1684,24 @@ public void params_anon() { .isEqualTo("Mike"); } - @Test(expected = ParamNotSetException.class) + @Test public void params_not_set() { - var name = new Param(String.class, "name"); - assertThat( - query() - .from(employee) - .where(employee.firstname.eq(name)) - .select(employee.firstname) - .fetchFirst()) - .isEqualTo("Mike"); + assertThrows( + ParamNotSetException.class, + () -> { + var name = new Param(String.class, "name"); + assertThat( + query() + .from(employee) + .where(employee.firstname.eq(name)) + .select(employee.firstname) + .fetchFirst()) + .isEqualTo("Mike"); + }); } @Test - @ExcludeIn({DB2, DERBY, FIREBIRD, HSQLDB, ORACLE, SQLSERVER}) + @ExcludeIn({DB2, DERBY, FIREBIRD, HSQLDB, ORACLE, SQLSERVER, TURSO}) @SkipForQuoted public void path_alias() { expectedQuery = @@ -1816,17 +1834,19 @@ private double radians(double x) { return x * Math.PI / 180.0; } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void random() { firstResult(MathExpressions.random()); } @Test - @ExcludeIn({FIREBIRD, ORACLE, POSTGRESQL, SQLITE, TERADATA}) + @ExcludeIn({FIREBIRD, ORACLE, POSTGRESQL, SQLITE, TERADATA, TURSO}) public void random2() { firstResult(MathExpressions.random(10)); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void relationalPath_projection() { var results = @@ -1910,7 +1930,7 @@ public void round() { } @Test - @ExcludeIn({SQLITE, DERBY}) + @ExcludeIn({SQLITE, DERBY, TURSO}) public void rpad() { assertThat(firstResult(StringExpressions.rpad(ConstantImpl.create("ab"), 4))).isEqualTo("ab "); assertThat(firstResult(StringExpressions.rpad(ConstantImpl.create("ab"), 4, '!'))) @@ -1918,7 +1938,7 @@ public void rpad() { } @Test - @Ignore + @Disabled @ExcludeIn({ORACLE, DERBY, SQLSERVER}) public void select_booleanExpr() throws SQLException { // TODO : FIXME @@ -1926,7 +1946,7 @@ public void select_booleanExpr() throws SQLException { } @Test - @Ignore + @Disabled @ExcludeIn({ORACLE, DERBY, SQLSERVER}) public void select_booleanExpr2() throws SQLException { // TODO : FIXME @@ -1949,13 +1969,13 @@ public void select_concat() throws SQLException { } @Test - @ExcludeIn({SQLITE, CUBRID, TERADATA}) + @ExcludeIn({SQLITE, CUBRID, TERADATA, TURSO}) public void select_for_update() { assertThat(query().from(survey).forUpdate().select(survey.id).fetch()).hasSize(1); } @Test - @ExcludeIn({SQLITE, CUBRID, TERADATA}) + @ExcludeIn({SQLITE, CUBRID, TERADATA, TURSO}) public void select_for_update_Where() { assertThat( query().from(survey).forUpdate().where(survey.id.isNotNull()).select(survey.id).fetch()) @@ -1963,7 +1983,7 @@ public void select_for_update_Where() { } @Test - @ExcludeIn({SQLITE, CUBRID, TERADATA}) + @ExcludeIn({SQLITE, CUBRID, TERADATA, TURSO}) public void select_for_update_UniqueResult() { query().from(survey).forUpdate().select(survey.id).fetchOne(); } @@ -2055,6 +2075,7 @@ public void specialChars() { .isEqualTo(0); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void standardTest() { standardTest.runBooleanTests(employee.firstname.isNull(), employee2.lastname.isNotNull()); @@ -2069,7 +2090,7 @@ public void standardTest() { standardTest.runStringTests(employee.firstname, employee2.firstname, "Jennifer"); var target = Connections.getTarget(); - if (target != SQLITE) { + if (target != SQLITE && target != TURSO) { standardTest.runTimeTests(employee.timefield, employee2.timefield, time); } @@ -2089,7 +2110,7 @@ public void standardTest_turkish() { } @Test - @ExcludeIn(SQLITE) + @ExcludeIn({SQLITE, TURSO}) public void string() { StringExpression str = Expressions.stringTemplate("' abcd '"); @@ -2102,7 +2123,7 @@ public void string() { } @Test - @ExcludeIn(SQLITE) + @ExcludeIn({SQLITE, TURSO}) public void string_withTemplate() { StringExpression str = Expressions.stringTemplate("' abcd '"); @@ -2119,7 +2140,7 @@ public void string_withTemplate() { } @Test - @ExcludeIn({POSTGRESQL, SQLITE}) + @ExcludeIn({POSTGRESQL, SQLITE, TURSO}) public void string_indexOf() { StringExpression str = Expressions.stringTemplate("' abcd '"); @@ -2141,7 +2162,7 @@ public void stringFunctions2() throws SQLException { } @Test - @ExcludeIn(SQLITE) + @ExcludeIn({SQLITE, TURSO}) public void string_left() { assertThat( query() @@ -2153,7 +2174,7 @@ public void string_left() { } @Test - @ExcludeIn({DERBY, SQLITE}) + @ExcludeIn({DERBY, SQLITE, TURSO}) public void string_right() { assertThat( query() @@ -2165,7 +2186,7 @@ public void string_right() { } @Test - @ExcludeIn({DERBY, SQLITE}) + @ExcludeIn({DERBY, SQLITE, TURSO}) public void string_left_Right() { assertThat( query() @@ -2177,7 +2198,7 @@ public void string_left_Right() { } @Test - @ExcludeIn({DERBY, SQLITE}) + @ExcludeIn({DERBY, SQLITE, TURSO}) public void string_right_Left() { assertThat( query() @@ -2238,6 +2259,7 @@ public void templateExpression() { .isEqualTo(Collections.singletonList(1)); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void transform_groupBy() { var employee = new QEmployee("employee"); @@ -2326,9 +2348,12 @@ public void unique_wildcard() { assertThat(row.get(1, Object.class)).as(row.get(0, Object.class) + " is not null").isNotNull(); } - @Test(expected = NonUniqueResultException.class) + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 + @Test public void uniqueResultContract() { - query().from(employee).select(employee.all()).fetchOne(); + assertThrows( + NonUniqueResultException.class, + () -> query().from(employee).select(employee.all()).fetchOne()); } @Test @@ -2531,7 +2556,7 @@ public void withinGroup() { } @Test - @ExcludeIn({DB2, DERBY, H2}) + @ExcludeIn({DB2, DERBY, H2, TURSO}) public void yearWeek() { SQLQuery query = query().from(employee).orderBy(employee.id.asc()); assertThat(query.select(employee.datefield.yearWeek()).fetchFirst()) @@ -2546,6 +2571,7 @@ public void yearWeek_h2() { .isEqualTo(Integer.valueOf(200007)); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void statementOptions() { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectMySQLBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectMySQLBase.java index ab7c1d4704..4d565f6697 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectMySQLBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectMySQLBase.java @@ -5,7 +5,7 @@ import fluentq.core.testutil.IncludeIn; import fluentq.sql.mysql.MySQLQuery; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SelectMySQLBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectOracleBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectOracleBase.java index e917c573c2..d4181ed67d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectOracleBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectOracleBase.java @@ -9,8 +9,8 @@ import fluentq.sql.oracle.OracleQuery; import java.sql.SQLException; import java.util.logging.Logger; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class SelectOracleBase extends AbstractBaseTest { @@ -33,7 +33,7 @@ protected SQLSerializer serialize(boolean forCountRow) { } @Test - @Ignore + @Disabled public void connectBy() throws SQLException { // TODO : come up with a legal case oracleQuery() diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectTeradataBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectTeradataBase.java index 2d898c6b2d..2e781188f7 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectTeradataBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectTeradataBase.java @@ -5,7 +5,7 @@ import fluentq.core.testutil.IncludeIn; import fluentq.sql.teradata.SetQueryBandClause; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SelectTeradataBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectWindowFunctionsBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectWindowFunctionsBase.java index 44a3b37504..a2d081ee0e 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectWindowFunctionsBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SelectWindowFunctionsBase.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SelectWindowFunctionsBase extends AbstractBaseTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SerializationTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SerializationTest.java index 23a8cad9af..c759c1d69c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SerializationTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SerializationTest.java @@ -29,7 +29,7 @@ import fluentq.sql.domain.QSurvey; import java.sql.Connection; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SerializationTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SkipForQuotedExtension.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SkipForQuotedExtension.java new file mode 100644 index 0000000000..da80473add --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SkipForQuotedExtension.java @@ -0,0 +1,30 @@ +package fluentq.sql; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit 5 replacement for the former {@code SkipForQuotedRule}. Disables test methods annotated + * with {@link SkipForQuoted} when the active configuration uses quoting, schema printing or + * literals. + */ +public class SkipForQuotedExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + var testMethod = context.getTestMethod().orElse(null); + if (testMethod == null || !testMethod.isAnnotationPresent(SkipForQuoted.class)) { + return ConditionEvaluationResult.enabled("No @SkipForQuoted"); + } + var configuration = Connections.getConfiguration(); + if (configuration == null) { + return ConditionEvaluationResult.enabled("No configuration"); + } + var templates = configuration.getTemplates(); + if (templates.isUseQuotes() || templates.isPrintSchema() || configuration.getUseLiterals()) { + return ConditionEvaluationResult.disabled("Skipped for quoted templates"); + } + return ConditionEvaluationResult.enabled("Not quoted"); + } +} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SkipForQuotedRule.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SkipForQuotedRule.java deleted file mode 100644 index 682cc8c48a..0000000000 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SkipForQuotedRule.java +++ /dev/null @@ -1,26 +0,0 @@ -package fluentq.sql; - -import fluentq.core.testutil.EmptyStatement; -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - -public class SkipForQuotedRule implements MethodRule { - - private final Configuration configuration; - - public SkipForQuotedRule(Configuration conf) { - this.configuration = conf; - } - - @Override - public Statement apply(Statement base, FrameworkMethod method, Object target) { - var templates = configuration.getTemplates(); - if (templates.isUseQuotes() || templates.isPrintSchema() || configuration.getUseLiterals()) { - var skip = method.getMethod().isAnnotationPresent(SkipForQuoted.class); - return skip ? EmptyStatement.DEFAULT : base; - } else { - return base; - } - } -} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SubqueriesBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SubqueriesBase.java index 9d0a411dbb..0185fb9263 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SubqueriesBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/SubqueriesBase.java @@ -11,6 +11,7 @@ import static fluentq.core.Target.SQLITE; import static fluentq.core.Target.SQLSERVER; import static fluentq.core.Target.TERADATA; +import static fluentq.core.Target.TURSO; import static fluentq.sql.Constants.employee; import static fluentq.sql.Constants.employee2; import static fluentq.sql.Constants.survey; @@ -30,7 +31,7 @@ import java.math.BigDecimal; import java.sql.SQLException; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class SubqueriesBase extends AbstractBaseTest { @@ -89,6 +90,7 @@ public void subQueries() throws SQLException { assertThat(list).isNotEmpty(); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void subQuery_alias() { query() @@ -98,7 +100,7 @@ public void subQuery_alias() { } @Test - @ExcludeIn(SQLITE) + @ExcludeIn({SQLITE, TURSO}) public void subQuery_all() { query() .from(employee) @@ -107,7 +109,7 @@ public void subQuery_all() { } @Test - @ExcludeIn(SQLITE) + @ExcludeIn({SQLITE, TURSO}) public void subQuery_any() { query() .from(employee) diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TargetExtension.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TargetExtension.java new file mode 100644 index 0000000000..1274c6af54 --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TargetExtension.java @@ -0,0 +1,39 @@ +package fluentq.sql; + +import fluentq.core.Target; +import fluentq.core.testutil.ExcludeIn; +import fluentq.core.testutil.IncludeIn; +import java.util.Arrays; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit 5 replacement for the former {@code TargetRule}. Disables a test (or container) when the + * configured {@link Target} is excluded via {@link ExcludeIn} or not part of {@link IncludeIn}. + */ +public class TargetExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + var target = Connections.getTarget(); + if (target == null) { + return ConditionEvaluationResult.enabled("No target configured"); + } + var element = context.getElement().orElse(null); + if (element == null) { + return ConditionEvaluationResult.enabled("No annotated element"); + } + // excluded in given targets + var ex = element.getAnnotation(ExcludeIn.class); + if (ex != null && Arrays.asList(ex.value()).contains(target)) { + return ConditionEvaluationResult.disabled("Excluded in target " + target); + } + // included only in given targets + var in = element.getAnnotation(IncludeIn.class); + if (in != null && !Arrays.asList(in.value()).contains(target)) { + return ConditionEvaluationResult.disabled("Not included in target " + target); + } + return ConditionEvaluationResult.enabled("Enabled for target " + target); + } +} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TargetRule.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TargetRule.java deleted file mode 100644 index 9f46d88e60..0000000000 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TargetRule.java +++ /dev/null @@ -1,34 +0,0 @@ -package fluentq.sql; - -import fluentq.core.Target; -import fluentq.core.testutil.EmptyStatement; -import fluentq.core.testutil.ExcludeIn; -import fluentq.core.testutil.IncludeIn; -import java.util.Arrays; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class TargetRule implements TestRule { - - @Override - public Statement apply(Statement base, Description description) { - var target = Connections.getTarget(); - var run = target == null || isExecuted(description, target); - return run ? base : EmptyStatement.DEFAULT; - } - - private boolean isExecuted(Description description, Target target) { - var ex = description.getAnnotation(ExcludeIn.class); - // excluded in given targets - if (ex != null && Arrays.asList(ex.value()).contains(target)) { - return false; - } - // included only in given targets - var in = description.getAnnotation(IncludeIn.class); - if (in != null && !Arrays.asList(in.value()).contains(target)) { - return false; - } - return true; - } -} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplateTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplateTest.java index 3f0c72af79..2390ca3b07 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplateTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplateTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.StringExpression; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TemplateTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplatesTest.java index e69cb89583..d55ae3eba8 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TemplatesTest.java @@ -14,7 +14,7 @@ package fluentq.sql; import fluentq.core.TemplatesTestBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TemplatesTest extends TemplatesTestBase { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TeradataTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TeradataTemplatesTest.java index 6918865232..8082c3be4d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TeradataTemplatesTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TeradataTemplatesTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.types.Ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TeradataTemplatesTest extends AbstractSQLTemplatesTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TursoTemplatesTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TursoTemplatesTest.java new file mode 100644 index 0000000000..c5600fb305 --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TursoTemplatesTest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fluentq.sql; + +import static fluentq.sql.SQLExpressions.select; +import static org.assertj.core.api.Assertions.assertThat; + +import fluentq.core.types.Ops; +import fluentq.core.types.Path; +import fluentq.core.types.dsl.Expressions; +import org.junit.jupiter.api.Test; + +public class TursoTemplatesTest extends AbstractSQLTemplatesTest { + + @Override + protected SQLTemplates createTemplates() { + return new TursoTemplates(); + } + + @SuppressWarnings("unchecked") + @Test + @Override + public void union() { + var one = Expressions.ONE; + var two = Expressions.TWO; + var three = Expressions.THREE; + Path col1 = Expressions.path(Integer.class, "col1"); + Union union = query.union(select(one.as(col1)), select(two), select(three)); + + assertThat(union.toString()) + .isEqualTo( + """ + select 1 as col1 + union + select 2 + union + select 3"""); + } + + @Test + public void precedence() { + // || + // * / % + var p1 = getPrecedence(Ops.MULT, Ops.DIV, Ops.MOD); + // + - + var p2 = getPrecedence(Ops.ADD, Ops.SUB); + // << >> & | + // < <= > >= + var p3 = getPrecedence(Ops.LT, Ops.GT, Ops.LOE, Ops.GOE); + // = == != <> IS IS NOT IN LIKE GLOB MATCH REGEXP + var p4 = + getPrecedence( + Ops.EQ, + Ops.EQ_IGNORE_CASE, + Ops.IS_NULL, + Ops.IS_NOT_NULL, + Ops.IN, + Ops.LIKE, + Ops.LIKE_ESCAPE, + Ops.MATCHES); + // AND + var p5 = getPrecedence(Ops.AND); + // OR + var p6 = getPrecedence(Ops.OR); + + assertThat(p1 < p2).isTrue(); + assertThat(p2 < p3).isTrue(); + assertThat(p3 < p4).isTrue(); + assertThat(p4 < p5).isTrue(); + assertThat(p5 < p6).isTrue(); + } +} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TypesBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TypesBase.java index 061b2a2cca..6370899122 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TypesBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/TypesBase.java @@ -3,6 +3,7 @@ import static fluentq.core.Target.CUBRID; import static fluentq.core.Target.POSTGRESQL; import static fluentq.core.Target.TERADATA; +import static fluentq.core.Target.TURSO; import fluentq.core.testutil.ExcludeIn; import fluentq.core.types.Path; @@ -14,7 +15,7 @@ import java.sql.SQLException; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class TypesBase extends AbstractBaseTest { @@ -51,7 +52,7 @@ public void create_tables() { } @Test - @ExcludeIn({CUBRID, POSTGRESQL, TERADATA}) + @ExcludeIn({CUBRID, POSTGRESQL, TERADATA, TURSO}) public void dump_types() throws SQLException { var conn = Connections.getConnection(); var md = conn.getMetaData(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionBase.java index a63a0de6f8..d7004815f5 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionBase.java @@ -21,8 +21,8 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.Collections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public abstract class UnionBase extends AbstractBaseTest { @@ -170,7 +170,7 @@ public void union4() { @SuppressWarnings("unchecked") @Test @ExcludeIn({DERBY, CUBRID, FIREBIRD, TERADATA}) - @Ignore // FIXME + @Disabled // FIXME public void union5() { /* (select e.ID, e.FIRSTNAME, superior.ID as sup_id, superior.FIRSTNAME as sup_name * from EMPLOYEE e join EMPLOYEE superior on e.SUPERIOR_ID = superior.ID) diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionSubQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionSubQueryTest.java index 8f621c6772..f83009b469 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionSubQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UnionSubQueryTest.java @@ -23,7 +23,7 @@ import fluentq.core.types.dsl.NumberPath; import fluentq.core.types.dsl.SimpleExpression; import fluentq.core.types.dsl.SimplePath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UnionSubQueryTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UpdateBase.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UpdateBase.java index d6c56000bf..b72c405041 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UpdateBase.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/UpdateBase.java @@ -21,6 +21,7 @@ import static fluentq.core.Target.ORACLE; import static fluentq.core.Target.SQLSERVER; import static fluentq.core.Target.TERADATA; +import static fluentq.core.Target.TURSO; import static fluentq.sql.Constants.survey; import static fluentq.sql.SQLExpressions.selectOne; import static org.assertj.core.api.Assertions.assertThat; @@ -35,9 +36,9 @@ import java.sql.SQLException; import java.util.Collections; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public abstract class UpdateBase extends AbstractBaseTest { @@ -46,16 +47,17 @@ protected void reset() throws SQLException { insert(survey).values(1, "Hello World", "Hello").execute(); } - @Before + @BeforeEach public void setUp() throws SQLException { reset(); } - @After + @AfterEach public void tearDown() throws SQLException { reset(); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update() throws SQLException { // original state @@ -81,6 +83,7 @@ public void update_limit() { assertThat(update(survey).set(survey.name, "S").limit(2).execute()).isEqualTo(2); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update2() throws SQLException { List> paths = Collections.>singletonList(survey.name); @@ -105,6 +108,7 @@ public void update3() { assertThat(update(survey).set(survey.name, survey.name.append("X")).execute()).isEqualTo(1); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update4() { assertThat(insert(survey).values(2, "A", "B").execute()).isEqualTo(1); @@ -112,6 +116,7 @@ public void update4() { .isEqualTo(1); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update5() { assertThat(insert(survey).values(3, "B", "C").execute()).isEqualTo(1); @@ -142,6 +147,7 @@ public void setNullEmptyRootPath() { assertThat(execute(update(survey).setNull(name))).isEqualTo(count); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void batch() throws SQLException { assertThat(insert(survey).values(2, "A", "B").execute()).isEqualTo(1); @@ -155,6 +161,7 @@ public void batch() throws SQLException { assertThat(update.execute()).isEqualTo(2); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void batch_templates() throws SQLException { assertThat(insert(survey).values(2, "A", "B").execute()).isEqualTo(1); @@ -172,6 +179,7 @@ public void batch_templates() throws SQLException { assertThat(update.execute()).isEqualTo(2); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update_with_subQuery_exists() { var survey1 = new QSurvey("s1"); @@ -197,6 +205,7 @@ public void update_with_subQuery_exists_Params() { assertThat(update.execute()).isEqualTo(0); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update_with_subQuery_exists2() { var survey1 = new QSurvey("s1"); @@ -207,6 +216,7 @@ public void update_with_subQuery_exists2() { assertThat(update.execute()).isEqualTo(0); } + @ExcludeIn(TURSO) // Turso 0.6.0 gap, see #1812 @Test public void update_with_subQuery_notExists() { var survey1 = new QSurvey("s1"); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WindowFunctionTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WindowFunctionTest.java index fdcdfbb02b..beefa8f321 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WindowFunctionTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WindowFunctionTest.java @@ -5,7 +5,7 @@ import fluentq.core.types.Expression; import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.NumberPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class WindowFunctionTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WithinGroupTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WithinGroupTest.java index 16cdc7f8e8..fd482984c5 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WithinGroupTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/WithinGroupTest.java @@ -5,8 +5,8 @@ import fluentq.core.types.Expression; import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.NumberPath; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class WithinGroupTest { NumberPath path = null; @@ -16,7 +16,7 @@ private static String toString(Expression e) { return new SQLSerializer(Configuration.DEFAULT).handle(e).toString(); } - @Before + @BeforeEach public void setPaths() { this.path = Expressions.numberPath(Long.class, "path"); this.path2 = Expressions.numberPath(Long.class, "path2"); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AbstractMapperTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AbstractMapperTest.java index 564f6ca2dc..d93e63d70d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AbstractMapperTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AbstractMapperTest.java @@ -18,7 +18,7 @@ import java.math.BigDecimal; import java.sql.Date; import java.sql.Time; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public abstract class AbstractMapperTest { @@ -49,7 +49,7 @@ public static class EmployeeNames { protected Employee employee; - @Before + @BeforeEach public void setUp() { employee = new Employee(); employee.setDatefield(new Date(0)); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AnnotationMapperTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AnnotationMapperTest.java index ad893b807e..c524211220 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AnnotationMapperTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/AnnotationMapperTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.sql.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnnotationMapperTest extends AbstractMapperTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/BeanMapperTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/BeanMapperTest.java index 000f3e13a9..6cabe2b5ac 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/BeanMapperTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/BeanMapperTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.sql.domain.QEmployee; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BeanMapperTest extends AbstractMapperTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/DefaultMapperTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/DefaultMapperTest.java index 563a1341a1..72d1c05ede 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/DefaultMapperTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/DefaultMapperTest.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DefaultMapperTest extends AbstractMapperTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLDeleteClauseTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLDeleteClauseTest.java index 4d21a69268..f1d4a9f365 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLDeleteClauseTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLDeleteClauseTest.java @@ -1,30 +1,39 @@ package fluentq.sql.dml; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.sql.KeyAccessorsTest.QEmployee; import fluentq.sql.SQLTemplates; import java.util.Collections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class SQLDeleteClauseTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var emp1 = new QEmployee("emp1"); - var delete = new SQLDeleteClause(null, SQLTemplates.DEFAULT, emp1); - delete.where(emp1.id.eq(1)); - delete.execute(); + assertThrows( + IllegalStateException.class, + () -> { + var emp1 = new QEmployee("emp1"); + var delete = new SQLDeleteClause(null, SQLTemplates.DEFAULT, emp1); + delete.where(emp1.id.eq(1)); + delete.execute(); + }); } - @Test(expected = IllegalArgumentException.class) - @Ignore + @Test + @Disabled public void error() { - var emp1 = new QEmployee("emp1"); - var emp2 = new QEmployee("emp2"); - var delete = new SQLDeleteClause(null, SQLTemplates.DEFAULT, emp1); - delete.where(emp2.id.eq(1)); + assertThrows( + IllegalArgumentException.class, + () -> { + var emp1 = new QEmployee("emp1"); + var emp2 = new QEmployee("emp2"); + var delete = new SQLDeleteClause(null, SQLTemplates.DEFAULT, emp1); + delete.where(emp2.id.eq(1)); + }); } @Test diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLInsertClauseTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLInsertClauseTest.java index a5611760d7..fd48e27c8d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLInsertClauseTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLInsertClauseTest.java @@ -1,21 +1,26 @@ package fluentq.sql.dml; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.core.QueryFlag; import fluentq.sql.KeyAccessorsTest.QEmployee; import fluentq.sql.SQLTemplates; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLInsertClauseTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var emp1 = new QEmployee("emp1"); - var insert = new SQLInsertClause(null, SQLTemplates.DEFAULT, emp1); - insert.set(emp1.id, 1); - insert.execute(); + assertThrows( + IllegalStateException.class, + () -> { + var emp1 = new QEmployee("emp1"); + var insert = new SQLInsertClause(null, SQLTemplates.DEFAULT, emp1); + insert.set(emp1.id, 1); + insert.execute(); + }); } @Test diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLMergeClauseTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLMergeClauseTest.java index 4c2461e6d9..ef78e2f1a6 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLMergeClauseTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLMergeClauseTest.java @@ -4,7 +4,7 @@ import fluentq.sql.H2Templates; import fluentq.sql.KeyAccessorsTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLMergeClauseTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLUpdateClauseTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLUpdateClauseTest.java index b705701baa..fe91caad52 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLUpdateClauseTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/dml/SQLUpdateClauseTest.java @@ -2,21 +2,26 @@ import static fluentq.sql.SQLExpressions.select; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.core.QueryFlag.Position; import fluentq.sql.KeyAccessorsTest.QEmployee; import fluentq.sql.SQLTemplates; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLUpdateClauseTest { - @Test(expected = IllegalStateException.class) + @Test public void noConnection() { - var emp1 = new QEmployee("emp1"); - var update = new SQLUpdateClause(null, SQLTemplates.DEFAULT, emp1); - update.set(emp1.id, 1); - update.execute(); + assertThrows( + IllegalStateException.class, + () -> { + var emp1 = new QEmployee("emp1"); + var update = new SQLUpdateClause(null, SQLTemplates.DEFAULT, emp1); + update.set(emp1.id, 1); + update.execute(); + }); } @Test diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/GeneratedKeysH2Test.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/GeneratedKeysH2Test.java index 3e10f2dd03..6f35aa8ce7 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/GeneratedKeysH2Test.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/GeneratedKeysH2Test.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Collections; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class GeneratedKeysH2Test { @@ -33,7 +33,7 @@ public class GeneratedKeysH2Test { private Statement stmt; - @Before + @BeforeEach public void setUp() throws ClassNotFoundException, SQLException { Class.forName("org.h2.Driver"); var url = "jdbc:h2:./target/h2-gen;MODE=legacy"; @@ -41,7 +41,7 @@ public void setUp() throws ClassNotFoundException, SQLException { stmt = conn.createStatement(); } - @After + @AfterEach public void tearDown() throws SQLException { try { stmt.close(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/H2QueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/H2QueryTest.java index de71d926f8..9f32946050 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/H2QueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/h2/H2QueryTest.java @@ -3,8 +3,8 @@ import fluentq.sql.H2Templates; import fluentq.sql.SQLQuery; import fluentq.sql.domain.QSurvey; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class H2QueryTest { @@ -12,7 +12,7 @@ public class H2QueryTest { private QSurvey survey = new QSurvey("survey"); - @Before + @BeforeEach public void setUp() { query = new SQLQuery(H2Templates.builder().newLineToSingleSpace().build()); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/hsqldb/HsqldbQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/hsqldb/HsqldbQueryTest.java index 73b52282eb..55c7c43903 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/hsqldb/HsqldbQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/hsqldb/HsqldbQueryTest.java @@ -3,8 +3,8 @@ import fluentq.sql.HSQLDBTemplates; import fluentq.sql.SQLQuery; import fluentq.sql.domain.QSurvey; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class HsqldbQueryTest { @@ -12,7 +12,7 @@ public class HsqldbQueryTest { private QSurvey survey = new QSurvey("survey"); - @Before + @BeforeEach public void setUp() { query = new SQLQuery(HSQLDBTemplates.builder().newLineToSingleSpace().build()); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/SQLServerQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/SQLServerQueryTest.java index 577d3a1ce0..dd589d3499 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/SQLServerQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/SQLServerQueryTest.java @@ -18,7 +18,7 @@ import fluentq.sql.SQLServerTemplates; import fluentq.sql.domain.QEmployee; import fluentq.sql.domain.QSurvey; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SQLServerQueryTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/WindowFunctionTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/WindowFunctionTest.java index 7556bd71cc..6e675bf4c2 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/WindowFunctionTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mssql/WindowFunctionTest.java @@ -21,7 +21,7 @@ import fluentq.sql.Configuration; import fluentq.sql.SQLSerializer; import fluentq.sql.SQLTemplates; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class WindowFunctionTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/GeneratedKeysMySQLTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/GeneratedKeysMySQLTest.java index 14806bb554..b1eaf2024c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/GeneratedKeysMySQLTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/GeneratedKeysMySQLTest.java @@ -15,7 +15,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import fluentq.core.testutil.MySQL; import fluentq.sql.H2Templates; import fluentq.sql.QGeneratedKeysEntity; import fluentq.sql.dml.SQLInsertClause; @@ -23,19 +22,19 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class GeneratedKeysMySQLTest { private Connection conn; private Statement stmt; - @Before + @BeforeEach public void setUp() throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); var url = "jdbc:mysql://localhost:3306/fluentq"; @@ -43,7 +42,7 @@ public void setUp() throws ClassNotFoundException, SQLException { stmt = conn.createStatement(); } - @After + @AfterEach public void tearDown() throws SQLException { try { stmt.close(); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryFactoryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryFactoryTest.java index 5b62af234b..ff10cab1ca 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryFactoryTest.java @@ -21,14 +21,14 @@ import java.sql.Connection; import java.util.function.Supplier; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MySQLQueryFactoryTest { private MySQLQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { Supplier provider = () -> EasyMock.createNiceMock(Connection.class); queryFactory = new MySQLQueryFactory(SQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryTest.java index 21c7c51bc3..0ffe455433 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/mysql/MySQLQueryTest.java @@ -18,15 +18,15 @@ import fluentq.sql.MySQLTemplates; import fluentq.sql.domain.QSurvey; import java.io.File; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MySQLQueryTest { private MySQLQuery query; private QSurvey survey = new QSurvey("survey"); - @Before + @BeforeEach public void setUp() { query = new MySQLQuery(null, MySQLTemplates.builder().newLineToSingleSpace().build()); query.from(survey); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleGrammarTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleGrammarTest.java index 2386b5256d..4160fa576e 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleGrammarTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleGrammarTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OracleGrammarTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryFactoryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryFactoryTest.java index 80997ed9e6..22c1430e8f 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryFactoryTest.java @@ -20,14 +20,14 @@ import java.sql.Connection; import java.util.function.Supplier; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class OracleQueryFactoryTest { private OracleQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { Supplier provider = () -> EasyMock.createNiceMock(Connection.class); queryFactory = new OracleQueryFactory(SQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryTest.java index 6ed253cef7..611fb994a2 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/oracle/OracleQueryTest.java @@ -17,8 +17,8 @@ import fluentq.sql.OracleTemplates; import fluentq.sql.domain.QSurvey; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class OracleQueryTest { @@ -26,7 +26,7 @@ public class OracleQueryTest { private QSurvey survey = new QSurvey("survey"); - @Before + @BeforeEach public void setUp() { query = new OracleQuery(null, OracleTemplates.builder().newLineToSingleSpace().build()); query.from(survey); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryFactoryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryFactoryTest.java index 42daed36d1..736fe47fb2 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryFactoryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryFactoryTest.java @@ -20,14 +20,14 @@ import java.sql.Connection; import java.util.function.Supplier; import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class PostgreSQLQueryFactoryTest { private PostgreSQLQueryFactory queryFactory; - @Before + @BeforeEach public void setUp() { Supplier provider = () -> EasyMock.createNiceMock(Connection.class); queryFactory = new PostgreSQLQueryFactory(SQLTemplates.DEFAULT, provider); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryTest.java index c979b30242..2c6d4548b3 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/postgresql/PostgreSQLQueryTest.java @@ -5,8 +5,8 @@ import fluentq.sql.PostgreSQLTemplates; import fluentq.sql.domain.QEmployee; import fluentq.sql.domain.QSurvey; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class PostgreSQLQueryTest { @@ -16,7 +16,7 @@ public class PostgreSQLQueryTest { private QEmployee employee = new QEmployee("employee"); - @Before + @BeforeEach public void setUp() { query = new PostgreSQLQuery( diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/AbstractSuite.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/AbstractSuite.java index 0638194775..0847392d0d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/AbstractSuite.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/AbstractSuite.java @@ -2,14 +2,11 @@ import fluentq.sql.Connections; import java.sql.SQLException; -import org.junit.AfterClass; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; -@RunWith(Enclosed.class) public abstract class AbstractSuite { - @AfterClass + @AfterAll public static void tearDown() throws SQLException { Connections.close(); } diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDLiteralsSuiteTest.java index 4d35b40581..6e382c3eda 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.CUBRID; import fluentq.sql.BeanPopulationBase; import fluentq.sql.CUBRIDTemplates; import fluentq.sql.Connections; @@ -14,37 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Ignore -@Category(CUBRID.class) +@Tag("fluentq.core.testutil.CUBRID") public class CUBRIDLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initCubrid(); Connections.initConfiguration(CUBRIDTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDSuiteTest.java index a59972f165..d4eb5fa0c9 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/CUBRIDSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.CUBRID; import fluentq.sql.BeanPopulationBase; import fluentq.sql.CUBRIDTemplates; import fluentq.sql.Connections; @@ -14,37 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Ignore -@Category(CUBRID.class) +@Tag("fluentq.core.testutil.CUBRID") public class CUBRIDSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initCubrid(); Connections.initConfiguration(CUBRIDTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2LiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2LiteralsSuiteTest.java index 4ff4f66767..79f8e2247d 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2LiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2LiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.DB2; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DB2Templates; @@ -16,39 +15,53 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(DB2.class) +@Tag("fluentq.core.testutil.DB2") public class DB2LiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initDB2(); Connections.initConfiguration(DB2Templates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2SuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2SuiteTest.java index 3a8f79c871..52c0a0a566 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2SuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DB2SuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.DB2; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DB2Templates; @@ -16,39 +15,53 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(DB2.class) +@Tag("fluentq.core.testutil.DB2") public class DB2SuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initDB2(); Connections.initConfiguration(DB2Templates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbyLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbyLiteralsSuiteTest.java index 0f285f5635..dd4e62a98e 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbyLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbyLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Derby; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Derby.class) +@Tag("fluentq.core.testutil.Derby") public class DerbyLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initDerby(); Connections.initConfiguration(DerbyTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbySuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbySuiteTest.java index e9a70789b5..0b441a3044 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbySuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/DerbySuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Derby; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Derby.class) +@Tag("fluentq.core.testutil.Derby") public class DerbySuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initDerby(); Connections.initConfiguration(DerbyTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdLiteralsSuiteTest.java index 9d8073ff01..eb12e88086 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Firebird; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Firebird.class) +@Tag("fluentq.core.testutil.Firebird") public class FirebirdLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initFirebird(); Connections.initConfiguration(FirebirdTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdSuiteTest.java index 0fcb53346a..12b051a58c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/FirebirdSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Firebird; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Firebird.class) +@Tag("fluentq.core.testutil.Firebird") public class FirebirdSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initFirebird(); Connections.initConfiguration(FirebirdTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2ExceptionSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2ExceptionSuiteTest.java index 959bad6536..98cac59f38 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2ExceptionSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2ExceptionSuiteTest.java @@ -4,24 +4,23 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.QueryException; -import fluentq.core.testutil.H2; import fluentq.sql.AbstractBaseTest; import fluentq.sql.Connections; import fluentq.sql.DefaultSQLExceptionTranslator; import fluentq.sql.H2Templates; import fluentq.sql.SQLExceptionTranslator; import java.sql.SQLException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2ExceptionSuiteTest extends AbstractBaseTest { private static final SQLExceptionTranslator exceptionTranslator = DefaultSQLExceptionTranslator.DEFAULT; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration(H2Templates.builder().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2LiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2LiteralsSuiteTest.java index 7a88c1c4e9..e3e6bda713 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2LiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2LiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.H2; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -15,37 +14,50 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2LiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration(H2Templates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2SuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2SuiteTest.java index 7793c39ae1..c0a2880321 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2SuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2SuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.H2; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -15,37 +14,50 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2SuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration(H2Templates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithQuotingTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithQuotingTest.java index afa69fea5d..2a9c54e3a8 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithQuotingTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithQuotingTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.H2; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2WithQuotingTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration(H2Templates.builder().quote().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithSchemaTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithSchemaTest.java index 673662f096..f1d74d1eff 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithSchemaTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/H2WithSchemaTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.H2; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -15,37 +14,50 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class H2WithSchemaTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initH2(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbLiteralsSuiteTest.java index 6bfdbe35b6..0b226c9478 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.HSQLDB; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(HSQLDB.class) +@Tag("fluentq.core.testutil.HSQLDB") public class HsqldbLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initHSQL(); Connections.initConfiguration(HSQLDBTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbSuiteTest.java index 18ab792ea6..8a96e5311c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/HsqldbSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.HSQLDB; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(HSQLDB.class) +@Tag("fluentq.core.testutil.HSQLDB") public class HsqldbSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initHSQL(); Connections.initConfiguration(HSQLDBTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLLiteralsSuiteTest.java index b7adb84a60..05226c7e7b 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.SQLServer; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -16,39 +15,53 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initSQLServer(); Connections.initConfiguration(SQLServer2008Templates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLSuiteTest.java index 3d4c302e00..7ca372742b 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MSSQLSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.SQLServer; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -16,39 +15,53 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class MSSQLSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initSQLServer(); Connections.initConfiguration(SQLServer2008Templates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLLiteralsSuiteTest.java index c4e1d9b358..c5e4d67bbe 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.MySQL; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -15,37 +14,50 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectMySQL extends SelectMySQLBase {} + @Nested + class SelectMySQL extends SelectMySQLBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initMySQL(); Connections.initConfiguration(MySQLTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLSuiteTest.java index eeb1e6fa70..9049098153 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.MySQL; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -15,37 +14,50 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectMySQL extends SelectMySQLBase {} + @Nested + class SelectMySQL extends SelectMySQLBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initMySQL(); Connections.initConfiguration(MySQLTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLWithQuotingTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLWithQuotingTest.java index b881ddc88c..a46e3e4d72 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLWithQuotingTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/MySQLWithQuotingTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.MySQL; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class MySQLWithQuotingTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initMySQL(); Connections.initConfiguration(MySQLTemplates.builder().quote().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleLiteralsSuiteTest.java index a183b1849a..748a6494c1 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Oracle; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -16,39 +15,53 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Oracle.class) +@Tag("fluentq.core.testutil.Oracle") public class OracleLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectOracle extends SelectOracleBase {} + @Nested + class SelectOracle extends SelectOracleBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initOracle(); Connections.initConfiguration(OracleTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleSuiteTest.java index aee86f05de..0b954ec312 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Oracle; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -16,39 +15,53 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Oracle.class) +@Tag("fluentq.core.testutil.Oracle") public class OracleSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectOracle extends SelectOracleBase {} + @Nested + class SelectOracle extends SelectOracleBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initOracle(); Connections.initConfiguration(OracleTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleWithQuotingTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleWithQuotingTest.java index 32717cd511..56ac050897 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleWithQuotingTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/OracleWithQuotingTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.Oracle; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(Oracle.class) +@Tag("fluentq.core.testutil.Oracle") public class OracleWithQuotingTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initOracle(); Connections.initConfiguration(OracleTemplates.builder().quote().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLLiteralsSuiteTest.java index 9fc6b4a1ff..4feb4212d9 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.PostgreSQL; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Configuration; import fluentq.sql.Connections; @@ -17,22 +16,30 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class PostgreSQLLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase { + @Nested + class KeywordQuoting extends KeywordQuotingBase { private Configuration previous; + @BeforeEach @Override public void setUp() throws Exception { // NOTE: replacing the templates with a non-quoting one @@ -42,6 +49,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { super.tearDown(); @@ -50,25 +58,34 @@ public void tearDown() throws Exception { } } - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initPostgreSQL(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLSuiteTest.java index 4d3fc1e40e..d800b246c2 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/PostgreSQLSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.PostgreSQL; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Configuration; import fluentq.sql.Connections; @@ -17,22 +16,30 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class PostgreSQLSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase { + @Nested + class KeywordQuoting extends KeywordQuotingBase { private Configuration previous; + @BeforeEach @Override public void setUp() throws Exception { // NOTE: replacing the templates with a non-quoting one @@ -42,6 +49,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { super.tearDown(); @@ -50,25 +58,34 @@ public void tearDown() throws Exception { } } - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class MergeUsing extends MergeUsingBase {} + @Nested + class MergeUsing extends MergeUsingBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class SelectWindowFunctions extends SelectWindowFunctionsBase {} + @Nested + class SelectWindowFunctions extends SelectWindowFunctionsBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initPostgreSQL(); Connections.initConfiguration( diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteLiteralsSuiteTest.java index 3169a12225..d9c7e8d92c 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteLiteralsSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteLiteralsSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.SQLite; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLite.class) +@Tag("fluentq.core.testutil.SQLite") public class SQLiteLiteralsSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initSQLite(); Connections.initConfiguration(SQLiteTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteSuiteTest.java index 454cbd0004..fca5f57555 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteSuiteTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/SQLiteSuiteTest.java @@ -1,6 +1,5 @@ package fluentq.sql.suites; -import fluentq.core.testutil.SQLite; import fluentq.sql.BeanPopulationBase; import fluentq.sql.Connections; import fluentq.sql.DeleteBase; @@ -14,35 +13,47 @@ import fluentq.sql.TypesBase; import fluentq.sql.UnionBase; import fluentq.sql.UpdateBase; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; -@Category(SQLite.class) +@Tag("fluentq.core.testutil.SQLite") public class SQLiteSuiteTest extends AbstractSuite { - public static class BeanPopulation extends BeanPopulationBase {} + @Nested + class BeanPopulation extends BeanPopulationBase {} - public static class Delete extends DeleteBase {} + @Nested + class Delete extends DeleteBase {} - public static class Insert extends InsertBase {} + @Nested + class Insert extends InsertBase {} - public static class KeywordQuoting extends KeywordQuotingBase {} + @Nested + class KeywordQuoting extends KeywordQuotingBase {} - public static class LikeEscape extends LikeEscapeBase {} + @Nested + class LikeEscape extends LikeEscapeBase {} - public static class Merge extends MergeBase {} + @Nested + class Merge extends MergeBase {} - public static class Select extends SelectBase {} + @Nested + class Select extends SelectBase {} - public static class Subqueries extends SubqueriesBase {} + @Nested + class Subqueries extends SubqueriesBase {} - public static class Types extends TypesBase {} + @Nested + class Types extends TypesBase {} - public static class Union extends UnionBase {} + @Nested + class Union extends UnionBase {} - public static class Update extends UpdateBase {} + @Nested + class Update extends UpdateBase {} - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Connections.initSQLite(); Connections.initConfiguration(SQLiteTemplates.builder().newLineToSingleSpace().build()); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/TursoLiteralsSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/TursoLiteralsSuiteTest.java new file mode 100644 index 0000000000..d6e19daf50 --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/TursoLiteralsSuiteTest.java @@ -0,0 +1,62 @@ +package fluentq.sql.suites; + +import fluentq.sql.BeanPopulationBase; +import fluentq.sql.Connections; +import fluentq.sql.DeleteBase; +import fluentq.sql.InsertBase; +import fluentq.sql.KeywordQuotingBase; +import fluentq.sql.LikeEscapeBase; +import fluentq.sql.MergeBase; +import fluentq.sql.SelectBase; +import fluentq.sql.SubqueriesBase; +import fluentq.sql.TursoTemplates; +import fluentq.sql.TypesBase; +import fluentq.sql.UnionBase; +import fluentq.sql.UpdateBase; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; + +@Tag("fluentq.core.testutil.Turso") +public class TursoLiteralsSuiteTest extends AbstractSuite { + + @Nested + class BeanPopulation extends BeanPopulationBase {} + + @Nested + class Delete extends DeleteBase {} + + @Nested + class Insert extends InsertBase {} + + @Nested + class KeywordQuoting extends KeywordQuotingBase {} + + @Nested + class LikeEscape extends LikeEscapeBase {} + + @Nested + class Merge extends MergeBase {} + + @Nested + class Select extends SelectBase {} + + @Nested + class Subqueries extends SubqueriesBase {} + + @Nested + class Types extends TypesBase {} + + @Nested + class Union extends UnionBase {} + + @Nested + class Update extends UpdateBase {} + + @BeforeAll + public static void setUp() throws Exception { + Connections.initTurso(); + Connections.initConfiguration(TursoTemplates.builder().newLineToSingleSpace().build()); + Connections.getConfiguration().setUseLiterals(true); + } +} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/TursoSuiteTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/TursoSuiteTest.java new file mode 100644 index 0000000000..aaec0695bd --- /dev/null +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/suites/TursoSuiteTest.java @@ -0,0 +1,61 @@ +package fluentq.sql.suites; + +import fluentq.sql.BeanPopulationBase; +import fluentq.sql.Connections; +import fluentq.sql.DeleteBase; +import fluentq.sql.InsertBase; +import fluentq.sql.KeywordQuotingBase; +import fluentq.sql.LikeEscapeBase; +import fluentq.sql.MergeBase; +import fluentq.sql.SelectBase; +import fluentq.sql.SubqueriesBase; +import fluentq.sql.TursoTemplates; +import fluentq.sql.TypesBase; +import fluentq.sql.UnionBase; +import fluentq.sql.UpdateBase; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; + +@Tag("fluentq.core.testutil.Turso") +public class TursoSuiteTest extends AbstractSuite { + + @Nested + class BeanPopulation extends BeanPopulationBase {} + + @Nested + class Delete extends DeleteBase {} + + @Nested + class Insert extends InsertBase {} + + @Nested + class KeywordQuoting extends KeywordQuotingBase {} + + @Nested + class LikeEscape extends LikeEscapeBase {} + + @Nested + class Merge extends MergeBase {} + + @Nested + class Select extends SelectBase {} + + @Nested + class Subqueries extends SubqueriesBase {} + + @Nested + class Types extends TypesBase {} + + @Nested + class Union extends UnionBase {} + + @Nested + class Update extends UpdateBase {} + + @BeforeAll + public static void setUp() throws Exception { + Connections.initTurso(); + Connections.initConfiguration(TursoTemplates.builder().newLineToSingleSpace().build()); + } +} diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/teradata/SetQueryBandClauseTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/teradata/SetQueryBandClauseTest.java index dd2f46269d..920843894b 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/teradata/SetQueryBandClauseTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/teradata/SetQueryBandClauseTest.java @@ -5,8 +5,8 @@ import fluentq.sql.Configuration; import fluentq.sql.SQLTemplates; import java.sql.Connection; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SetQueryBandClauseTest { @@ -14,7 +14,7 @@ public class SetQueryBandClauseTest { private SetQueryBandClause clause; - @Before + @BeforeEach public void setUp() { conf = new Configuration(SQLTemplates.DEFAULT); conf.setUseLiterals(true); diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/ArrayTypeTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/ArrayTypeTest.java index 748b03b669..ddc9e88b2b 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/ArrayTypeTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/ArrayTypeTest.java @@ -8,7 +8,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ArrayTypeTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocalDateTimeTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocalDateTimeTest.java index 2023610c9f..2fa791d6ae 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocalDateTimeTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocalDateTimeTest.java @@ -4,7 +4,7 @@ import java.sql.SQLException; import java.time.LocalDateTime; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LocalDateTimeTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocaleTypeTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocaleTypeTest.java index 4ef36c3723..51e11524e1 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocaleTypeTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/LocaleTypeTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LocaleTypeTest { diff --git a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/TypeTest.java b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/TypeTest.java index e380e156a8..0f04c438b9 100644 --- a/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/TypeTest.java +++ b/fluentq-libraries/fluentq-sql/src/test/java/fluentq/sql/types/TypeTest.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.UUID; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeTest implements InvocationHandler { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/BooleanExtensionsTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/BooleanExtensionsTest.java index 701edce0d9..ddf7cdab4a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/BooleanExtensionsTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/BooleanExtensionsTest.java @@ -17,12 +17,11 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BooleanExtensionsTest extends AbstractProcessorTest { @@ -37,10 +36,8 @@ public void process() throws IOException { process(FluentQAnnotationProcessor.class, sources, "booleanExtensions"); var qtypeContent = - new String( - Files.readAllBytes( - Path.of("target", "booleanExtensions", "com", "fluentq", "QExampleEntity.java")), - StandardCharsets.UTF_8); + Files.readString( + Path.of("target", "booleanExtensions", "com", "fluentq", "QExampleEntity.java")); assertThat(qtypeContent).contains("ext.java.lang.QBoolean booleanProp"); assertThat(qtypeContent).contains("ext.java.lang.QBoolean booleanProp2"); } @@ -53,10 +50,8 @@ public void process2() throws IOException { new File(packagePath, "ExampleEntity.java").getPath()); process(FluentQAnnotationProcessor.class, sources, "booleanExtensions2"); var qtypeContent = - new String( - Files.readAllBytes( - Path.of("target", "booleanExtensions2", "com", "fluentq", "QExampleEntity.java")), - StandardCharsets.UTF_8); + Files.readString( + Path.of("target", "booleanExtensions2", "com", "fluentq", "QExampleEntity.java")); assertThat(qtypeContent).contains("ext.java.lang.QBoolean booleanProp"); assertThat(qtypeContent).contains("ext.java.lang.QBoolean booleanProp2"); } diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/DateExtensionsTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/DateExtensionsTest.java index 05ec874e68..e1fc3c9932 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/DateExtensionsTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/DateExtensionsTest.java @@ -17,16 +17,15 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class DateExtensionsTest extends AbstractProcessorTest { private static final String packagePath = "src/test/java/fluentq/apt/"; @@ -43,8 +42,7 @@ public void handles_date_extensions_correctly() throws IOException, InterruptedE assertThat(qType).exists(); var modified = qType.lastModified(); Thread.sleep(1000); - assertThat(new String(Files.readAllBytes(qType.toPath()), StandardCharsets.UTF_8)) - .contains("QDate"); + assertThat(Files.readString(qType.toPath())).contains("QDate"); // EntityWithExtensions has not changed, QEntityWithExtensions is not overwritten compile(FluentQAnnotationProcessor.class, sources, "overwrite3"); @@ -56,15 +54,13 @@ public void handles_date_extensions_correctly() throws IOException, InterruptedE assertThat(modified < qType.lastModified()) .as("" + modified + " >= " + qType.lastModified()) .isTrue(); - assertThat(new String(Files.readAllBytes(qType.toPath()), StandardCharsets.UTF_8)) - .contains("QDate"); + assertThat(Files.readString(qType.toPath())).contains("QDate"); // QEntityWithExtensions is deleted and regenerated assertThat(qType.delete()).isTrue(); compile(FluentQAnnotationProcessor.class, sources, "overwrite3"); assertThat(qType).exists(); - assertThat(new String(Files.readAllBytes(qType.toPath()), StandardCharsets.UTF_8)) - .contains("QDate"); + assertThat(Files.readString(qType.toPath())).contains("QDate"); } @Override diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EclipseCompilationTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EclipseCompilationTest.java index c0071db54c..112d42b9c7 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EclipseCompilationTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EclipseCompilationTest.java @@ -20,21 +20,20 @@ import fluentq.core.util.FileUtils; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import javax.tools.JavaCompiler; import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class EclipseCompilationTest { private static final String packagePath = "src/test/apt/fluentq/eclipse/"; @Test - @Ignore + @Disabled public void test() throws IOException { System.setProperty("jdt.compiler.useSingleThread", "true"); // select classes @@ -78,7 +77,7 @@ public void test() throws IOException { var resultFile = new File("target/out-eclipse/fluentq/eclipse/QSimpleEntity.java"); assertThat(resultFile).exists(); - var result = new String(Files.readAllBytes(resultFile.toPath()), StandardCharsets.UTF_8); + var result = Files.readString(resultFile.toPath()); assertThat(result).contains("NumberPath bigDecimalProp"); assertThat(result).contains("NumberPath integerProp"); assertThat(result).contains("NumberPath intProp"); diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EmbeddableTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EmbeddableTest.java index a6f8d865a9..a0c5856614 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EmbeddableTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EmbeddableTest.java @@ -16,7 +16,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EmbeddableTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EntityExtensionsTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EntityExtensionsTest.java index a9a08ad05a..e6384a43b3 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EntityExtensionsTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/EntityExtensionsTest.java @@ -17,16 +17,15 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class EntityExtensionsTest extends AbstractProcessorTest { private static final String packagePath = "src/test/java/fluentq/apt/"; @@ -43,8 +42,7 @@ public void handles_entity_extensions_correctly() throws IOException, Interrupte assertThat(qType).exists(); var modified = qType.lastModified(); Thread.sleep(1000); - assertThat(new String(Files.readAllBytes(qType.toPath()), StandardCharsets.UTF_8)) - .contains("extension()"); + assertThat(Files.readString(qType.toPath())).contains("extension()"); // EntityWithExtensions has not changed, QEntityWithExtensions is not overwritten compile(FluentQAnnotationProcessor.class, sources, "overwrite2"); @@ -56,15 +54,13 @@ public void handles_entity_extensions_correctly() throws IOException, Interrupte assertThat(modified < qType.lastModified()) .as("" + modified + " >= " + qType.lastModified()) .isTrue(); - assertThat(new String(Files.readAllBytes(qType.toPath()), StandardCharsets.UTF_8)) - .contains("extension()"); + assertThat(Files.readString(qType.toPath())).contains("extension()"); // QEntityWithExtensions is deleted and regenerated assertThat(qType.delete()).isTrue(); compile(FluentQAnnotationProcessor.class, sources, "overwrite2"); assertThat(qType).exists(); - assertThat(new String(Files.readAllBytes(qType.toPath()), StandardCharsets.UTF_8)) - .contains("extension()"); + assertThat(Files.readString(qType.toPath())).contains("extension()"); } @Override diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedClassesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedClassesTest.java index b85bf0c3e6..6b0049790a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedClassesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedClassesTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExcludedClassesTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedPackagesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedPackagesTest.java index b759949213..27d70ce087 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedPackagesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/ExcludedPackagesTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExcludedPackagesTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericExporterTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericExporterTest.java index d7d2f96b45..faff6b0b76 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericExporterTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericExporterTest.java @@ -17,11 +17,10 @@ import jakarta.persistence.Transient; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericExporterTest extends AbstractProcessorTest { @@ -136,8 +135,8 @@ private void execute(List expected, String genericExporterFolder, String if (!other.exists() || !other.isFile()) { continue; } - var result1 = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - var result2 = new String(Files.readAllBytes(other.toPath()), StandardCharsets.UTF_8); + var result1 = Files.readString(file.toPath()); + var result2 = Files.readString(other.toPath()); if (!result1.equals(result2)) { if (!expected.contains(file.getName())) { System.err.println(file.getName()); diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericTest.java index cb3c41816b..235e8f29c1 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/GenericTest.java @@ -4,7 +4,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedClassesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedClassesTest.java index fc2a4636ee..caa99ef937 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedClassesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedClassesTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class IncludedClassesTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedPackagesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedPackagesTest.java index d6dbba7187..31858b2a0f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedPackagesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncludedPackagesTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class IncludedPackagesTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncrementalCompilationTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncrementalCompilationTest.java index b10b21d085..f79644ee4a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncrementalCompilationTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IncrementalCompilationTest.java @@ -19,10 +19,10 @@ import java.io.IOException; import java.nio.file.Files; import java.util.Collections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class IncrementalCompilationTest extends AbstractProcessorTest { private static final String packagePath = "src/test/java/fluentq/apt/domain/"; diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IntegerExtensionsTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IntegerExtensionsTest.java index f037d1ac80..317f26e2a9 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IntegerExtensionsTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/IntegerExtensionsTest.java @@ -4,12 +4,11 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class IntegerExtensionsTest extends AbstractProcessorTest { @@ -23,10 +22,8 @@ public void process() throws IOException { new File(packagePath, "ExampleEntity2.java").getPath()); process(FluentQAnnotationProcessor.class, sources, "integerExtensions"); var qtypeContent = - new String( - Files.readAllBytes( - Path.of("target", "integerExtensions", "com", "fluentq", "QExampleEntity2.java")), - StandardCharsets.UTF_8); + Files.readString( + Path.of("target", "integerExtensions", "com", "fluentq", "QExampleEntity2.java")); // The superclass' id property is inherited, but can't be assigned to the custom QInteger assertThat(qtypeContent) .contains( diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NamePrefixTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NamePrefixTest.java index 4a37671775..1ffdf74e1c 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NamePrefixTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NamePrefixTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NamePrefixTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NameSuffixTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NameSuffixTest.java index 509d3a4c2d..6b616ed2d6 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NameSuffixTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NameSuffixTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NameSuffixTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NoteTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NoteTest.java index fe891d4aed..217fbce6f9 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NoteTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/NoteTest.java @@ -6,7 +6,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NoteTest extends AbstractProcessorTest { @@ -31,28 +31,33 @@ protected ByteArrayOutputStream getStdErr() { return err; } - protected boolean isStdErrEmpty() { - return getStdErr().toByteArray().length == 0; + /** + * Whether the processor emitted info-level notes (controlled by {@code fluentq.logInfo}). Cannot + * simply check that stderr is empty: the processor also reports unrelated warnings (e.g. circular + * Q-class references) regardless of the logInfo option. + */ + protected boolean hasInfoNotes() { + return getStdErr().toString().contains("Note:"); } @Test public void processDefault() throws IOException { aptOptions = Collections.emptyList(); process(); - assertThat(isStdErrEmpty()).isTrue(); + assertThat(hasInfoNotes()).isFalse(); } @Test public void processEnabled() throws IOException { aptOptions = Collections.singletonList("-Afluentq.logInfo=true"); process(); - assertThat(isStdErrEmpty()).isFalse(); + assertThat(hasInfoNotes()).isTrue(); } @Test public void processDisabled() throws IOException { aptOptions = Collections.singletonList("-Afluentq.logInfo=false"); process(); - assertThat(isStdErrEmpty()).isTrue(); + assertThat(hasInfoNotes()).isFalse(); } } diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/PackageSuffixTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/PackageSuffixTest.java index 36a2f782f2..120364a1a1 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/PackageSuffixTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/PackageSuffixTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PackageSuffixTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/UnknownAsEmbeddableTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/UnknownAsEmbeddableTest.java index 40f287ce5e..0dc3b38163 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/UnknownAsEmbeddableTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/UnknownAsEmbeddableTest.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UnknownAsEmbeddableTest extends AbstractProcessorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClasses2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClasses2Test.java index abd396f0a9..1c63718166 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClasses2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClasses2Test.java @@ -25,7 +25,7 @@ import java.io.Serializable; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings({"rawtypes", "serial", "unchecked"}) public class AbstractClasses2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClassesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClassesTest.java index 6f5bfaf455..18ce74e9e0 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClassesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractClassesTest.java @@ -21,7 +21,7 @@ import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings({"rawtypes", "serial", "unchecked"}) public class AbstractClassesTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractEntityTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractEntityTest.java index dce29747a8..c3d0fc3e07 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractEntityTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractEntityTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AbstractEntityTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties2Test.java index 3c659af28f..2866d3dbc2 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties2Test.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AbstractProperties2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties3Test.java index 3ccc3890cc..7a6c4cc9d3 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractProperties3Test.java @@ -17,10 +17,10 @@ import java.io.Serializable; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class AbstractProperties3Test { @MappedSuperclass diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractPropertiesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractPropertiesTest.java index e2248106cf..552493ae4a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractPropertiesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AbstractPropertiesTest.java @@ -15,9 +15,9 @@ import jakarta.persistence.Entity; import java.io.Serializable; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class AbstractPropertiesTest { public abstract static class GenericEntity> { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnimalTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnimalTest.java index b3548d0dee..14721b61f1 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnimalTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnimalTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnimalTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotatedGettersTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotatedGettersTest.java index e82d2a76a0..630856bcef 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotatedGettersTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotatedGettersTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnnotatedGettersTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotationTypeTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotationTypeTest.java index 9602b45038..1975e42168 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotationTypeTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnnotationTypeTest.java @@ -6,9 +6,9 @@ import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; import java.lang.annotation.Annotation; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class AnnotationTypeTest { @MappedSuperclass diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyPathTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyPathTest.java index 52ebc63de4..9ab8d7f63a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyPathTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyPathTest.java @@ -11,7 +11,7 @@ import jakarta.persistence.OneToMany; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnyPathTest { @Entity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyUsageTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyUsageTest.java index 2cb94dd1ad..f13fa145e3 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyUsageTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/AnyUsageTest.java @@ -24,7 +24,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AnyUsageTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array2Test.java index 310a6faa6a..166a8dfd6e 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array2Test.java @@ -2,7 +2,7 @@ import fluentq.core.annotations.QueryProjection; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Array2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array3Test.java index 748bf88d28..baac407316 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Array3Test.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Array3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayExtTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayExtTest.java index 7e2f7a2527..3baa391221 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayExtTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayExtTest.java @@ -23,7 +23,7 @@ import fluentq.core.types.dsl.StringPath; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ArrayExtTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayTest.java index bd9a2ffbcb..469ac94a23 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ArrayTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ArrayTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/BlockingTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/BlockingTest.java index 82c5375152..7539d9cd9c 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/BlockingTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/BlockingTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryTransient; import fluentq.core.annotations.QueryType; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class BlockingTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/CollectionTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/CollectionTest.java index ea4e5a6259..011cb8d7a8 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/CollectionTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/CollectionTest.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CollectionTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ComparableTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ComparableTest.java index fcef4488c3..caeaaafd4a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ComparableTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ComparableTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ComparableTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ConstructorTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ConstructorTest.java index 7c6e08d9ac..2293fab1ca 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ConstructorTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ConstructorTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QuerySupertype; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConstructorTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DeepInitializationTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DeepInitializationTest.java index 4e80afdf51..a31545200d 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DeepInitializationTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DeepInitializationTest.java @@ -14,7 +14,7 @@ import jakarta.persistence.OneToOne; import jakarta.persistence.SequenceGenerator; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DeepInitializationTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate2Test.java index 4eac3f21bc..e9b71492fa 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate2Test.java @@ -21,7 +21,7 @@ import fluentq.core.types.Path; import fluentq.core.types.dsl.Expressions; import fluentq.core.types.dsl.NumberExpression; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Delegate2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate3Test.java index 00da542ebf..605906dbe7 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Delegate3Test.java @@ -4,7 +4,7 @@ import fluentq.core.types.dsl.BooleanExpression; import fluentq.core.types.dsl.ComparablePath; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Delegate3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DelegateTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DelegateTest.java index 407b6a94c3..0d572dd859 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DelegateTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/DelegateTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.ConstantImpl; import fluentq.core.types.Expression; import fluentq.core.types.dsl.StringPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DelegateTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable2Test.java index 99d65074b6..513e65aedb 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable2Test.java @@ -21,8 +21,8 @@ import fluentq.core.domain.MyEmbeddable; import fluentq.core.types.PathMetadata; import fluentq.core.types.dsl.PathInits; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class Embeddable2Test { @@ -42,7 +42,7 @@ public abstract static class SomeEntityClassHavingMyEmbeddable { public static class SomeEntity extends SomeMappedSuperClassHavingMyEmbeddable {} @Test - @Ignore + @Disabled public void mapped_superClass_constructors() throws SecurityException, NoSuchMethodException { assertThat( QEmbeddable2Test_SomeMappedSuperClassHavingMyEmbeddable.class.getConstructor( @@ -51,7 +51,7 @@ public void mapped_superClass_constructors() throws SecurityException, NoSuchMet } @Test - @Ignore + @Disabled public void entity_constructors() throws SecurityException, NoSuchMethodException { assertThat( QEmbeddable2Test_SomeEntityClassHavingMyEmbeddable.class.getConstructor( diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable3Test.java index f3e226c033..c7e19d84c9 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embeddable3Test.java @@ -3,7 +3,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.annotations.QueryProjection; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Embeddable3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableDeepTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableDeepTest.java index 3daf3bed87..3d6e8cc22d 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableDeepTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableDeepTest.java @@ -18,9 +18,9 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; import java.io.Serializable; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled @SuppressWarnings("serial") public class EmbeddableDeepTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableInterfaceTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableInterfaceTest.java index 335bef8a75..5be5e5da9c 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableInterfaceTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableInterfaceTest.java @@ -19,7 +19,7 @@ import jakarta.persistence.Embeddable; import jakarta.persistence.Entity; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EmbeddableInterfaceTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableTest.java index 601e750243..0fb4b5ef67 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddableTest.java @@ -17,9 +17,9 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QuerySupertype; import java.util.List; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class EmbeddableTest { @QueryEntity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embedded2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embedded2Test.java index 3ee3148e64..53c52ddab2 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embedded2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Embedded2Test.java @@ -21,7 +21,7 @@ import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Embedded2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddedTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddedTest.java index 73ce903333..f4c5dc001b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddedTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EmbeddedTest.java @@ -20,7 +20,7 @@ import jakarta.persistence.Embedded; import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EmbeddedTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityInheritanceTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityInheritanceTest.java index b3b37c76e2..6997f2d869 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityInheritanceTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityInheritanceTest.java @@ -17,7 +17,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EntityInheritanceTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityTest.java index 72bf98a624..f149df7f64 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EntityTest.java @@ -14,13 +14,14 @@ package fluentq.apt.domain; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; import fluentq.core.annotations.QuerySupertype; import fluentq.core.types.PathMetadata; import fluentq.core.types.dsl.PathInits; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EntityTest extends AbstractTest { @@ -99,9 +100,13 @@ public void constructors() throws SecurityException, NoSuchMethodException { QEntityTest_Supertype2.class.getConstructor(types); } - @Test(expected = NoSuchMethodException.class) - public void constructors2() throws SecurityException, NoSuchMethodException { - var types = new Class[] {Class.class, PathMetadata.class, PathInits.class}; - QEntityTest_EntityNoReferences.class.getConstructor(types); + @Test + public void constructors2() throws SecurityException { + assertThrows( + NoSuchMethodException.class, + () -> { + var types = new Class[] {Class.class, PathMetadata.class, PathInits.class}; + QEntityTest_EntityNoReferences.class.getConstructor(types); + }); } } diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum2Test.java index cfce0121aa..1b33d7fb1c 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum2Test.java @@ -14,9 +14,9 @@ package fluentq.apt.domain; import fluentq.core.annotations.QueryEntity; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class Enum2Test { @QueryEntity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum3Test.java index 6c3b93ffde..d9abd04ece 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum3Test.java @@ -3,7 +3,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Enumerated; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Enum3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum4Test.java index 1fc3617fb0..79215bece4 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Enum4Test.java @@ -2,9 +2,9 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class Enum4Test { @Entity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EnumTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EnumTest.java index 623de2c024..7f6ccadd93 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EnumTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/EnumTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EnumTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExcludedClassTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExcludedClassTest.java index 23d73c8f4a..566a55263c 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExcludedClassTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExcludedClassTest.java @@ -13,9 +13,11 @@ */ package fluentq.apt.domain; +import static org.junit.jupiter.api.Assertions.assertThrows; + import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryExclude; -import org.junit.Test; +import org.junit.jupiter.api.Test; @QueryExclude @QueryEntity @@ -25,13 +27,17 @@ public class ExcludedClassTest { @QueryEntity public static class InnerClass {} - @Test(expected = ClassNotFoundException.class) - public void outerClass() throws ClassNotFoundException { - Class.forName(getClass().getPackage().getName() + ".Q" + getClass().getSimpleName()); + @Test + public void outerClass() { + assertThrows( + ClassNotFoundException.class, + () -> Class.forName(getClass().getPackage().getName() + ".Q" + getClass().getSimpleName())); } - @Test(expected = ClassNotFoundException.class) - public void innerClass() throws ClassNotFoundException { - Class.forName(getClass().getPackage().getName() + ".QExcludedClassTest_InnerClass"); + @Test + public void innerClass() { + assertThrows( + ClassNotFoundException.class, + () -> Class.forName(getClass().getPackage().getName() + ".QExcludedClassTest_InnerClass")); } } diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExpressionTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExpressionTest.java index fffc7957f2..e65557f630 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExpressionTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExpressionTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExpressionTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExtendsAndSuperTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExtendsAndSuperTest.java index 8edcf00ab9..b85b915d62 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExtendsAndSuperTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExtendsAndSuperTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExtendsAndSuperTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEmbeddableTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEmbeddableTest.java index cb22aedab2..c8a21aaaae 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEmbeddableTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEmbeddableTest.java @@ -16,9 +16,9 @@ import fluentq.core.domain.EmbeddableWithoutQType; import jakarta.persistence.Embedded; import jakarta.persistence.Entity; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class ExternalEmbeddableTest { @Entity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEntityTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEntityTest.java index 7bc4997634..a2446dd5ae 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEntityTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ExternalEntityTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.domain.AbstractEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ExternalEntityTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic10Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic10Test.java index 1a6a39adf7..948c240bee 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic10Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic10Test.java @@ -5,7 +5,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToOne; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic10Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic11Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic11Test.java index b498b27a4c..b728293697 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic11Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic11Test.java @@ -2,7 +2,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic11Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic12Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic12Test.java index 9af35ce7a6..fa3bee4975 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic12Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic12Test.java @@ -9,7 +9,7 @@ import jakarta.persistence.ManyToMany; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic12Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic13Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic13Test.java index 75c8d79bd6..7a86f4a0af 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic13Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic13Test.java @@ -1,7 +1,7 @@ package fluentq.apt.domain; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic13Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic14Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic14Test.java index f84249b64a..436442ee8d 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic14Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic14Test.java @@ -5,7 +5,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic14Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic15Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic15Test.java index 01838c665e..53a22b255b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic15Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic15Test.java @@ -4,7 +4,7 @@ import jakarta.persistence.MappedSuperclass; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic15Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic16Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic16Test.java index 56cd9d14b9..c4363cf340 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic16Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic16Test.java @@ -6,7 +6,7 @@ import jakarta.persistence.MappedSuperclass; import java.util.SortedSet; import java.util.TreeSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic16Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic2Test.java index b3fce36dcc..00e68acfca 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic2Test.java @@ -4,7 +4,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic2Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic3Test.java index 99e85ccd7f..5a4cdb58c0 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic3Test.java @@ -3,7 +3,7 @@ import fluentq.core.types.dsl.StringPath; import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic3Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic4Test.java index 25e252060f..91fa898ecf 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic4Test.java @@ -1,7 +1,7 @@ package fluentq.apt.domain; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic4Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic5Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic5Test.java index 835de18613..9dc1837989 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic5Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic5Test.java @@ -2,7 +2,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic5Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic6Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic6Test.java index 6ac08fd501..6d9e074150 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic6Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic6Test.java @@ -1,7 +1,7 @@ package fluentq.apt.domain; import jakarta.persistence.Entity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic6Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic7Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic7Test.java index 67c290f08c..4097f0aef7 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic7Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic7Test.java @@ -3,7 +3,7 @@ import fluentq.core.annotations.QueryEntity; import java.util.Collection; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic7Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic8Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic8Test.java index 0cf6ab5817..a64eb5acb1 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic8Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic8Test.java @@ -5,7 +5,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QuerySupertype; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic8Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic9Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic9Test.java index 5d9214ab62..fd0db3b10b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic9Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Generic9Test.java @@ -6,7 +6,7 @@ import jakarta.persistence.MappedSuperclass; import jakarta.persistence.Table; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic9Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericSignatureTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericSignatureTest.java index bbaf91c567..26bd430bb4 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericSignatureTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericSignatureTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericSignatureTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericStackOverflowTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericStackOverflowTest.java index 27db7f8024..5dce16e043 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericStackOverflowTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericStackOverflowTest.java @@ -5,7 +5,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QuerySupertype; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericStackOverflowTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericTest.java index 288c1416c9..2123d23c50 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/GenericTest.java @@ -20,7 +20,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryTransient; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Hierarchy2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Hierarchy2Test.java index cd1d246446..adf725ea72 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Hierarchy2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Hierarchy2Test.java @@ -19,9 +19,9 @@ import jakarta.persistence.Entity; import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToOne; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class Hierarchy2Test { @MappedSuperclass diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/HierarchyTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/HierarchyTest.java index 07d40505ae..f75d180ed2 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/HierarchyTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/HierarchyTest.java @@ -19,7 +19,7 @@ import fluentq.core.annotations.QueryType; import jakarta.persistence.Column; import jakarta.persistence.Entity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HierarchyTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InitTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InitTest.java index 50e6296926..6c76767a65 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InitTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InitTest.java @@ -7,7 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InitTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InnerExtensionsTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InnerExtensionsTest.java index 3c58df3c00..a1f9a6f2b7 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InnerExtensionsTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InnerExtensionsTest.java @@ -6,12 +6,11 @@ import fluentq.apt.FluentQAnnotationProcessor; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InnerExtensionsTest extends AbstractProcessorTest { @@ -25,10 +24,8 @@ public void process() throws IOException { new File(packagePath, "ExampleEntity2.java").getPath()); process(FluentQAnnotationProcessor.class, sources, "innerextensions"); var qtypeContent = - new String( - Files.readAllBytes( - Path.of("target", "innerextensions", "com", "fluentq", "QExampleEntity2.java")), - StandardCharsets.UTF_8); + Files.readString( + Path.of("target", "innerextensions", "com", "fluentq", "QExampleEntity2.java")); assertThat(qtypeContent) .contains("return InnerExtensions.ExampleEntity2Extensions.isZero(this);"); } diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType2Test.java index 1ff74a97cc..810bd3640e 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType2Test.java @@ -12,7 +12,7 @@ import jakarta.persistence.MappedSuperclass; import jakarta.persistence.Table; import org.hibernate.annotations.NaturalId; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InterfaceType2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType3Test.java index ad105e7f9a..59dcc9596d 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceType3Test.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InterfaceType3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceTypeTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceTypeTest.java index be52905074..2af62d2f7b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceTypeTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/InterfaceTypeTest.java @@ -17,7 +17,7 @@ import fluentq.core.types.dsl.ListPath; import fluentq.core.types.dsl.NumberPath; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InterfaceTypeTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JPATest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JPATest.java index 4208c211f3..b9d1bb0c9f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JPATest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JPATest.java @@ -16,7 +16,7 @@ import fluentq.core.types.dsl.StringPath; import jakarta.persistence.Entity; import jakarta.persistence.Transient; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JPATest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310Test.java index 4b8cb73d56..38bbe11732 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310Test.java @@ -9,7 +9,7 @@ import jakarta.persistence.TemporalType; import java.time.Instant; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310TimeSupportTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310TimeSupportTest.java index 96b7e36b81..3fc9a10e95 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310TimeSupportTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JSR310TimeSupportTest.java @@ -23,7 +23,7 @@ import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZonedDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JSR310TimeSupportTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JodaMoneyTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JodaMoneyTest.java index d18c7982f5..a06c9256dd 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JodaMoneyTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/JodaMoneyTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.joda.money.QMoney; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JodaMoneyTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/KeywordsTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/KeywordsTest.java index 1b14ccdd4b..6bce2c136f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/KeywordsTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/KeywordsTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import jakarta.persistence.Entity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class KeywordsTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/LiteralEntityTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/LiteralEntityTest.java index 18b872a64d..1909f5acb6 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/LiteralEntityTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/LiteralEntityTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.types.dsl.EnumPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LiteralEntityTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManagedEmailTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManagedEmailTest.java index 6231988034..87a0de87c2 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManagedEmailTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManagedEmailTest.java @@ -6,7 +6,7 @@ import jakarta.persistence.MapKey; import jakarta.persistence.OneToMany; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ManagedEmailTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManyToManyTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManyToManyTest.java index 7738617811..52e6e18418 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManyToManyTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ManyToManyTest.java @@ -5,7 +5,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.ManyToMany; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ManyToManyTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/MonitoredCompanyTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/MonitoredCompanyTest.java index b3a5867e2d..3c90299aef 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/MonitoredCompanyTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/MonitoredCompanyTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MonitoredCompanyTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/NumberTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/NumberTest.java index 3d8acd4ee4..d68774dd94 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/NumberTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/NumberTest.java @@ -2,9 +2,9 @@ import fluentq.apt.domain.custom.CustomNumber; import fluentq.core.annotations.QueryEntity; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class NumberTest { @QueryEntity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OneToOneTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OneToOneTest.java index 4ef40ab877..f87e5e5e8f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OneToOneTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OneToOneTest.java @@ -4,7 +4,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.OneToOne; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OneToOneTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OrderTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OrderTest.java index ffdd1f79cc..7c0d67a273 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OrderTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/OrderTest.java @@ -5,7 +5,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.OneToMany; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OrderTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathMetadataTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathMetadataTest.java index ed50ae3e2c..71e883d0c5 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathMetadataTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathMetadataTest.java @@ -18,14 +18,14 @@ import fluentq.core.types.ConstantImpl; import fluentq.core.types.dsl.StringExpression; import java.util.Map; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class PathMetadataTest { - @Before + @BeforeEach public void setUp() { assertThat(QAnimalTest_Animal.animal).isNotNull(); assertThat(QAnimalTest_Cat.cat).isNotNull(); diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathTest.java index c9eb252c5c..98e642e994 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PathTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PathTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PersonTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PersonTest.java index de5a76bc06..986b38fd7e 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PersonTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PersonTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PersonTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties2Test.java index 33d9349fb8..a7d8113e45 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties2Test.java @@ -1,11 +1,13 @@ package fluentq.apt.domain; +import static org.junit.jupiter.api.Assertions.assertThrows; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Properties2Test { @@ -29,8 +31,9 @@ public String getId() { } } - @Test(expected = NoSuchFieldException.class) - public void test() throws NoSuchFieldException { - QProperties2Test_ConcreteX.class.getDeclaredField("id"); + @Test + public void test() { + assertThrows( + NoSuchFieldException.class, () -> QProperties2Test_ConcreteX.class.getDeclaredField("id")); } } diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties3Test.java index b27f2f8893..8a9556a006 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties3Test.java @@ -7,7 +7,7 @@ import jakarta.persistence.TemporalType; import java.time.LocalDateTime; import java.time.ZoneId; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Properties3Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties4Test.java index 8182218cac..a845f5dbda 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Properties4Test.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import jakarta.persistence.MappedSuperclass; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Properties4Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertiesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertiesTest.java index 0dd179f71b..56195df73b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertiesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertiesTest.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PropertiesTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertyTypeTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertyTypeTest.java index 72ab8ebc79..25d910315b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertyTypeTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/PropertyTypeTest.java @@ -16,10 +16,10 @@ import fluentq.core.annotations.PropertyType; import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryType; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore +@Disabled public class PropertyTypeTest { @QueryEntity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryByExampleTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryByExampleTest.java index 3f855a89e1..22311e19d8 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryByExampleTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryByExampleTest.java @@ -4,7 +4,7 @@ import fluentq.core.annotations.QueryDelegate; import fluentq.core.types.Predicate; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryByExampleTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable2Test.java index 262df37fe1..a0341c7a0b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable2Test.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbeddable2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable3Test.java index 76e3dee6dc..45ff6eb510 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddable3Test.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbeddable3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddableTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddableTest.java index b782509281..d079508324 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddableTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddableTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbeddableTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded2Test.java index d6dd8c7a68..44854417c8 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded2Test.java @@ -18,7 +18,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.annotations.QueryEmbedded; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbedded2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded3Test.java index c27989d52c..47442a8c7c 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded3Test.java @@ -18,7 +18,7 @@ import fluentq.core.annotations.QueryEmbedded; import fluentq.core.annotations.QueryEntity; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbedded3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded4Test.java index 2b268ea62a..e387429efb 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded4Test.java @@ -18,7 +18,7 @@ import fluentq.core.annotations.QueryEmbedded; import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbedded4Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded5Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded5Test.java index 4bc819f775..a48a525e2d 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded5Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded5Test.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbedded5Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded6Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded6Test.java index 7861868d38..21575d69bb 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded6Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded6Test.java @@ -19,7 +19,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.types.dsl.EntityPathBase; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbedded6Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded7Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded7Test.java index 78264218bb..69fb6d94bb 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded7Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbedded7Test.java @@ -9,7 +9,7 @@ import java.util.Collection; import java.util.Locale; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbedded7Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddedTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddedTest.java index 7e7e686e84..8b34459ad8 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddedTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryEmbeddedTest.java @@ -19,7 +19,7 @@ import fluentq.core.annotations.QueryEntity; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryEmbeddedTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryExcludeTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryExcludeTest.java index 70b3393680..6aebbf53d6 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryExcludeTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryExcludeTest.java @@ -18,7 +18,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryExclude; import fluentq.core.types.dsl.EntityPathBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryExcludeTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit2Test.java index c84cd506a0..7b1752c5aa 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit2Test.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInit2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit3Test.java index ea69609dcd..4853293067 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit3Test.java @@ -19,7 +19,7 @@ import fluentq.core.annotations.QueryInit; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInit3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit4Test.java index d61912f4f5..4080ea5d6a 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit4Test.java @@ -6,7 +6,7 @@ import fluentq.core.annotations.QueryInit; import java.sql.Date; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInit4Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit5Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit5Test.java index 5515508a3d..b7b076308f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit5Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit5Test.java @@ -4,7 +4,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInit5Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit6Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit6Test.java index 0cf5e682a9..0a36538ab9 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit6Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit6Test.java @@ -20,7 +20,7 @@ import java.util.HashSet; import java.util.Set; import org.hibernate.proxy.HibernateProxy; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInit6Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit7Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit7Test.java index 8ea24959d6..135cd99f87 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit7Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInit7Test.java @@ -27,7 +27,7 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.MappedSuperclass; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInit7Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInitTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInitTest.java index 69a9c35ec1..7ed7af0587 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInitTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryInitTest.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryInit; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryInitTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionBuilderTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionBuilderTest.java index aafa26b32b..70858f839f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionBuilderTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionBuilderTest.java @@ -1,10 +1,10 @@ package fluentq.apt.domain; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import fluentq.core.types.dsl.Expressions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryProjectionBuilderTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionTest.java index 69f5b2c230..831a8fdabd 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryProjectionTest.java @@ -22,7 +22,7 @@ import fluentq.core.types.dsl.StringExpression; import jakarta.persistence.Entity; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryProjectionTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeOverTransientTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeOverTransientTest.java index 678bdacd40..b5f552ee4b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeOverTransientTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeOverTransientTest.java @@ -19,7 +19,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QueryTransient; import fluentq.core.annotations.QueryType; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryTypeOverTransientTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeTest.java index 00cdcfb6c2..5d5df640cc 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/QueryTypeTest.java @@ -21,7 +21,7 @@ import fluentq.core.types.dsl.DateTimePath; import fluentq.core.types.dsl.SimplePath; import fluentq.core.types.dsl.TimePath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryTypeTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RawTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RawTest.java index c4384252c7..89fdf43504 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RawTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RawTest.java @@ -2,7 +2,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QuerySupertype; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RawTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RelationTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RelationTest.java index cd1f02c21a..6cb441b46b 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RelationTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/RelationTest.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RelationTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesInTypesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesInTypesTest.java index 5c5200a294..6abfba98e6 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesInTypesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesInTypesTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ReservedNamesInTypesTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesTest.java index 7c10b17b8d..77ef22cfe2 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/ReservedNamesTest.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ReservedNamesTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SignatureTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SignatureTest.java index cc6bee0ccf..a85b27aefe 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SignatureTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SignatureTest.java @@ -18,7 +18,7 @@ import fluentq.core.annotations.QuerySupertype; import fluentq.core.types.dsl.EntityPathBase; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SignatureTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SimpleTypesTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SimpleTypesTest.java index cd30207181..53c780155e 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SimpleTypesTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SimpleTypesTest.java @@ -35,7 +35,7 @@ import java.util.Date; import java.util.List; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SimpleTypesTest extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass2Test.java index ff675e6211..1d0aef48a3 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass2Test.java @@ -20,7 +20,7 @@ import jakarta.persistence.MappedSuperclass; import jakarta.persistence.PrePersist; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Superclass2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass3Test.java index 87b8688982..519a2a6f13 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass3Test.java @@ -17,7 +17,7 @@ import fluentq.core.DefaultQueryMetadata; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Superclass3Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass4Test.java index 923df922a8..07dcd06881 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass4Test.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Superclass4Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass5Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass5Test.java index 4068a46e00..3d02b7a9f4 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass5Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Superclass5Test.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEmbeddable; import fluentq.core.types.PathMetadataFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Superclass5Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SuperclassTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SuperclassTest.java index 62f12e1528..8f86f63389 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SuperclassTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/SuperclassTest.java @@ -15,9 +15,9 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.annotations.QuerySupertype; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class SuperclassTest { @QuerySupertype diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Temporal2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Temporal2Test.java index bf9bc95272..258dc629a4 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Temporal2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/Temporal2Test.java @@ -10,7 +10,7 @@ import jakarta.persistence.TemporalType; import java.math.BigDecimal; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Temporal2Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TemporalTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TemporalTest.java index 21c41dd3a3..fc69c02d89 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TemporalTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TemporalTest.java @@ -8,7 +8,7 @@ import jakarta.persistence.Temporal; import jakarta.persistence.TemporalType; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TemporalTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TransientTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TransientTest.java index 559517d0eb..2d729515ba 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TransientTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/TransientTest.java @@ -19,7 +19,7 @@ import fluentq.core.annotations.QueryType; import jakarta.persistence.Entity; import jakarta.persistence.Transient; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TransientTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/p6/TypeTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/p6/TypeTest.java index df875736b6..fd75e5a9ac 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/p6/TypeTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/domain/p6/TypeTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance11Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance11Test.java index da05e62514..b5ccae7e37 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance11Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance11Test.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Inheritance11Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance2Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance2Test.java index de617f965f..593a3f8680 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance2Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance2Test.java @@ -14,9 +14,9 @@ package fluentq.apt.inheritance; import fluentq.core.annotations.QueryEntity; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class Inheritance2Test { @QueryEntity diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance3Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance3Test.java index 04598edd71..86cae4db55 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance3Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance3Test.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Inheritance3Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance4Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance4Test.java index a5d474b2b5..b952a38347 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance4Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance4Test.java @@ -18,7 +18,7 @@ import fluentq.core.types.dsl.NumberPath; import fluentq.core.types.dsl.SimplePath; import fluentq.core.types.dsl.StringPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Inheritance4Test extends AbstractTest { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance5Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance5Test.java index 4bcd7650c0..b64ff5d6cc 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance5Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance5Test.java @@ -20,7 +20,7 @@ import fluentq.core.types.dsl.NumberPath; import java.io.Serializable; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Inheritance5Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance6Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance6Test.java index aac36590e1..e33d5628fb 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance6Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance6Test.java @@ -21,7 +21,7 @@ import fluentq.core.types.dsl.NumberPath; import java.io.Serializable; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** Test multiple level superclasses with generics. */ public class Inheritance6Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance7Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance7Test.java index b54480070c..d98fe0cf9e 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance7Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance7Test.java @@ -17,8 +17,8 @@ import fluentq.core.annotations.QueryEntity; import java.util.Set; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class Inheritance7Test { @@ -64,7 +64,7 @@ public Set getChildren() { public static class SubCategory2 extends Category {} @Test - @Ignore + @Disabled public void parent() { // FIXME assertThat(QInheritance7Test_Category.category.parent.getType()).isEqualTo(Category.class); @@ -75,7 +75,7 @@ public void parent() { } @Test - @Ignore + @Disabled public void children() { // FIXME assertThat(QInheritance7Test_Category.category.children.getElementType()) diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance8Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance8Test.java index 46be18f5cd..949bef0811 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance8Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance8Test.java @@ -19,7 +19,7 @@ import fluentq.core.domain.CommonIdentifiable; import fluentq.core.domain.CommonPersistence; import fluentq.core.types.dsl.NumberPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Inheritance8Test { diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance9Test.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance9Test.java index 03aa362bdb..b29d27a61f 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance9Test.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/Inheritance9Test.java @@ -17,7 +17,7 @@ import fluentq.core.annotations.QueryEntity; import fluentq.core.domain.SuperSupertype; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * related to https://bugs.launchpad.net/fluentq/+bug/538148 diff --git a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/InheritanceTest.java b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/InheritanceTest.java index a9a560abcc..cd80ee9138 100644 --- a/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/InheritanceTest.java +++ b/fluentq-tooling/fluentq-apt-test/src/test/java/fluentq/apt/inheritance/InheritanceTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.core.annotations.QueryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InheritanceTest { diff --git a/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/ExtendedTypeFactory.java b/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/ExtendedTypeFactory.java index 2cc243a27b..67fc367067 100644 --- a/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/ExtendedTypeFactory.java +++ b/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/ExtendedTypeFactory.java @@ -37,9 +37,11 @@ import java.util.Set; import java.util.function.Function; import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.ErrorType; @@ -52,6 +54,7 @@ import javax.lang.model.type.TypeVariable; import javax.lang.model.type.TypeVisitor; import javax.lang.model.type.WildcardType; +import javax.lang.model.util.ElementFilter; import org.jetbrains.annotations.Nullable; /** @@ -373,8 +376,38 @@ private Type createType(TypeMirror typeMirror, List key, boolean deep) { } } + private boolean isKotlinValueClass(TypeElement typeElement) { + for (AnnotationMirror annotation : typeElement.getAnnotationMirrors()) { + if (annotation.getAnnotationType().toString().equals("kotlin.jvm.JvmInline")) { + return true; + } + } + return false; + } + + private TypeMirror getKotlinValueClassUnderlyingType(TypeElement typeElement) { + var instanceFields = new ArrayList(); + for (var field : ElementFilter.fieldsIn(typeElement.getEnclosedElements())) { + if (!field.getModifiers().contains(Modifier.STATIC)) { + instanceFields.add(field); + } + } + if (instanceFields.size() == 1) { + return instanceFields.get(0).asType(); + } + return null; + } + // TODO : simplify private Type createClassType(DeclaredType declaredType, TypeElement typeElement, boolean deep) { + // Kotlin value classes (@JvmInline) should be unwrapped to their underlying type + if (isKotlinValueClass(typeElement)) { + var underlyingType = getKotlinValueClassUnderlyingType(typeElement); + if (underlyingType != null) { + return getType(underlyingType, deep); + } + } + // other var name = typeElement.getQualifiedName().toString(); diff --git a/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/TypeElementHandler.java b/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/TypeElementHandler.java index aa9f49574c..65123f378e 100644 --- a/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/TypeElementHandler.java +++ b/fluentq-tooling/fluentq-apt/src/main/java/fluentq/apt/TypeElementHandler.java @@ -191,6 +191,9 @@ public EntityType handleProjectionType( private Type getType(VariableElement element) { Type rv = typeFactory.getType(element.asType(), true); + if (rv == null) { + return null; + } if (element.getAnnotation(QueryType.class) != null) { var qt = element.getAnnotation(QueryType.class); if (qt.value() != PropertyType.NONE) { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/JDKEvaluatorFactory.java b/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/JDKEvaluatorFactory.java index 41a9c5ca33..3b1033d1a6 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/JDKEvaluatorFactory.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/JDKEvaluatorFactory.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Optional; import javax.tools.JavaCompiler; import javax.tools.SimpleJavaFileObject; import javax.tools.StandardLocation; @@ -51,10 +50,7 @@ public JDKEvaluatorFactory(ClassLoader parent, JavaCompiler compiler) { this.fileManager = new MemFileManager(parent, compiler.getStandardFileManager(null, null, null)); this.compiler = compiler; - this.classpath = - Optional.of(SimpleCompiler.getClassPath(parent)) - .filter(s -> !s.isEmpty()) - .orElseGet(() -> SimpleCompiler.getClassPath(compiler.getClass().getClassLoader())); + this.classpath = SimpleCompiler.getClassPath(parent); this.loader = fileManager.getClassLoader(StandardLocation.CLASS_OUTPUT); this.compilationOptions = Arrays.asList("-classpath", classpath, "-g:none"); } diff --git a/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/SimpleCompiler.java b/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/SimpleCompiler.java index 40631f2902..fbe05bc8bc 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/SimpleCompiler.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/main/java/fluentq/codegen/utils/SimpleCompiler.java @@ -36,7 +36,7 @@ public class SimpleCompiler implements JavaCompiler { public static String getClassPath(ClassLoader cl) { - return new ClassGraph().overrideClassLoaders(cl).getClasspath(); + return new ClassGraph().addClassLoader(cl).getClasspath(); } private final ClassLoader classLoader; diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/NestedTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/NestedTest.java index 8004d2e511..e00a3f827e 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/NestedTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/NestedTest.java @@ -2,7 +2,7 @@ import fluentq.codegen.utils.model.ClassType; import fluentq.codegen.utils.support.ClassUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NestedTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/AnnotationTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/AnnotationTest.java index 40fc8f1b66..0fe1ff8a99 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/AnnotationTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/AnnotationTest.java @@ -10,7 +10,7 @@ import java.io.IOException; import java.io.StringWriter; import java.lang.annotation.ElementType; -import org.junit.Test; +import org.junit.jupiter.api.Test; @Annotation(prop2 = false, clazz = AnnotationTest.class) @Annotation2("Hello") @@ -54,7 +54,7 @@ public void ClassAnnotation3() throws IOException { @Test public void MethodAnnotation() throws IOException, SecurityException, NoSuchMethodException { writer.annotation(getClass().getMethod("MethodAnnotation").getAnnotation(Test.class)); - assertThat(w.toString().trim()).isEqualTo("@org.junit.Test"); + assertThat(w.toString().trim()).isEqualTo("@org.junit.jupiter.api.Test"); } @Test diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ComplexEvaluationTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ComplexEvaluationTest.java index 46b3426615..1861ae0f18 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ComplexEvaluationTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ComplexEvaluationTest.java @@ -6,6 +6,7 @@ package fluentq.codegen.utils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import fluentq.codegen.utils.model.ClassType; import fluentq.codegen.utils.model.Type; @@ -15,7 +16,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ComplexEvaluationTest { @@ -106,7 +107,7 @@ public void ComplexClassLoading() { } } - @Test(expected = CodegenException.class) + @Test @SuppressWarnings("unchecked") public void ComplexClassLoadingFailure() { var resultType = new ClassType(TypeCategory.LIST, List.class, Types.STRING); @@ -125,20 +126,24 @@ public void ComplexClassLoadingFailure() { source.append("}\n"); source.append("return rv;"); - @SuppressWarnings("rawtypes") // cannot specify further than List.class - Evaluator evaluator = - factory.createEvaluator( - source.toString(), - resultType, - new String[] {"a_", "b_"}, - new Type[] {resultType, resultType}, - new Class[] {List.class, List.class}, - Collections.emptyMap()); + assertThatThrownBy( + () -> { + @SuppressWarnings("rawtypes") // cannot specify further than List.class + Evaluator evaluator = + factory.createEvaluator( + source.toString(), + resultType, + new String[] {"a_", "b_"}, + new Type[] {resultType, resultType}, + new Class[] {List.class, List.class}, + Collections.emptyMap()); - List a = Arrays.asList("1", "2", "3", "4"); - List b = Arrays.asList("2", "4", "6", "8"); + List a = Arrays.asList("1", "2", "3", "4"); + List b = Arrays.asList("2", "4", "6", "8"); - assertThat(evaluator.evaluate(a, b)).isEqualTo(Arrays.asList("2", "4")); + assertThat(evaluator.evaluate(a, b)).isEqualTo(Arrays.asList("2", "4")); + }) + .isInstanceOf(CodegenException.class); } @Test diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ECJEvaluatorFactoryTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ECJEvaluatorFactoryTest.java index 6d6b9e8853..134061b44a 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ECJEvaluatorFactoryTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ECJEvaluatorFactoryTest.java @@ -13,8 +13,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ECJEvaluatorFactoryTest { @@ -41,7 +41,7 @@ public String getName() { private List> string_int = Arrays.>asList(String.class, int.class); - @Before + @BeforeEach public void setUp() throws IOException { factory = new ECJEvaluatorFactory(getClass().getClassLoader()); } diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/InnerClassesTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/InnerClassesTest.java index 593d31b6d4..729f31292b 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/InnerClassesTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/InnerClassesTest.java @@ -7,7 +7,7 @@ import fluentq.codegen.utils.model.Type; import java.io.IOException; import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InnerClassesTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JDKEvaluatorFactoryTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JDKEvaluatorFactoryTest.java index 81ecbb18cb..fdb1c0072c 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JDKEvaluatorFactoryTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JDKEvaluatorFactoryTest.java @@ -14,8 +14,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JDKEvaluatorFactoryTest { @@ -42,7 +42,7 @@ public String getName() { private List> string_int = Arrays.>asList(String.class, int.class); - @Before + @BeforeEach public void setUp() throws IOException { factory = new JDKEvaluatorFactory(getClass().getClassLoader()); } diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JavaWriterTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JavaWriterTest.java index 6bf811e6b2..39e0f15de4 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JavaWriterTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/JavaWriterTest.java @@ -24,8 +24,8 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.function.Function; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class JavaWriterTest { @@ -59,7 +59,7 @@ private static void match(String resource, String text) throws IOException { assertThat(actual).isEqualTo(expected); } - @Before + @BeforeEach public void setUp() { w = new StringWriter(); writer = new JavaWriter(w); @@ -192,18 +192,6 @@ public void Annotations2() throws IOException { writer.beginClass(testType); writer.annotation( new Test() { - @Override - public Class expected() { - // TODO Auto-generated method stub - return null; - } - - @Override - public long timeout() { - - return 0; - } - @Override public Class annotationType() { return Test.class; diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemJavaFileObjectTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemJavaFileObjectTest.java index d3d5c8abb4..ba10104f3f 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemJavaFileObjectTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemJavaFileObjectTest.java @@ -9,7 +9,7 @@ import java.io.IOException; import javax.tools.JavaFileObject.Kind; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MemJavaFileObjectTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemSourceFileObjectTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemSourceFileObjectTest.java index f9e7903a84..ae527a57fe 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemSourceFileObjectTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/MemSourceFileObjectTest.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MemSourceFileObjectTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ScalaWriterTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ScalaWriterTest.java index 735eec4926..e1c0905d35 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ScalaWriterTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/ScalaWriterTest.java @@ -18,8 +18,8 @@ import java.util.Arrays; import java.util.List; import java.util.function.Function; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ScalaWriterTest { @@ -37,7 +37,7 @@ public Parameter apply(Parameter input) { private Type testType, testType2, testSuperType, testInterface1, testInterface2; - @Before + @BeforeEach public void setUp() { testType = new ClassType(JavaWriterTest.class); testType2 = new SimpleType("fluentq.codegen.utils.Test", "fluentq.codegen.utils", "Test"); @@ -276,18 +276,6 @@ public void Annotations2() throws IOException { writer.beginClass(testType); writer.annotation( new Test() { - @Override - public Class expected() { - // TODO Auto-generated method stub - return null; - } - - @Override - public long timeout() { - - return 0; - } - @Override public Class annotationType() { return Test.class; diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SimpleCompilerTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SimpleCompilerTest.java index fa7e3cae8b..b709971af3 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SimpleCompilerTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SimpleCompilerTest.java @@ -17,19 +17,19 @@ import java.util.List; import javax.tools.JavaCompiler; import javax.tools.ToolProvider; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class SimpleCompilerTest { - @After + @AfterEach public void tearDown() { new File("src/test/java/fluentq/codegen/utils/SimpleCompilerTest.class").delete(); } @Test - @Ignore + @Disabled public void Run() throws UnsupportedEncodingException { new File("target/out").mkdir(); var compiler = ToolProvider.getSystemJavaCompiler(); diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SurefireBooterTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SurefireBooterTest.java index 8b8266ab68..bd2262c3c4 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SurefireBooterTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/SurefireBooterTest.java @@ -3,7 +3,7 @@ import java.io.IOException; import java.net.URLClassLoader; import java.util.jar.Manifest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SurefireBooterTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ClassTypeTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ClassTypeTest.java index 8b8f0f92dc..58e68957e8 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ClassTypeTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ClassTypeTest.java @@ -9,7 +9,7 @@ import java.util.Collections; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ClassTypeTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ConstructorTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ConstructorTest.java index 880602d729..92222e5446 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ConstructorTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ConstructorTest.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConstructorTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ParameterTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ParameterTest.java index 0ea80bf3ed..d8c503d3fb 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ParameterTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/ParameterTest.java @@ -7,7 +7,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ParameterTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/SimpleTypeTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/SimpleTypeTest.java index 1cc6d3992b..c343650003 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/SimpleTypeTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/SimpleTypeTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SimpleTypeTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeAdapterTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeAdapterTest.java index 5579ad0f25..a1fcdbe388 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeAdapterTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeAdapterTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeAdapterTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeCategoryTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeCategoryTest.java index 53f585962f..0abccbb018 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeCategoryTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeCategoryTest.java @@ -9,7 +9,7 @@ import java.sql.Date; import java.sql.Time; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeCategoryTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeExtendsTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeExtendsTest.java index c3ab5cc217..753e90d6ef 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeExtendsTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeExtendsTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeExtendsTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeSuperTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeSuperTest.java index 6761bfe162..f1f3ebb042 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeSuperTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeSuperTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeSuperTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeTest.java index 8f1fbda883..4f0c00ee78 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/model/TypeTest.java @@ -12,7 +12,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/support/ClassUtilsTest.java b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/support/ClassUtilsTest.java index f2bcf4d9a6..3e70dca5ab 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/support/ClassUtilsTest.java +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/java/fluentq/codegen/utils/support/ClassUtilsTest.java @@ -15,7 +15,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ClassUtilsTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations index b13ee967c7..bd9dcb89e0 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations @@ -6,7 +6,7 @@ import java.io.StringWriter; @Entity public class JavaWriterTest { - @org.junit.Test + @org.junit.jupiter.api.Test public void test() { } diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations2 b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations2 index 938654783c..6388cc4b31 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations2 +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testAnnotations2 @@ -6,7 +6,7 @@ import java.io.*; @Entity public class JavaWriterTest { - @org.junit.Test + @org.junit.jupiter.api.Test public void test() { } diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testBasic b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testBasic index 6f2bed89e2..75fbb4d2b4 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testBasic +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testBasic @@ -2,7 +2,7 @@ package fluentq.codegen.utils; import java.io.IOException; import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JavaWriterTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testInterface b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testInterface index 6cf866fc35..fb8f7ef43f 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testInterface +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testInterface @@ -2,7 +2,7 @@ package fluentq.codegen.utils; import java.io.IOException; import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; public interface JavaWriterTest { diff --git a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testJavadoc b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testJavadoc index f926ccbd12..226f84dc07 100644 --- a/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testJavadoc +++ b/fluentq-tooling/fluentq-codegen-utils/src/test/resources/testJavadoc @@ -2,7 +2,7 @@ package fluentq.codegen.utils; import java.io.IOException; import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * JavaWriterTest is a test class diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/AbstractExporterTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/AbstractExporterTest.java index 01d4ed3ae6..f2d9dd52c5 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/AbstractExporterTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/AbstractExporterTest.java @@ -1,7 +1,7 @@ package fluentq.codegen; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractExporterTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/BeanSerializerTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/BeanSerializerTest.java index 58372cebb7..040f36672f 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/BeanSerializerTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/BeanSerializerTest.java @@ -29,8 +29,8 @@ import java.io.Writer; import java.util.Arrays; import java.util.Date; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class BeanSerializerTest { @@ -40,7 +40,7 @@ public class BeanSerializerTest { private final Writer writer = new StringWriter(); - @Before + @BeforeEach public void setUp() { typeModel = new SimpleType( diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ClassPathUtilsTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ClassPathUtilsTest.java index e84ef616ad..60f1130c1e 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ClassPathUtilsTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ClassPathUtilsTest.java @@ -17,7 +17,7 @@ import com.SomeClass; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ClassPathUtilsTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CodegenModuleTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CodegenModuleTest.java index 2b795b3eb6..518c23bf6e 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CodegenModuleTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CodegenModuleTest.java @@ -14,9 +14,10 @@ package fluentq.codegen; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.lang.annotation.Annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CodegenModuleTest { @@ -32,9 +33,10 @@ public void typeMappings() { assertThat(module.get(TypeMappings.class)).isNotNull(); } - @Test(expected = IllegalArgumentException.class) + @Test public void get_with_unknown_key() { - module.get(String.class, "XXX"); + assertThatThrownBy(() -> module.get(String.class, "XXX")) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CustomTypeTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CustomTypeTest.java index a8cbac72a9..2ba50609bf 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CustomTypeTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/CustomTypeTest.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.io.StringWriter; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CustomTypeTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/DelegateTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/DelegateTest.java index 58ff7c566d..2a7b8627cc 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/DelegateTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/DelegateTest.java @@ -18,7 +18,7 @@ import fluentq.codegen.utils.model.Parameter; import fluentq.codegen.utils.model.Types; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DelegateTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EmbeddableSerializerTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EmbeddableSerializerTest.java index 6eb6fe4e08..432ca3218b 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EmbeddableSerializerTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EmbeddableSerializerTest.java @@ -29,7 +29,7 @@ import java.util.Date; import java.util.EnumMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EmbeddableSerializerTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntitySerializerTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntitySerializerTest.java index 1fb81975fd..53a263231d 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntitySerializerTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntitySerializerTest.java @@ -29,7 +29,7 @@ import java.util.Date; import java.util.EnumMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EntitySerializerTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntityTypeTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntityTypeTest.java index 8619ff82e1..dcfe5e62a5 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntityTypeTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/EntityTypeTest.java @@ -18,7 +18,7 @@ import fluentq.codegen.utils.model.ClassType; import fluentq.codegen.utils.model.TypeCategory; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EntityTypeTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ExternalEmbeddableTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ExternalEmbeddableTest.java index d3eb0d8957..5e3e5576c1 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ExternalEmbeddableTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ExternalEmbeddableTest.java @@ -3,9 +3,9 @@ import fluentq.core.annotations.QueryEmbedded; import fluentq.core.annotations.QueryEntity; import fluentq.core.domain.EmbeddableWithoutQType; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; -@Ignore +@Disabled public class ExternalEmbeddableTest { @QueryEntity diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GeneratedAnnotationResolverTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GeneratedAnnotationResolverTest.java index 38eb6d7fbb..2be4608ff4 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GeneratedAnnotationResolverTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GeneratedAnnotationResolverTest.java @@ -4,7 +4,7 @@ import jakarta.annotation.Generated; import java.lang.annotation.Annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GeneratedAnnotationResolverTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Generic2Test.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Generic2Test.java index c0df5c8860..3fecb21e8e 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Generic2Test.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Generic2Test.java @@ -9,7 +9,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Generic2Test { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericExporterTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericExporterTest.java index 2e22152205..e20499fd57 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericExporterTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericExporterTest.java @@ -18,142 +18,134 @@ import fluentq.core.domain.Cat; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class GenericExporterTest { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; private GenericExporter exporter; - @Before + @BeforeEach public void setUp() { exporter = new GenericExporter(); } @Test public void export() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbeddable.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbedded.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntity.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntityInterface.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleSupertype.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/sub/QExampleEntity2.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbedded.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntity.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntityInterface.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleSupertype.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/sub/QExampleEntity2.java")).exists(); } @Test public void export_with_keywords() throws IOException { exporter.setKeywords(Keywords.JPA); - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.export(getClass().getPackage()); - var str = - new String( - Files.readAllBytes(new File(folder.getRoot(), "fluentq/codegen/QGroup.java").toPath()), - StandardCharsets.UTF_8); + var str = Files.readString(new File(folder, "fluentq/codegen/QGroup.java").toPath()); assertThat(str).contains("QGroup group = new QGroup(\"group1\");"); } @Test public void export_with_stopClass() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.addStopClass(Examples.Supertype.class); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExamples_Supertype.java").exists()) - .isFalse(); + assertThat(new File(folder, "fluentq/codegen/QExamples_Supertype.java").exists()).isFalse(); } @Test public void override_serializer() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.setSerializerClass(DefaultEntitySerializer.class); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbeddable.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbedded.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntity.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntityInterface.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleSupertype.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/sub/QExampleEntity2.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbedded.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntity.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntityInterface.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleSupertype.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/sub/QExampleEntity2.java")).exists(); } @Test public void export_package_as_string() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.export(getClass().getPackage().getName()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbeddable.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbedded.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntity.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntityInterface.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleSupertype.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/sub/QExampleEntity2.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbedded.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntity.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntityInterface.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleSupertype.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/sub/QExampleEntity2.java")).exists(); } @Test public void export_with_package_suffix() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.setPackageSuffix("types"); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegentypes/QExampleEmbeddable.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegentypes/QExampleEmbedded.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegentypes/QExampleEntity.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegentypes/QExampleEntityInterface.java")) - .exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegentypes/QExampleSupertype.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/subtypes/QExampleEntity2.java")) - .exists(); + assertThat(new File(folder, "fluentq/codegentypes/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegentypes/QExampleEmbedded.java")).exists(); + assertThat(new File(folder, "fluentq/codegentypes/QExampleEntity.java")).exists(); + assertThat(new File(folder, "fluentq/codegentypes/QExampleEntityInterface.java")).exists(); + assertThat(new File(folder, "fluentq/codegentypes/QExampleSupertype.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/subtypes/QExampleEntity2.java")).exists(); } @Test public void export_handle_no_methods_nor_fields() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.setHandleFields(false); exporter.setHandleMethods(false); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbeddable.java")).exists(); } @Test public void export_domain_package() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.export(Cat.class.getPackage()); } @Test public void export_serializerConfig() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.setSerializerConfig(new SimpleSerializerConfig(true, true, true, true, "")); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbeddable.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbedded.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntity.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntityInterface.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleSupertype.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/sub/QExampleEntity2.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbedded.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntity.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntityInterface.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleSupertype.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/sub/QExampleEntity2.java")).exists(); } @Test public void export_useFieldTypes() { - exporter.setTargetFolder(folder.getRoot()); + exporter.setTargetFolder(folder); exporter.setUseFieldTypes(true); exporter.export(getClass().getPackage()); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbeddable.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEmbedded.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntity.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleEntityInterface.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/QExampleSupertype.java")).exists(); - assertThat(new File(folder.getRoot(), "fluentq/codegen/sub/QExampleEntity2.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbeddable.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEmbedded.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntity.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleEntityInterface.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/QExampleSupertype.java")).exists(); + assertThat(new File(folder, "fluentq/codegen/sub/QExampleEntity2.java")).exists(); } @Test public void export_propertyHandling() throws IOException { for (PropertyHandling ph : PropertyHandling.values()) { - var f = folder.newFolder(); + var f = Files.createTempDirectory(folder.toPath(), "export").toFile(); var e = new GenericExporter(); e.setTargetFolder(f); e.setPropertyHandling(ph); diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericTest.java index 6ecfb5a549..926242a2bf 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GenericTest.java @@ -1,7 +1,7 @@ package fluentq.codegen; import fluentq.codegen.utils.model.Type; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GroovyBeanSerializerTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GroovyBeanSerializerTest.java index 199ddb27a3..08c339bf1f 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GroovyBeanSerializerTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/GroovyBeanSerializerTest.java @@ -27,8 +27,8 @@ import java.io.Writer; import java.util.Arrays; import java.util.Date; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class GroovyBeanSerializerTest { @@ -38,7 +38,7 @@ public class GroovyBeanSerializerTest { private final Writer writer = new StringWriter(); - @Before + @BeforeEach public void setUp() { typeModel = new SimpleType( diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Inheritance2Test.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Inheritance2Test.java index a4a3c5e950..278d54f661 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Inheritance2Test.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/Inheritance2Test.java @@ -5,7 +5,7 @@ import fluentq.codegen.utils.model.TypeExtends; import fluentq.core.annotations.QueryEntity; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Inheritance2Test { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PackageSuffixTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PackageSuffixTest.java index c1573e1fb3..33edc57089 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PackageSuffixTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PackageSuffixTest.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.io.StringWriter; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PackageSuffixTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ProjectionSerializerTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ProjectionSerializerTest.java index 69cfd09736..8d8e705085 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ProjectionSerializerTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ProjectionSerializerTest.java @@ -27,7 +27,7 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ProjectionSerializerTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PropertyTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PropertyTest.java index 7157bc3ff6..19d2035af5 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PropertyTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/PropertyTest.java @@ -19,7 +19,7 @@ import fluentq.codegen.utils.model.Type; import fluentq.codegen.utils.model.TypeCategory; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PropertyTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/QueryTypeFactoryTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/QueryTypeFactoryTest.java index b4bdfc6989..b6c94da04e 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/QueryTypeFactoryTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/QueryTypeFactoryTest.java @@ -17,7 +17,7 @@ import fluentq.codegen.utils.model.ClassType; import fluentq.codegen.utils.model.Type; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryTypeFactoryTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ScalaTypeDump.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ScalaTypeDump.java index abc6ff9f96..059cddcc02 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ScalaTypeDump.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/ScalaTypeDump.java @@ -33,13 +33,13 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ScalaTypeDump { @Test - @Ignore + @Disabled public void test() throws IOException { List> classes = new ArrayList<>(); classes.add(SimpleExpression.class); diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/SerializerTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/SerializerTest.java index d2f9604114..26bb2bc465 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/SerializerTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/SerializerTest.java @@ -32,8 +32,8 @@ import java.util.Date; import java.util.List; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SerializerTest { @@ -44,7 +44,7 @@ public class SerializerTest { private TypeMappings typeMappings = new JavaTypeMappings(); @SuppressWarnings("unchecked") - @Before + @BeforeEach public void setUp() { // type Type typeModel = diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeFactoryTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeFactoryTest.java index 6886897cbb..a38da28352 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeFactoryTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeFactoryTest.java @@ -28,7 +28,7 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeFactoryTest { diff --git a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeMappingsTest.java b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeMappingsTest.java index 17927c8879..08142dd5eb 100644 --- a/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeMappingsTest.java +++ b/fluentq-tooling/fluentq-codegen/src/test/java/fluentq/codegen/TypeMappingsTest.java @@ -20,7 +20,7 @@ import fluentq.codegen.utils.model.Type; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TypeMappingsTest { diff --git a/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/JPADomainExporterTest.java b/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/JPADomainExporterTest.java index e124df306b..66bee03b91 100644 --- a/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/JPADomainExporterTest.java +++ b/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/JPADomainExporterTest.java @@ -18,26 +18,22 @@ import jakarta.persistence.Persistence; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collection; import java.util.Comparator; import java.util.Properties; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import java.util.stream.Stream; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.TestFactory; -@RunWith(Parameterized.class) public class JPADomainExporterTest { - @Rule public ErrorCollector errors = new ErrorCollector(); + private final File origRoot = + new File( + "../../fluentq-libraries/fluentq-jpa/target/generated-test-sources/test-annotations"); - @Parameters - public static Collection generateFiles() throws Exception { + @TestFactory + public Stream generatedFilesMatchReference() throws Exception { var emf = Persistence.createEntityManagerFactory("h2", new Properties()); var outputFolder = Files.createTempDirectory("jpa-exporter-test"); var exporter = new JPADomainExporter(outputFolder.toFile(), emf.getMetamodel()); @@ -48,27 +44,16 @@ public static Collection generateFiles() throws Exception { return files.stream() .sorted(Comparator.comparing(File::getName)) - .map(file -> new Object[] {outputFolder, file}) - .toList(); - } - - private File file; - private Path outputFolder; - private File origRoot = - new File( - "../../fluentq-libraries/fluentq-jpa/target/generated-test-sources/test-annotations"); - - public JPADomainExporterTest(Path outputFolder, File file) { - this.file = file; - this.outputFolder = outputFolder; + .map( + file -> + DynamicTest.dynamicTest(file.getName(), () -> assertMatches(outputFolder, file))); } - @Test - public void test() throws IOException { + private void assertMatches(Path outputFolder, File file) throws IOException { var relativeFile = outputFolder.relativize(file.toPath()); var origFile = origRoot.toPath().resolve(relativeFile); - var reference = new String(Files.readAllBytes(origFile), StandardCharsets.UTF_8); - var content = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + var reference = Files.readString(origFile); + var content = Files.readString(file.toPath()); if (file.getName().equals("QCalendar.java")) { // The APT processor does not apply @Temporal(TemporalType.DATE) to @ElementCollection diff --git a/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/ant/AntJPADomainExporterTest.java b/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/ant/AntJPADomainExporterTest.java index 1a1627fd49..45dece3f2b 100644 --- a/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/ant/AntJPADomainExporterTest.java +++ b/fluentq-tooling/fluentq-jpa-codegen/src/test/java/fluentq/jpa/codegen/ant/AntJPADomainExporterTest.java @@ -4,22 +4,20 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class AntJPADomainExporterTest { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; @Test public void test() throws IOException { var exporter = new AntJPADomainExporter(); exporter.setNamePrefix("Q"); exporter.setNameSuffix(""); - var outputFolder = folder.getRoot().toPath(); + var outputFolder = folder.toPath(); exporter.setTargetFolder(outputFolder.toFile().getAbsolutePath()); exporter.setPersistenceUnitName("h2"); exporter.execute(); @@ -32,9 +30,8 @@ public void test() throws IOException { for (File file : files) { var relativeFile = outputFolder.relativize(file.toPath()); var origFile = origRoot.toPath().resolve(relativeFile); - var reference = - new String(java.nio.file.Files.readAllBytes(origFile), StandardCharsets.UTF_8); - var content = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + var reference = Files.readString(origFile); + var content = Files.readString(file.toPath()); if (file.getName().equals("QCalendar.java")) { // The APT processor does not apply @Temporal(TemporalType.DATE) to @ElementCollection diff --git a/fluentq-tooling/fluentq-kotlin-codegen/src/main/kotlin/fluentq/kotlin/codegen/Extensions.kt b/fluentq-tooling/fluentq-kotlin-codegen/src/main/kotlin/fluentq/kotlin/codegen/Extensions.kt index 783468fe3d..48a4f963ca 100644 --- a/fluentq-tooling/fluentq-kotlin-codegen/src/main/kotlin/fluentq/kotlin/codegen/Extensions.kt +++ b/fluentq-tooling/fluentq-kotlin-codegen/src/main/kotlin/fluentq/kotlin/codegen/Extensions.kt @@ -27,10 +27,26 @@ import com.squareup.kotlinpoet.asTypeName import com.squareup.kotlinpoet.joinToCode import kotlin.reflect.KClass +private val PRIMITIVE_ARRAY_FULL_NAMES = + setOf("boolean[]", "byte[]", "char[]", "short[]", "int[]", "long[]", "float[]", "double[]") + +// Component type of an object array (e.g. String[]), or null for non-arrays and primitive +// arrays. Primitive arrays (int[], byte[], ...) keep their dedicated Kotlin array class +// (IntArray, ByteArray, ...) via asClassName() and must not be wrapped in Array. +private fun Type.objectArrayComponentType(): Type? = + componentType?.takeUnless { fullName in PRIMITIVE_ARRAY_FULL_NAMES } + @JvmOverloads -fun Type.asTypeName(out: Boolean = false): TypeName = asClassName().let { className -> - if (parameters.isNotEmpty()) - className.parameterizedBy(*parameters.map { if (out) it.asOutTypeName() else it.asTypeName() }.toTypedArray()) else className +fun Type.asTypeName(out: Boolean = false): TypeName { + // Object arrays (e.g. String[]) must be rendered as the Kotlin Array type. + objectArrayComponentType()?.let { component -> + return Array::class.asClassName() + .parameterizedBy(if (out) component.asOutTypeName() else component.asTypeName()) + } + return asClassName().let { className -> + if (parameters.isNotEmpty()) + className.parameterizedBy(*parameters.map { if (out) it.asOutTypeName() else it.asTypeName() }.toTypedArray()) else className + } } fun Type.asClassName(): ClassName = when (this.fullName) { @@ -67,7 +83,10 @@ private fun Type.enclosingTypeHierarchy(): List { fun ClassName.asClassStatement() = CodeBlock.of("%T::class.java", this) -fun Type.asClassNameStatement() = asClassName().asClassStatement() +fun Type.asClassNameStatement(): CodeBlock = + // Object arrays need the Kotlin Array::class.java form to resolve to the right runtime class. + objectArrayComponentType()?.let { CodeBlock.of("%T::class.java", asTypeName()) } + ?: asClassName().asClassStatement() fun TypeMappings.getPathClassName(type: Type, model: EntityType) = getPathType(type, model, true).asClassName() diff --git a/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EmbeddableSerializerTest.kt b/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EmbeddableSerializerTest.kt index c5dc9a5fa5..d95072cf1c 100644 --- a/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EmbeddableSerializerTest.kt +++ b/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EmbeddableSerializerTest.kt @@ -31,9 +31,8 @@ import fluentq.codegen.utils.model.Types import fluentq.core.annotations.Generated import fluentq.core.annotations.PropertyType import fluentq.kotlin.codegen.CompileUtils.assertCompiles -import org.junit.Assert -import org.junit.Ignore -import org.junit.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions import org.assertj.core.api.Assertions.assertThat @@ -164,7 +163,7 @@ class EmbeddableSerializerTest { } @Test - @Ignore + @Disabled fun delegates() { val type = SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false) val entityType = EntityType(type) diff --git a/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EntitySerializerTest.kt b/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EntitySerializerTest.kt index 54a29f7a86..4e4df3327a 100644 --- a/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EntitySerializerTest.kt +++ b/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/EntitySerializerTest.kt @@ -31,9 +31,8 @@ import fluentq.codegen.utils.model.Types import fluentq.core.annotations.Generated import fluentq.core.annotations.PropertyType import fluentq.kotlin.codegen.CompileUtils.assertCompiles -import org.junit.Assert -import org.junit.Ignore -import org.junit.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions import java.io.StringWriter @@ -118,6 +117,18 @@ class EntitySerializerTest { assertCompiles("QEntity", writer.toString()) } + @Test + fun object_array() { + val type = SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false) + val entityType = EntityType(type) + entityType.addProperty(Property(entityType, "tags", ClassType(TypeCategory.ARRAY, Array::class.java))) + typeMappings.register(entityType, queryTypeFactory.create(entityType)) + serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, JavaWriter(writer)) + Assertions.assertTrue(writer.toString().contains("val tags: ArrayPath, String>")) + Assertions.assertTrue(writer.toString().contains("createArray(\"tags\", Array::class.java)")) + assertCompiles("QEntity", writer.toString()) + } + @Test fun include() { val type = SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false) @@ -174,7 +185,7 @@ class EntitySerializerTest { @Test - @Ignore //TODO: Implement delegates. Or document that extensions need to be used instead? + @Disabled //TODO: Implement delegates. Or document that extensions need to be used instead? fun delegates() { val type = SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false) val entityType = EntityType(type) diff --git a/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/ProjectionSerializerTest.kt b/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/ProjectionSerializerTest.kt index b32fdf6922..285f12fa6f 100644 --- a/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/ProjectionSerializerTest.kt +++ b/fluentq-tooling/fluentq-kotlin-codegen/src/test/kotlin/fluentq/kotlin/codegen/ProjectionSerializerTest.kt @@ -26,8 +26,7 @@ import fluentq.codegen.utils.model.TypeCategory import fluentq.codegen.utils.model.Types import fluentq.core.annotations.Generated import org.assertj.core.api.Assertions.assertThat -import org.junit.Assert -import org.junit.Test +import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions import java.io.StringWriter diff --git a/fluentq-tooling/fluentq-ksp-codegen/pom.xml b/fluentq-tooling/fluentq-ksp-codegen/pom.xml index b12d8662e7..3317ca6876 100644 --- a/fluentq-tooling/fluentq-ksp-codegen/pom.xml +++ b/fluentq-tooling/fluentq-ksp-codegen/pom.xml @@ -50,7 +50,7 @@ io.mockk mockk-jvm - 1.14.9 + 1.14.11 test @@ -61,13 +61,13 @@ dev.zacsweers.kctfork core - 0.12.1 + ${kctfork.version} test dev.zacsweers.kctfork ksp - 0.12.1 + ${kctfork.version} test com.google.devtools.ksp diff --git a/fluentq-tooling/fluentq-ksp-codegen/src/main/kotlin/fluentq/ksp/codegen/QueryModelExtractor.kt b/fluentq-tooling/fluentq-ksp-codegen/src/main/kotlin/fluentq/ksp/codegen/QueryModelExtractor.kt index 0152cd3cab..08a86d4a0a 100644 --- a/fluentq-tooling/fluentq-ksp-codegen/src/main/kotlin/fluentq/ksp/codegen/QueryModelExtractor.kt +++ b/fluentq-tooling/fluentq-ksp-codegen/src/main/kotlin/fluentq/ksp/codegen/QueryModelExtractor.kt @@ -168,13 +168,22 @@ class QueryModelExtractor( } private fun toQueryModel(classDeclaration: KSClassDeclaration, type: QueryModelType, constructor: KSFunctionDeclaration?): QueryModel { + val simpleNames = generateSequence(classDeclaration) { it.parentDeclaration as? KSClassDeclaration } + .map { it.simpleName.asString() } + .toList() + .reversed() + return QueryModel( // Build the ClassName from raw KSP names to avoid kotlinpoet-ksp's // toClassName(), which invalidates KSP2 lifetime tokens (see // superclassOrNull above for the same workaround). + // Inner classes need the full parent hierarchy passed as vararg simple names + // so KotlinPoet emits a qualified reference (e.g. Outer.Inner) instead of + // the bare Inner, which fails to resolve at compile time. originalClassName = ClassName( classDeclaration.packageName.asString(), - classDeclaration.simpleName.asString() + simpleNames.first(), + *simpleNames.drop(1).toTypedArray() ), typeParameterCount = classDeclaration.typeParameters.size, className = queryClassName(classDeclaration, settings), diff --git a/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/KspProcessorIntegrationTest.kt b/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/KspProcessorIntegrationTest.kt index 83bfb49f6b..eb8357371c 100644 --- a/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/KspProcessorIntegrationTest.kt +++ b/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/KspProcessorIntegrationTest.kt @@ -6,7 +6,8 @@ import com.tschuchort.compiletesting.configureKsp import com.tschuchort.compiletesting.kspSourcesDir import org.assertj.core.api.Assertions.assertThat import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi -import org.junit.Test +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Timeout import java.io.File import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.CountDownLatch @@ -296,7 +297,8 @@ class KspProcessorIntegrationTest { .doesNotContain("SimplePath") } - @Test(timeout = 30_000) + @Test + @Timeout(30) fun bidirectionalEntities_loadConcurrentlyWithoutDeadlock() { // Regression: two JPA entities with mutual @ManyToOne refs (Foo has // a Bar, Bar has a Foo) are the canonical case where APT-generated @@ -666,6 +668,43 @@ class KspProcessorIntegrationTest { return compilation.compile() to compilation.kspSourcesDir } + @Test + fun embeddableInnerClass_generatesQualifiedTypeReference() { + val source = SourceFile.kotlin( + "Invoice.kt", + """ + package test + + import jakarta.persistence.Embeddable + import jakarta.persistence.EmbeddedId + import jakarta.persistence.Entity + import java.io.Serializable + + @Entity + class Invoice( + @EmbeddedId val id: InvoiceId + ) { + @Embeddable + data class InvoiceId( + val invoiceNo: String = "", + val seq: Int = 0 + ) : Serializable + } + """.trimIndent() + ) + + val (result, generatedDir) = compile(source) + + assertThat(result.exitCode) + .withFailMessage(result.messages) + .isEqualTo(KotlinCompilation.ExitCode.OK) + + val qInvoiceId = generatedDir.findGenerated("QInvoice_InvoiceId.kt") + assertThat(qInvoiceId.readText()) + .contains("Invoice.InvoiceId") + .doesNotContain("EmbeddablePath") + } + private fun File.findGenerated(name: String): File { val match = walkTopDown().firstOrNull { it.isFile && it.name == name } assertThat(match) diff --git a/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/RenderTest.kt b/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/RenderTest.kt index b45cc37bf3..756f442e21 100644 --- a/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/RenderTest.kt +++ b/fluentq-tooling/fluentq-ksp-codegen/src/test/kotlin/RenderTest.kt @@ -9,7 +9,8 @@ import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.asClassName import io.mockk.mockk import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Timeout import javax.script.ScriptEngineManager class RenderTest { diff --git a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/CompileMojoTest.java b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/CompileMojoTest.java index 9dabbc19f0..5c4d7eb8fa 100644 --- a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/CompileMojoTest.java +++ b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/CompileMojoTest.java @@ -2,7 +2,7 @@ import java.io.File; import org.apache.maven.project.MavenProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonatype.plexus.build.incremental.DefaultBuildContext; public class CompileMojoTest { diff --git a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/GenericExporterMojoTest.java b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/GenericExporterMojoTest.java index 6976a08b66..cade5f8a91 100644 --- a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/GenericExporterMojoTest.java +++ b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/GenericExporterMojoTest.java @@ -7,7 +7,7 @@ import java.lang.annotation.Annotation; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GenericExporterMojoTest { diff --git a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/JPAExporterMojoTest.java b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/JPAExporterMojoTest.java index 42be47e617..8c4c5b07bb 100644 --- a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/JPAExporterMojoTest.java +++ b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/JPAExporterMojoTest.java @@ -4,7 +4,7 @@ import java.io.File; import org.apache.maven.project.MavenProject; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JPAExporterMojoTest { diff --git a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/MetadataExportMojoTest.java b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/MetadataExportMojoTest.java index 3d68b6bcc7..f416f1786b 100644 --- a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/MetadataExportMojoTest.java +++ b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/MetadataExportMojoTest.java @@ -28,11 +28,10 @@ import java.io.Serializable; import java.util.Collections; import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; public class MetadataExportMojoTest { @@ -50,10 +49,11 @@ public class MetadataExportMojoTest { private final MetadataExportMojo mojo = new MetadataExportMojo(); - @Rule public TestName testName = new TestName(); + private String testName; - @Before - public void setUp() { + @BeforeEach + public void setUp(TestInfo testInfo) { + testName = testInfo.getTestMethod().orElseThrow().getName(); mojo.setProject(project); mojo.setJdbcDriver("org.h2.Driver"); mojo.setJdbcUrl(url); @@ -149,7 +149,7 @@ public void executeWithBeans() throws Exception { } @Test - @Ignore + @Disabled public void executeWithScalaSources() throws Exception { mojo.setTargetFolder("target/export7"); mojo.setCreateScalaSources(true); @@ -226,7 +226,7 @@ public void executeWithRenames() throws Exception { @Test public void executeWithUnsetSchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern(null); @@ -239,7 +239,7 @@ public void executeWithUnsetSchemaPattern() throws Exception { @Test public void executeWithExactSchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1"); @@ -253,7 +253,7 @@ public void executeWithExactSchemaPattern() throws Exception { @Test public void executeWithSimilarSchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("%EMA1"); @@ -267,7 +267,7 @@ public void executeWithSimilarSchemaPattern() throws Exception { @Test public void executeWithMismatchedSchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("NON_EXISTENT_SCHEMA"); @@ -280,7 +280,7 @@ public void executeWithMismatchedSchemaPattern() throws Exception { @Test public void executeWithMultipleSchemaPatterns() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1,SCHEMA2"); @@ -298,7 +298,7 @@ public void executeWithMultipleSchemaPatterns() throws Exception { @Test public void executeWithEmptySchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern(""); @@ -312,7 +312,7 @@ public void executeWithEmptySchemaPattern() throws Exception { @Test public void executeWithMultipleSchemaPatternsAndInterleavedEmpty() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1,,SCHEMA2"); @@ -325,7 +325,7 @@ public void executeWithMultipleSchemaPatternsAndInterleavedEmpty() throws Except @Test public void executeWithMultipleSchemaPatternsAndLeadingEmpty() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern(",SCHEMA2"); @@ -338,9 +338,9 @@ public void executeWithMultipleSchemaPatternsAndLeadingEmpty() throws Exception } @Test - @Ignore("Trailing empty strings are not handled correctly by the MetaDataExporter") + @Disabled("Trailing empty strings are not handled correctly by the MetaDataExporter") public void executeWithMultipleSchemaPatternsAndTrailingEmpty() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1,"); @@ -358,7 +358,7 @@ public void executeWithMultipleSchemaPatternsAndTrailingEmpty() throws Exception @Test public void executeWithBlankUppercaseSchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("BLANK"); @@ -372,7 +372,7 @@ public void executeWithBlankUppercaseSchemaPattern() throws Exception { @Test public void executeWithBlankLowercaseSchemaPattern() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("blank"); @@ -386,7 +386,7 @@ public void executeWithBlankLowercaseSchemaPattern() throws Exception { @Test public void executeWithSchemaPatternContainingBlank() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1BLANK"); @@ -399,7 +399,7 @@ public void executeWithSchemaPatternContainingBlank() throws Exception { @Test public void executeWithMultipleSchemaPatternsAndInterleavedBlank() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1,BLANK,SCHEMA2"); @@ -412,7 +412,7 @@ public void executeWithMultipleSchemaPatternsAndInterleavedBlank() throws Except @Test public void executeWithMultipleSchemaPatternsAndLeadingBlank() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("BLANK,SCHEMA2"); @@ -425,9 +425,9 @@ public void executeWithMultipleSchemaPatternsAndLeadingBlank() throws Exception } @Test - @Ignore("Trailing empty strings are not handled correctly by the MetaDataExporter") + @Disabled("Trailing empty strings are not handled correctly by the MetaDataExporter") public void executeWithMultipleSchemaPatternsAndTrailingBlank() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1,BLANK"); @@ -441,7 +441,7 @@ public void executeWithMultipleSchemaPatternsAndTrailingBlank() throws Exception @Test public void executeWithMultipleSchemaPatternsAndContainingBlank() throws Exception { - var targetFolder = "target/" + testName.getMethodName(); + var targetFolder = "target/" + testName; mojo.setTargetFolder(targetFolder); mojo.setSchemaPattern("SCHEMA1,SCHEMA2BLANK"); diff --git a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/TestMetadataExportMojoTest.java b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/TestMetadataExportMojoTest.java index e011c2a065..9cf797da45 100644 --- a/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/TestMetadataExportMojoTest.java +++ b/fluentq-tooling/fluentq-maven-plugin/src/test/java/fluentq/maven/TestMetadataExportMojoTest.java @@ -21,7 +21,7 @@ import java.util.Collections; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestMetadataExportMojoTest { diff --git a/fluentq-tooling/fluentq-sql-codegen/pom.xml b/fluentq-tooling/fluentq-sql-codegen/pom.xml index 3b4ef52a9d..c73f43e394 100644 --- a/fluentq-tooling/fluentq-sql-codegen/pom.xml +++ b/fluentq-tooling/fluentq-sql-codegen/pom.xml @@ -142,6 +142,13 @@ test + + tech.turso + turso + ${turso.version} + test + + io.github.openfeign.fluentq fluentq-core diff --git a/fluentq-tooling/fluentq-sql-codegen/src/main/java/fluentq/sql/codegen/MetaDataExporter.java b/fluentq-tooling/fluentq-sql-codegen/src/main/java/fluentq/sql/codegen/MetaDataExporter.java index 3e908f55bf..faa8b3b31c 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/main/java/fluentq/sql/codegen/MetaDataExporter.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/main/java/fluentq/sql/codegen/MetaDataExporter.java @@ -413,9 +413,13 @@ private void handleColumn(EntityType classModel, String tableName, ResultSet col var typeName = columns.getString("TYPE_NAME"); var columnSize = (Number) columns.getObject("COLUMN_SIZE"); var columnDigits = (Number) columns.getObject("DECIMAL_DIGITS"); - var columnIndex = columns.getInt("ORDINAL_POSITION"); + // Read the columns in ascending column-index order. In Oracle the COLUMN_DEF (index 13) value + // is exposed as a streamed LONG, and the driver closes that stream once a higher-indexed column + // (e.g. ORDINAL_POSITION, index 17) is read first, causing "ORA-17027: Stream has already been + // closed." on tables whose columns have default values. var nullable = columns.getInt("NULLABLE"); var columnDefaultValue = columns.getString("COLUMN_DEF"); + var columnIndex = columns.getInt("ORDINAL_POSITION"); var propertyName = namingStrategy.getPropertyName(normalizedColumnName, classModel); Class clazz = diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/CustomTypesTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/CustomTypesTest.java index d934ee2ed5..40c98f37af 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/CustomTypesTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/CustomTypesTest.java @@ -29,19 +29,18 @@ import fluentq.sql.types.UtilDateType; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.sql.SQLException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class CustomTypesTest extends AbstractJDBCTest { private Configuration configuration; @Override - @Before + @BeforeEach public void setUp() throws ClassNotFoundException, SQLException { super.setUp(); // create schema @@ -83,7 +82,7 @@ public void export() throws SQLException, IOException { exporter.export(connection.getMetaData()); var qpersonFile = Path.of("target", "customExport", "test", "QPerson.java"); assertThat(qpersonFile).exists(); - var person = new String(Files.readAllBytes(qpersonFile), StandardCharsets.UTF_8); + var person = Files.readString(qpersonFile); // System.err.println(person); assertThat(person).contains("createEnum(\"gender\""); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/DefaultNamingStrategyTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/DefaultNamingStrategyTest.java index 4cf8878a49..5fa61b1662 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/DefaultNamingStrategyTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/DefaultNamingStrategyTest.java @@ -18,8 +18,8 @@ import fluentq.codegen.EntityType; import fluentq.codegen.Property; import fluentq.codegen.utils.model.Types; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class DefaultNamingStrategyTest { @@ -27,7 +27,7 @@ public class DefaultNamingStrategyTest { private EntityType entityModel; - @Before + @BeforeEach public void setUp() { entityModel = new EntityType(Types.OBJECT); // entityModel.addAnnotation(new TableImpl("OBJECT")); diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportBaseTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportBaseTest.java index b879212ecb..c131cabfff 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportBaseTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportBaseTest.java @@ -16,15 +16,15 @@ import static org.assertj.core.api.Assertions.assertThat; import fluentq.sql.Connections; +import java.io.File; import java.sql.SQLException; -import org.junit.AfterClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public abstract class ExportBaseTest { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; @Test public void export() throws SQLException { @@ -32,20 +32,20 @@ public void export() throws SQLException { // config.setSpatial(true); config.setSchemaPattern(getSchemaPattern()); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setNamingStrategyClass(DefaultNamingStrategy.class); var exporter = new MetaDataExporter(config); exporter.export(Connections.getConnection().getMetaData()); - assertThat(folder.getRoot().listFiles().length).isGreaterThan(0); + assertThat(folder.listFiles().length).isGreaterThan(0); } protected String getSchemaPattern() { return null; } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws SQLException { Connections.close(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportDerbyTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportDerbyTest.java index 3350a8903b..b40d5fc6ba 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportDerbyTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportDerbyTest.java @@ -13,15 +13,14 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.Derby; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(Derby.class) +@Tag("fluentq.core.testutil.Derby") public class ExportDerbyTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initDerby(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2Test.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2Test.java index 15441e2e6c..df9a44db58 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2Test.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2Test.java @@ -13,15 +13,14 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.H2; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class ExportH2Test extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initH2(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2TwoSchemasTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2TwoSchemasTest.java index 5cca1fdf64..1fe43f6f83 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2TwoSchemasTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportH2TwoSchemasTest.java @@ -2,27 +2,24 @@ import static org.assertj.core.api.Assertions.assertThat; -import fluentq.core.testutil.H2; import fluentq.sql.Connections; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.sql.SQLException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; -@Category(H2.class) +@Tag("fluentq.core.testutil.H2") public class ExportH2TwoSchemasTest { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initH2(); @@ -35,7 +32,7 @@ public static void setUpClass() throws Exception { """); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws SQLException { Connections.close(); } @@ -45,15 +42,12 @@ public void export() throws SQLException, MalformedURLException, IOException { var config = new MetadataExporterConfigImpl(); config.setSchemaPattern(null); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); var exporter = new MetaDataExporter(config); exporter.export(Connections.getConnection().getMetaData()); - var contents = - new String( - Files.readAllBytes(new File(folder.getRoot(), "test/QSurvey.java").toPath()), - StandardCharsets.UTF_8); + var contents = Files.readString(new File(folder, "test/QSurvey.java").toPath()); assertThat(contents).contains("id"); assertThat(contents).contains("name"); assertThat(contents).contains("name2"); diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportHsqldbTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportHsqldbTest.java index 1735b5db67..8da5c7de41 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportHsqldbTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportHsqldbTest.java @@ -13,15 +13,14 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.HSQLDB; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(HSQLDB.class) +@Tag("fluentq.core.testutil.HSQLDB") public class ExportHsqldbTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initHSQL(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMSSQLTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMSSQLTest.java index f67da239b2..9960825eee 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMSSQLTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMSSQLTest.java @@ -13,15 +13,14 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.SQLServer; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(SQLServer.class) +@Tag("fluentq.core.testutil.SQLServer") public class ExportMSSQLTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initSQLServer(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMySQLTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMySQLTest.java index bad132d79c..818c5bc7bc 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMySQLTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportMySQLTest.java @@ -13,15 +13,14 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.MySQL; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(MySQL.class) +@Tag("fluentq.core.testutil.MySQL") public class ExportMySQLTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initMySQL(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportOracleTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportOracleTest.java index 35305838eb..8b79f10070 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportOracleTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportOracleTest.java @@ -13,16 +13,15 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.Oracle; import fluentq.sql.Connections; import java.util.TimeZone; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(Oracle.class) +@Tag("fluentq.core.testutil.Oracle") public class ExportOracleTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { var tz = TimeZone.getDefault(); try { diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportPostgreSQLTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportPostgreSQLTest.java index 38267a6f8d..712c2c1007 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportPostgreSQLTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportPostgreSQLTest.java @@ -13,15 +13,14 @@ */ package fluentq.sql.codegen; -import fluentq.core.testutil.PostgreSQL; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(PostgreSQL.class) +@Tag("fluentq.core.testutil.PostgreSQL") public class ExportPostgreSQLTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initPostgreSQL(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportSQLiteTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportSQLiteTest.java index 2d4d5c3d94..cd8ae641f5 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportSQLiteTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportSQLiteTest.java @@ -1,14 +1,13 @@ package fluentq.sql.codegen; -import fluentq.core.testutil.SQLite; import fluentq.sql.Connections; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(SQLite.class) +@Tag("fluentq.core.testutil.SQLite") public class ExportSQLiteTest extends ExportBaseTest { - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { Connections.initSQLite(); } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportTursoTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportTursoTest.java new file mode 100644 index 0000000000..7a43b2d200 --- /dev/null +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExportTursoTest.java @@ -0,0 +1,18 @@ +package fluentq.sql.codegen; + +import fluentq.sql.Connections; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; + +// Turso 0.6.0 JDBC DatabaseMetaData.getPrimaryKeys() returns null, so schema export codegen +// cannot read the database metadata. Re-enable once the driver implements it. See #1812. +@Disabled("Turso 0.6.0 JDBC metadata (getPrimaryKeys) incomplete, see #1812") +@Tag("fluentq.core.testutil.Turso") +public class ExportTursoTest extends ExportBaseTest { + + @BeforeAll + public static void setUpClass() throws Exception { + Connections.initTurso(); + } +} diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedBeanSerializerTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedBeanSerializerTest.java index 7240e397c8..b8b45bc9f5 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedBeanSerializerTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedBeanSerializerTest.java @@ -22,10 +22,9 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class ExtendedBeanSerializerTest { @@ -34,18 +33,21 @@ public class ExtendedBeanSerializerTest { private static final String PACKAGE = String.join(".", PATH); private static final String FULL_NAME = PACKAGE + "." + CLASS_NAME; - @Rule public TemporaryFolder compileFolder = new TemporaryFolder(); + @TempDir File compileFolder; private EntityType type; private File srcFile; - @Before + @BeforeEach public void setUp() throws IOException { Type typeModel = new SimpleType(TypeCategory.ENTITY, FULL_NAME, PACKAGE, CLASS_NAME, false, false); type = new EntityType(typeModel); - var srcFolder = compileFolder.newFolder(PATH); + var srcFolder = + java.nio.file.Files.createDirectories( + new File(compileFolder, String.join(File.separator, PATH)).toPath()) + .toFile(); srcFile = new File(srcFolder, CLASS_NAME + ".java"); } @@ -74,8 +76,7 @@ public void equals_hashcode_tostring() throws Exception { extendedBeanSerializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(fw)); fw.close(); - var classLoader = - URLClassLoader.newInstance(new URL[] {compileFolder.getRoot().toURI().toURL()}); + var classLoader = URLClassLoader.newInstance(new URL[] {compileFolder.toURI().toURL()}); var retCode = new SimpleCompiler().run(null, System.out, System.err, srcFile.getAbsolutePath()); assertThat(retCode).as("The generated source should compile").isEqualTo(0); diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedNamingStrategyTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedNamingStrategyTest.java index 455643ce79..cf45e9d2b9 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedNamingStrategyTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ExtendedNamingStrategyTest.java @@ -17,8 +17,8 @@ import fluentq.codegen.EntityType; import fluentq.codegen.utils.model.Types; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ExtendedNamingStrategyTest { @@ -26,7 +26,7 @@ public class ExtendedNamingStrategyTest { private EntityType entityModel; - @Before + @BeforeEach public void setUp() { entityModel = new EntityType(Types.OBJECT); // entityModel.addAnnotation(new TableImpl("OBJECT")); diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/KeyDataFactoryTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/KeyDataFactoryTest.java index c64a9b26b0..d22b34d3a2 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/KeyDataFactoryTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/KeyDataFactoryTest.java @@ -17,7 +17,7 @@ import fluentq.sql.AbstractJDBCTest; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class KeyDataFactoryTest extends AbstractJDBCTest { diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterAllTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterAllTest.java index 302954eb9a..2589c8e016 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterAllTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterAllTest.java @@ -1,12 +1,13 @@ package fluentq.sql.codegen; import static org.assertj.core.api.Assertions.fail; +import static org.junit.jupiter.api.DynamicTest.dynamicTest; import fluentq.codegen.BeanSerializer; import fluentq.codegen.utils.SimpleCompiler; -import fluentq.core.testutil.Parallelized; -import fluentq.core.testutil.SlowTest; +import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; @@ -15,34 +16,25 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.stream.Stream; import javax.tools.JavaCompiler; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(value = Parallelized.class) -@Category(SlowTest.class) +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestFactory; +import org.junit.jupiter.api.io.TempDir; + +@Tag("fluentq.core.testutil.SlowTest") public class MetaDataExporterAllTest { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; private static Connection connection; private static DatabaseMetaData metadata; private static JavaCompiler compiler = new SimpleCompiler(); - private String namePrefix, nameSuffix, beanPrefix, beanSuffix; - private String beanPackageName; - private Class beanSerializer = BeanSerializer.class; - private Class namingStrategyClass; - private boolean withBeans, withInnerClasses, withOrdinalPositioning; - private boolean exportColumns, schemaToPackage; - - @BeforeClass + @BeforeAll public static void setUpClass() throws ClassNotFoundException, SQLException { Class.forName("org.h2.Driver"); var url = "jdbc:h2:mem:testdb" + System.currentTimeMillis() + ";MODE=legacy"; @@ -51,12 +43,11 @@ public static void setUpClass() throws ClassNotFoundException, SQLException { MetaDataExporterTest.createTables(connection); } - @AfterClass + @AfterAll public static void tearDownClass() throws SQLException { connection.close(); } - @Parameterized.Parameters public static List parameters() { List params = new ArrayList<>(); @@ -118,33 +109,27 @@ public static List parameters() { return params; } - public MetaDataExporterAllTest( - String namePrefix, - String nameSuffix, - String beanPrefix, - String beanSuffix, - String beanPackageName, - Class namingStrategy, - boolean withBeans, - boolean withInnerClasses, - boolean withOrdinalPositioning, - boolean exportColumns, - boolean schemaToPackage) { - this.namePrefix = namePrefix; - this.nameSuffix = nameSuffix; - this.beanPrefix = beanPrefix; - this.beanSuffix = beanSuffix; - this.beanPackageName = beanPackageName; - this.schemaToPackage = schemaToPackage; - this.namingStrategyClass = namingStrategy; - this.withBeans = withBeans; - this.withInnerClasses = withInnerClasses; - this.withOrdinalPositioning = withOrdinalPositioning; - this.exportColumns = exportColumns; + @TestFactory + public Stream export() { + return parameters().stream().map(p -> dynamicTest(Arrays.toString(p), () -> runExport(p))); } - @Test - public void export() throws SQLException, IOException { + @SuppressWarnings("unchecked") + private void runExport(Object[] p) throws SQLException, IOException { + var namePrefix = (String) p[0]; + var nameSuffix = (String) p[1]; + var beanPrefix = (String) p[2]; + var beanSuffix = (String) p[3]; + var beanPackageName = (String) p[4]; + var namingStrategyClass = (Class) p[5]; + var withBeans = (boolean) p[6]; + var withInnerClasses = (boolean) p[7]; + var withOrdinalPositioning = (boolean) p[8]; + var exportColumns = (boolean) p[9]; + var schemaToPackage = (boolean) p[10]; + + var targetFolder = Files.createTempDirectory(folder.toPath(), "case").toFile(); + var config = new MetadataExporterConfigImpl(); config.setColumnAnnotations(exportColumns); config.setSchemaPattern("PUBLIC"); @@ -155,11 +140,11 @@ public void export() throws SQLException, IOException { config.setInnerClassesForKeys(withInnerClasses); config.setPackageName("test"); config.setBeanPackageName(beanPackageName); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(targetFolder); config.setNamingStrategyClass(namingStrategyClass); config.setSchemaToPackage(schemaToPackage); if (withBeans) { - config.setBeanSerializerClass(beanSerializer); + config.setBeanSerializerClass(BeanSerializer.class); } if (withOrdinalPositioning) { config.setColumnComparatorClass(OrdinalPositionComparator.class); @@ -172,7 +157,7 @@ public void export() throws SQLException, IOException { var compilationResult = compiler.run(null, System.out, System.err, classes.toArray(new String[0])); if (compilationResult != 0) { - fail("Compilation Failed for " + folder.getRoot().getPath()); + fail("Compilation Failed for " + targetFolder.getPath()); } } } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterColumnDefOrderingTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterColumnDefOrderingTest.java new file mode 100644 index 0000000000..b64c60876c --- /dev/null +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterColumnDefOrderingTest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2015, The FluentQ Team (http://www.fluentq.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fluentq.sql.codegen; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; + +import java.io.File; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +/** + * Regression test for the JDBC column-read ordering in {@link MetaDataExporter}. Oracle exposes + * {@code COLUMN_DEF} (index 13) as a streamed LONG and closes that stream as soon as a + * higher-indexed column such as {@code ORDINAL_POSITION} (index 17) is read first, which throws + * "ORA-17027: Stream has already been closed." on tables whose columns have default values. The + * exporter therefore must read {@code COLUMN_DEF} before {@code ORDINAL_POSITION}. + * + *

The Oracle JDBC driver streams LONG / LONG RAW columns and requires that they be read in + * SELECT-list order: the row is sent column by column and the stream of a LONG column is discarded + * once a later column is fetched. Because {@code DatabaseMetaData.getColumns(...)} backs {@code + * COLUMN_DEF} with such a LONG, the same ordering constraint applies to reading column metadata. + * See: + * + *

+ */ +public class MetaDataExporterColumnDefOrderingTest { + + @TempDir File folder; + + @Test + public void column_def_is_read_before_ordinal_position() throws SQLException { + var readOrder = new ArrayList(); + + ResultSet columns = createMock(ResultSet.class); + expect(columns.next()).andReturn(true).andReturn(false); + expect(columns.getString("COLUMN_NAME")).andReturn("NAME").anyTimes(); + expect(columns.getInt("DATA_TYPE")).andReturn(Types.VARCHAR).anyTimes(); + expect(columns.getString("TYPE_NAME")).andReturn("VARCHAR").anyTimes(); + expect(columns.getObject("COLUMN_SIZE")).andReturn(255).anyTimes(); + expect(columns.getObject("DECIMAL_DIGITS")).andReturn(null).anyTimes(); + expect(columns.getInt("NULLABLE")).andReturn(DatabaseMetaData.columnNullable).anyTimes(); + // Simulate Oracle's streamed-LONG behaviour: once ORDINAL_POSITION has been read the COLUMN_DEF + // stream is closed, so reading it afterwards fails. + expect(columns.getString("COLUMN_DEF")) + .andAnswer( + () -> { + if (readOrder.contains("ORDINAL_POSITION")) { + throw new SQLException("ORA-17027: Stream has already been closed."); + } + readOrder.add("COLUMN_DEF"); + return "'some default'"; + }) + .anyTimes(); + expect(columns.getInt("ORDINAL_POSITION")) + .andAnswer( + () -> { + readOrder.add("ORDINAL_POSITION"); + return 1; + }) + .anyTimes(); + columns.close(); + replay(columns); + + DatabaseMetaData metadata = createMock(DatabaseMetaData.class); + expect(metadata.getDatabaseProductName()).andReturn("Oracle").anyTimes(); + expect(metadata.getDatabaseMajorVersion()).andReturn(19).anyTimes(); + expect(metadata.getTables(anyObject(), anyObject(), anyObject(), anyObject())) + .andReturn(tableRow()); + expect(metadata.getColumns(anyObject(), anyObject(), anyObject(), anyObject())) + .andReturn(columns); + replay(metadata); + + var config = new MetadataExporterConfigImpl(); + config.setPackageName("test"); + config.setTargetFolder(folder); + // Keep the mock surface focused on column reading. + config.setExportPrimaryKeys(false); + config.setExportForeignKeys(false); + + var exporter = new MetaDataExporter(config); + // With the old ordering (ORDINAL_POSITION first) the COLUMN_DEF answer would raise ORA-17027 + // and export(...) would propagate the SQLException, failing this test. + exporter.export(metadata); + + assertThat(readOrder).containsExactly("COLUMN_DEF", "ORDINAL_POSITION"); + assertThat(new File(folder, "test/QFoo.java")).exists(); + } + + private ResultSet tableRow() throws SQLException { + ResultSet tables = createMock(ResultSet.class); + expect(tables.next()).andReturn(true).andReturn(false); + expect(tables.getString("TABLE_CAT")).andReturn(null).anyTimes(); + expect(tables.getString("TABLE_SCHEM")).andReturn("PUBLIC").anyTimes(); + expect(tables.getString("TABLE_NAME")).andReturn("FOO").anyTimes(); + tables.close(); + replay(tables); + return tables; + } +} diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterTest.java index 8af0cf41dc..dc4fedbb3f 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataExporterTest.java @@ -14,6 +14,7 @@ package fluentq.sql.codegen; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; import fluentq.codegen.BeanSerializer; @@ -32,12 +33,11 @@ import java.sql.DriverManager; import java.sql.SQLException; import javax.tools.JavaCompiler; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class MetaDataExporterTest { @@ -53,9 +53,9 @@ public class MetaDataExporterTest { private JavaCompiler compiler = new SimpleCompiler(); - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; - @BeforeClass + @BeforeAll public static void setUpClass() throws ClassNotFoundException, SQLException { Class.forName("org.h2.Driver"); var url = "jdbc:h2:mem:testdb" + System.currentTimeMillis() + ";MODE=legacy"; @@ -133,12 +133,12 @@ constraint product_bom foreign key (m_productbom_id) references product(id))\ } } - @AfterClass + @AfterAll public static void tearDownClass() throws SQLException { connection.close(); } - @Before + @BeforeEach public void setUp() throws ClassNotFoundException, SQLException { metadata = connection.getMetaData(); } @@ -147,14 +147,14 @@ public void setUp() throws ClassNotFoundException, SQLException { @Test public void normalSettings_repetition() throws SQLException { - test("Q", "", "", "", DefaultNamingStrategy.class, folder.getRoot(), false, false, false); + test("Q", "", "", "", DefaultNamingStrategy.class, folder, false, false, false); - var file = new File(folder.getRoot(), "test/QEmployee.java"); + var file = new File(folder, "test/QEmployee.java"); var lastModified = file.lastModified(); assertThat(file).exists(); clean = false; - test("Q", "", "", "", DefaultNamingStrategy.class, folder.getRoot(), false, false, false); + test("Q", "", "", "", DefaultNamingStrategy.class, folder, false, false, false); assertThat(file.lastModified()).isEqualTo(lastModified); } @@ -165,7 +165,7 @@ public void explicit_configuration() throws SQLException { config.setSchemaPattern("PUBLIC"); config.setNamePrefix("Q"); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setNamingStrategyClass(DefaultNamingStrategy.class); config.setBeanSerializerClass(BeanSerializer.class); config.setBeanPackageName("test2"); @@ -173,8 +173,8 @@ public void explicit_configuration() throws SQLException { var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/QDateTest.java")).exists(); - assertThat(new File(folder.getRoot(), "test2/DateTest.java")).exists(); + assertThat(new File(folder, "test/QDateTest.java")).exists(); + assertThat(new File(folder, "test2/DateTest.java")).exists(); } @Test @@ -193,15 +193,15 @@ name VARCHAR(255) NOT NULL DEFAULT 'some default')\ config.setNamePrefix("Q"); config.setPackageName("test"); config.setTableNamePattern("FOO"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setBeanSerializerClass(BeanSerializer.class); config.setValidationAnnotations(true); config.setExportBeans(true); var exporter = new MetaDataExporter(config); exporter.export(metadata); - var classLoader = URLClassLoader.newInstance(new URL[] {folder.getRoot().toURI().toURL()}); - compiler.run(null, null, null, folder.getRoot().getAbsoluteFile() + "/test/Foo.java"); + var classLoader = URLClassLoader.newInstance(new URL[] {folder.toURI().toURL()}); + compiler.run(null, null, null, folder.getAbsoluteFile() + "/test/Foo.java"); Class cls = Class.forName("test.Foo", true, classLoader); assertThat( ReflectionUtils.getAnnotatedElement(cls, "id", Integer.class) @@ -231,16 +231,16 @@ name VARCHAR(255) NOT NULL)\ config.setNamePrefix("Q"); config.setPackageName("test"); config.setTableNamePattern("BAR"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setBeanSerializerClass(BeanSerializer.class); config.setValidationAnnotations(true); config.setExportBeans(true); var exporter = new MetaDataExporter(config); exporter.export(metadata); - var file = new File(folder.getRoot().getAbsoluteFile(), "/test/Bar.java"); + var file = new File(folder.getAbsoluteFile(), "/test/Bar.java"); assertThat(file.exists()); - var classLoader = URLClassLoader.newInstance(new URL[] {folder.getRoot().toURI().toURL()}); + var classLoader = URLClassLoader.newInstance(new URL[] {folder.toURI().toURL()}); compiler.run(null, null, null, file.toString()); Class cls = Class.forName("test.Bar", true, classLoader); assertThat( @@ -260,11 +260,11 @@ public void minimal_configuration() throws SQLException { var config = new MetadataExporterConfigImpl(); config.setSchemaPattern("PUBLIC"); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/QDateTest.java")).exists(); + assertThat(new File(folder, "test/QDateTest.java")).exists(); } @Test @@ -272,11 +272,11 @@ public void minimal_configuration_with_schemas() throws SQLException { var config = new MetadataExporterConfigImpl(); config.setSchemaPattern("PUBLIC2,PUBLIC"); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/QDateTest.java")).exists(); + assertThat(new File(folder, "test/QDateTest.java")).exists(); } @Test @@ -285,14 +285,14 @@ public void minimal_configuration_with_schemas_and_tables() throws SQLException config.setSchemaPattern("PUBLIC2,PUBLIC"); config.setTableNamePattern("RESERVED,UNDERSCORE,BEANGEN1"); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/QBeangen1.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QReserved.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QUnderscore.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QDefinstance.java").exists()).isFalse(); + assertThat(new File(folder, "test/QBeangen1.java")).exists(); + assertThat(new File(folder, "test/QReserved.java")).exists(); + assertThat(new File(folder, "test/QUnderscore.java")).exists(); + assertThat(new File(folder, "test/QDefinstance.java").exists()).isFalse(); } @Test @@ -301,30 +301,34 @@ public void minimal_configuration_with_tables() throws SQLException { config.setSchemaPattern("PUBLIC"); config.setTableNamePattern("RESERVED,UNDERSCORE,BEANGEN1"); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/QBeangen1.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QReserved.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QUnderscore.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QDefinstance.java").exists()).isFalse(); + assertThat(new File(folder, "test/QBeangen1.java")).exists(); + assertThat(new File(folder, "test/QReserved.java")).exists(); + assertThat(new File(folder, "test/QUnderscore.java")).exists(); + assertThat(new File(folder, "test/QDefinstance.java").exists()).isFalse(); } - @Test(expected = IllegalStateException.class) + @Test public void minimal_configuration_with_duplicate_tables() throws SQLException { - var config = new MetadataExporterConfigImpl(); - config.setSchemaPattern("PUBLIC"); - config.setTableNamePattern("%,%"); - config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); - var exporter = new MetaDataExporter(config); - exporter.export(metadata); - - assertThat(new File(folder.getRoot(), "test/QBeangen1.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QReserved.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QUnderscore.java")).exists(); - assertThat(new File(folder.getRoot(), "test/QDefinstance.java").exists()).isFalse(); + assertThatThrownBy( + () -> { + var config = new MetadataExporterConfigImpl(); + config.setSchemaPattern("PUBLIC"); + config.setTableNamePattern("%,%"); + config.setPackageName("test"); + config.setTargetFolder(folder); + var exporter = new MetaDataExporter(config); + exporter.export(metadata); + + assertThat(new File(folder, "test/QBeangen1.java")).exists(); + assertThat(new File(folder, "test/QReserved.java")).exists(); + assertThat(new File(folder, "test/QUnderscore.java")).exists(); + assertThat(new File(folder, "test/QDefinstance.java").exists()).isFalse(); + }) + .isInstanceOf(IllegalStateException.class); } @Test @@ -334,11 +338,11 @@ public void minimal_configuration_with_suffix() throws SQLException { config.setPackageName("test"); config.setNamePrefix(""); config.setNameSuffix("Type"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/DateTestType.java")).exists(); + assertThat(new File(folder, "test/DateTestType.java")).exists(); } @Test @@ -348,12 +352,12 @@ public void minimal_configuration_without_keys() throws SQLException { config.setPackageName("test"); config.setNamePrefix(""); config.setNameSuffix("Type"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setExportForeignKeys(false); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/DateTestType.java")).exists(); + assertThat(new File(folder, "test/DateTestType.java")).exists(); } @Test @@ -363,12 +367,12 @@ public void minimal_configuration_only_direct_foreign_keys() throws SQLException config.setPackageName("test"); config.setNamePrefix(""); config.setNameSuffix("Type"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setExportInverseForeignKeys(false); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/DateTestType.java")).exists(); + assertThat(new File(folder, "test/DateTestType.java")).exists(); } @Test @@ -379,13 +383,13 @@ public void minimal_configuration_with_bean_prefix() throws SQLException { config.setNamePrefix(""); config.setBeanPrefix("Bean"); config.setBeanSerializerClass(BeanSerializer.class); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setExportBeans(true); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/DateTest.java")).exists(); - assertThat(new File(folder.getRoot(), "test/BeanDateTest.java")).exists(); + assertThat(new File(folder, "test/DateTest.java")).exists(); + assertThat(new File(folder, "test/BeanDateTest.java")).exists(); } @Test @@ -396,13 +400,13 @@ public void minimal_configuration_with_bean_suffix() throws SQLException { config.setNamePrefix(""); config.setBeanSuffix("Bean"); config.setBeanSerializerClass(BeanSerializer.class); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setExportBeans(true); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/DateTest.java")).exists(); - assertThat(new File(folder.getRoot(), "test/DateTestBean.java")).exists(); + assertThat(new File(folder, "test/DateTest.java")).exists(); + assertThat(new File(folder, "test/DateTestBean.java")).exists(); } @Test @@ -413,14 +417,15 @@ public void minimal_configuration_with_bean_folder() throws SQLException, IOExce config.setNamePrefix(""); config.setBeanSuffix("Bean"); config.setBeanSerializerClass(BeanSerializer.class); - config.setTargetFolder(folder.getRoot()); - config.setBeansTargetFolder(folder.newFolder("beans")); + config.setTargetFolder(folder); + config.setBeansTargetFolder( + java.nio.file.Files.createDirectories(new File(folder, "beans").toPath()).toFile()); config.setExportBeans(true); var exporter = new MetaDataExporter(config); exporter.export(metadata); - assertThat(new File(folder.getRoot(), "test/DateTest.java")).exists(); - assertThat(new File(folder.getRoot(), "beans/test/DateTestBean.java")).exists(); + assertThat(new File(folder, "test/DateTest.java")).exists(); + assertThat(new File(folder, "beans/test/DateTestBean.java")).exists(); } // @Test FIXME can't get mysql admin access working with circle CI, might need to move to @@ -450,23 +455,23 @@ foo VARCHAR(32) NOT NULL)\ config.setNamePrefix(""); config.setBeanSuffix("Bean"); config.setBeanSerializerClass(BeanSerializer.class); - config.setTargetFolder(folder.getRoot()); - config.setBeansTargetFolder(folder.newFolder("beans")); + config.setTargetFolder(folder); + config.setBeansTargetFolder( + java.nio.file.Files.createDirectories(new File(folder, "beans").toPath()).toFile()); var exporter = new MetaDataExporter(config); exporter.export(connection.getMetaData()); - assertThat(new File(folder.getRoot(), "test/TestCatalogTableOne.java")).exists(); - assertThat(new File(folder.getRoot(), "beans/test/TestCatalogTableOneBean.java")).exists(); + assertThat(new File(folder, "test/TestCatalogTableOne.java")).exists(); + assertThat(new File(folder, "beans/test/TestCatalogTableOneBean.java")).exists(); - assertThat(new File(folder.getRoot(), "test/TestCatalogTableTwo.java").exists()).isFalse(); - assertThat(new File(folder.getRoot(), "beans/test/TestCatalogTableTwoBean.java").exists()) - .isFalse(); + assertThat(new File(folder, "test/TestCatalogTableTwo.java").exists()).isFalse(); + assertThat(new File(folder, "beans/test/TestCatalogTableTwoBean.java").exists()).isFalse(); config.setCatalogPattern("catalog_test_two"); exporter.export(connection.getMetaData()); - assertThat(new File(folder.getRoot(), "test/TestCatalogTableTwo.java")).exists(); - assertThat(new File(folder.getRoot(), "beans/test/TestCatalogTableTwoBean.java")).exists(); + assertThat(new File(folder, "test/TestCatalogTableTwo.java")).exists(); + assertThat(new File(folder, "beans/test/TestCatalogTableTwoBean.java")).exists(); } finally { stmt.execute("DROP DATABASE IF EXISTS catalog_test_one"); stmt.execute("DROP DATABASE IF EXISTS catalog_test_two"); diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataSerializerTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataSerializerTest.java index a33b499005..09e71b456e 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataSerializerTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataSerializerTest.java @@ -13,7 +13,6 @@ */ package fluentq.sql.codegen; -import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -24,24 +23,24 @@ import fluentq.sql.Configuration; import fluentq.sql.SQLTemplates; import fluentq.sql.types.AbstractType; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import javax.tools.JavaCompiler; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class MetaDataSerializerTest extends AbstractJDBCTest { public static class CustomNumber {} - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir File folder; @Override - @Before + @BeforeEach public void setUp() throws SQLException, ClassNotFoundException { super.setUp(); statement.execute("drop table employee if exists"); @@ -93,7 +92,7 @@ public void normal_serialization() throws SQLException { config.setBeanSerializerClass(BeanSerializer.class); config.setNamePrefix(namePrefix); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setNamingStrategyClass(DefaultNamingStrategy.class); config.setExportBeans(true); var exporter = new MetaDataExporter(config); @@ -149,7 +148,7 @@ public void setValue(PreparedStatement st, int startIndex, CustomNumber value) config.setBeanSerializerClass(BeanSerializer.class); config.setNamePrefix(namePrefix); config.setPackageName("test"); - config.setTargetFolder(folder.getRoot()); + config.setTargetFolder(folder); config.setNamingStrategyClass(DefaultNamingStrategy.class); config.setGeneratedAnnotationClass("fluentq.core.annotations.Generated"); config.setExportBeans(true); @@ -190,7 +189,7 @@ private void compile(MetaDataExporter exporter) { } private void assertFileContainsInOrder(String path, String... methods) throws IOException { - var content = new String(Files.readAllBytes(folder.getRoot().toPath().resolve(path)), UTF_8); + var content = Files.readString(folder.toPath().resolve(path)); assertThat(content).containsIgnoringWhitespaces(methods); } } diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataTest.java index 60c9f33a1f..a230d3fe21 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/MetaDataTest.java @@ -19,14 +19,14 @@ import fluentq.codegen.utils.model.SimpleType; import fluentq.codegen.utils.model.Type; import fluentq.codegen.utils.model.TypeCategory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MetaDataTest { private EntityType classModel; - @Before + @BeforeEach public void setUp() { NamingStrategy namingStrategy = new DefaultNamingStrategy(); var packageName = "com.myproject.domain"; diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/OriginalNamingStrategyTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/OriginalNamingStrategyTest.java index a0e744add0..faaf9a1f1e 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/OriginalNamingStrategyTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/OriginalNamingStrategyTest.java @@ -17,8 +17,8 @@ import fluentq.codegen.EntityType; import fluentq.codegen.utils.model.Types; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class OriginalNamingStrategyTest { @@ -26,7 +26,7 @@ public class OriginalNamingStrategyTest { private EntityType entityModel; - @Before + @BeforeEach public void setUp() { entityModel = new EntityType(Types.OBJECT); // entityModel.addAnnotation(new TableImpl("OBJECT")); diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ant/AntMetaDataExporterTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ant/AntMetaDataExporterTest.java index 486da28b85..cababd08b5 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ant/AntMetaDataExporterTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/ant/AntMetaDataExporterTest.java @@ -20,14 +20,14 @@ import java.sql.SQLException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class AntMetaDataExporterTest { private static final String url = "jdbc:h2:./target/dbs/h2_AntMetaDataExporterTest;MODE=legacy"; - @BeforeClass + @BeforeAll public static void setUp() throws SQLException { try (var conn = DriverManager.getConnection(url, "sa", "")) { try (var stmt = conn.createStatement()) { diff --git a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/support/RenameMappingTest.java b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/support/RenameMappingTest.java index b0bf514b43..6caf4648a3 100644 --- a/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/support/RenameMappingTest.java +++ b/fluentq-tooling/fluentq-sql-codegen/src/test/java/fluentq/sql/codegen/support/RenameMappingTest.java @@ -5,7 +5,7 @@ import fluentq.sql.Configuration; import fluentq.sql.SQLTemplates; import fluentq.sql.SchemaAndTable; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RenameMappingTest { diff --git a/pom.xml b/pom.xml index 1a596009c2..69f8ae0c0a 100644 --- a/pom.xml +++ b/pom.xml @@ -94,11 +94,13 @@ 6.0 + 1.7.3 + 6.1.0 - 3.45.0 + 3.46.0 3.2.1 - 4.0.6 - 7.0.7 + 4.1.0 + 7.0.8 12.1.4.0 @@ -110,15 +112,16 @@ 9.7.0 13.4.0.jre11 9.3.9.0002 - 3.53.1.0 + 3.53.2.0 + 0.6.0 13.10.00.35 6.0.5 - 5.7.0 + 5.8.0 1.0.0.RELEASE - 7.3.6.Final + 7.4.1.Final 9.1.0.Final 5.0.0-B13 3.2.0 @@ -127,16 +130,18 @@ 3.27.7 3.9.16 33.6.0-jre + 2.22.0 0.6.8 - 1.18.8 + 1.18.10 2.0.18 - 3.5.5 + 3.5.6 1.27 2.2.5 2.5.3 1.37 - 2.3.21 - 2.3.8 + 2.4.0 + 2.3.9 + 0.13.0 2.3.0 2.2.0 2.13.16 @@ -163,7 +168,7 @@ io.smallrye jandex - 3.5.3 + 3.6.0 org.jetbrains @@ -276,7 +281,7 @@ io.projectreactor reactor-bom - 2025.0.5 + 2025.0.6 pom import @@ -300,11 +305,6 @@ junit-jupiter-api test - - org.junit.vintage - junit-vintage-engine - test - org.easymock easymock @@ -448,7 +448,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.26.0 + 0.26.1 @@ -538,7 +538,7 @@ org.jacoco jacoco-maven-plugin - 0.8.14 + 0.8.15 fluentq/** @@ -592,6 +592,7 @@ 0.300.0 false + ${project.baseUri}src/main/resources/bom-template.xml.vm querydsl-bom @@ -601,11 +602,23 @@ true + + + + install + deploy + + + io.github.openfeign.querydsl:* + *:querydsl-bom + *:querydsl-apt-test *:querydsl-examples *:querydsl-example-* *:querydsl-jpa-spring @@ -895,7 +908,7 @@ org.sonatype.central central-publishing-maven-plugin - 0.10.0 + 0.11.0 true central @@ -1079,11 +1092,35 @@ com.querydsl.core.testutil.Database, com.querydsl.core.testutil.MongoDB, + com.querydsl.core.testutil.CUBRID, + com.querydsl.core.testutil.DB2, + com.querydsl.core.testutil.Derby, + com.querydsl.core.testutil.Firebird, + com.querydsl.core.testutil.H2, + com.querydsl.core.testutil.HSQLDB, + com.querydsl.core.testutil.MySQL, + com.querydsl.core.testutil.Oracle, + com.querydsl.core.testutil.PostgreSQL, + com.querydsl.core.testutil.SQLite, + com.querydsl.core.testutil.Turso, + com.querydsl.core.testutil.SQLServer, com.querydsl.core.testutil.SlowTest, com.querydsl.core.testutil.Performance, com.querydsl.core.testutil.ReportingOnly, fluentq.core.testutil.Database, fluentq.core.testutil.MongoDB, + fluentq.core.testutil.CUBRID, + fluentq.core.testutil.DB2, + fluentq.core.testutil.Derby, + fluentq.core.testutil.Firebird, + fluentq.core.testutil.H2, + fluentq.core.testutil.HSQLDB, + fluentq.core.testutil.MySQL, + fluentq.core.testutil.Oracle, + fluentq.core.testutil.PostgreSQL, + fluentq.core.testutil.SQLite, + fluentq.core.testutil.Turso, + fluentq.core.testutil.SQLServer, fluentq.core.testutil.SlowTest, fluentq.core.testutil.Performance, fluentq.core.testutil.ReportingOnly @@ -1107,11 +1144,25 @@ com.querydsl.core.testutil.ExternalDatabase, com.querydsl.core.testutil.MongoDB, + com.querydsl.core.testutil.CUBRID, + com.querydsl.core.testutil.DB2, + com.querydsl.core.testutil.Firebird, + com.querydsl.core.testutil.MySQL, + com.querydsl.core.testutil.Oracle, + com.querydsl.core.testutil.PostgreSQL, + com.querydsl.core.testutil.SQLServer, com.querydsl.core.testutil.SlowTest, com.querydsl.core.testutil.Performance, com.querydsl.core.testutil.ReportingOnly, fluentq.core.testutil.ExternalDatabase, fluentq.core.testutil.MongoDB, + fluentq.core.testutil.CUBRID, + fluentq.core.testutil.DB2, + fluentq.core.testutil.Firebird, + fluentq.core.testutil.MySQL, + fluentq.core.testutil.Oracle, + fluentq.core.testutil.PostgreSQL, + fluentq.core.testutil.SQLServer, fluentq.core.testutil.SlowTest, fluentq.core.testutil.Performance, fluentq.core.testutil.ReportingOnly @@ -1143,18 +1194,18 @@ org.openrewrite.maven rewrite-maven-plugin - 6.40.0 + 6.42.0 org.openrewrite.recipe rewrite-testing-frameworks - 3.36.0 + 3.38.0 org.openrewrite.recipe rewrite-migrate-java - 3.35.0 + 3.37.0 diff --git a/querydsl-examples/pom.xml b/querydsl-examples/pom.xml index ea66fa0c1a..3a1cdccfdd 100644 --- a/querydsl-examples/pom.xml +++ b/querydsl-examples/pom.xml @@ -46,6 +46,14 @@ log4j-core 2.26.0 + + + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.5 + diff --git a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/guice/GuiceTestExtension.java b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/guice/GuiceTestExtension.java new file mode 100644 index 0000000000..c538ce969e --- /dev/null +++ b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/guice/GuiceTestExtension.java @@ -0,0 +1,16 @@ +package com.querydsl.example.jpa.guice; + +import com.google.inject.Guice; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstanceFactory; +import org.junit.jupiter.api.extension.TestInstanceFactoryContext; + +/** JUnit 5 replacement for the former {@code GuiceTestRunner}: builds test instances via Guice. */ +public class GuiceTestExtension implements TestInstanceFactory { + + @Override + public Object createTestInstance( + TestInstanceFactoryContext factoryContext, ExtensionContext extensionContext) { + return Guice.createInjector(new ServiceModule()).getInstance(factoryContext.getTestClass()); + } +} diff --git a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/guice/GuiceTestRunner.java b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/guice/GuiceTestRunner.java deleted file mode 100644 index 241e48133b..0000000000 --- a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/guice/GuiceTestRunner.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.querydsl.example.jpa.guice; - -import com.google.inject.Guice; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.InitializationError; - -public class GuiceTestRunner extends BlockJUnit4ClassRunner { - - public GuiceTestRunner(Class klass) throws InitializationError { - super(klass); - } - - @Override - protected Object createTest() throws Exception { - return Guice.createInjector(new ServiceModule()).getInstance(getTestClass().getJavaClass()); - } -} diff --git a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/AbstractPersistenceTest.java b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/AbstractPersistenceTest.java index 6ad47770f5..cea9b1f494 100644 --- a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/AbstractPersistenceTest.java +++ b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/AbstractPersistenceTest.java @@ -1,7 +1,7 @@ package com.querydsl.example.jpa.repository; import com.google.inject.persist.Transactional; -import com.querydsl.example.jpa.guice.GuiceTestRunner; +import com.querydsl.example.jpa.guice.GuiceTestExtension; import jakarta.inject.Inject; import jakarta.inject.Provider; import jakarta.persistence.EntityManager; @@ -11,14 +11,14 @@ import java.util.List; import org.hibernate.Session; import org.hibernate.jdbc.Work; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(GuiceTestRunner.class) +@ExtendWith(GuiceTestExtension.class) public abstract class AbstractPersistenceTest { @Inject private Provider em; - @Before + @BeforeEach @Transactional public void before() { var entityManager = em.get(); diff --git a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/TweetRepositoryTest.java b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/TweetRepositoryTest.java index 8e0e454f92..f6d2bd94e0 100644 --- a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/TweetRepositoryTest.java +++ b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/TweetRepositoryTest.java @@ -10,7 +10,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TweetRepositoryTest extends AbstractPersistenceTest { @Inject private TweetRepository repository; diff --git a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/UserRepositoryTest.java b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/UserRepositoryTest.java index cea96164bb..5254d23d73 100644 --- a/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/UserRepositoryTest.java +++ b/querydsl-examples/querydsl-example-jpa-guice/src/test/java/com/querydsl/example/jpa/repository/UserRepositoryTest.java @@ -4,7 +4,7 @@ import com.querydsl.example.jpa.model.User; import jakarta.inject.Inject; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UserRepositoryTest extends AbstractPersistenceTest { @Inject private UserRepository repository; diff --git a/querydsl-examples/querydsl-example-jpa-quarkus/Dockerfile b/querydsl-examples/querydsl-example-jpa-quarkus/Dockerfile index 6831392879..96ab61d354 100644 --- a/querydsl-examples/querydsl-example-jpa-quarkus/Dockerfile +++ b/querydsl-examples/querydsl-example-jpa-quarkus/Dockerfile @@ -1,7 +1,18 @@ +# Optional pre-built Querydsl artifacts, injected by CI's "compile" job via +# --build-context m2= --build-arg REUSE_M2=true +# so the image build does not have to recompile Querydsl from source. Empty by default, +# so a plain `docker build` still works standalone (it rebuilds Querydsl itself). +FROM scratch AS m2 + FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-25 AS build +ARG REUSE_M2=false COPY --chown=quarkus:quarkus . /code/ +COPY --from=m2 --chown=quarkus:quarkus . /home/quarkus/.m2/repository/ USER quarkus WORKDIR /code -RUN ./mvnw -ntp -B install -Pquickbuild -pl :querydsl-jpa -am -Dtoolchain.skip -Dgcf.skip -RUN ./mvnw verify -Dnative -Pexamples -pl :querydsl-example-jpa-quarkus -Dtoolchain.skip -Dgcf.skip +# Build Querydsl from source only when prebuilt artifacts were not injected. +RUN if [ "$REUSE_M2" != "true" ]; then \ + ./mvnw -ntp -B install -Pquickbuild -pl :querydsl-jpa -am -Dtoolchain.skip -Dgcf.skip ; \ + fi +RUN ./mvnw -ntp -B verify -Dnative -Pexamples -pl :querydsl-example-jpa-quarkus -Dtoolchain.skip -Dgcf.skip diff --git a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml index e4f4b3fd50..e9830adb5b 100644 --- a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml @@ -12,11 +12,20 @@ Querydsl example - JPA Quarkus - 3.35.4 + 3.36.3 + + + io.netty + netty-bom + 4.1.135.Final + pom + import + io.quarkus.platform quarkus-bom diff --git a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml index ae53f100df..3a1d5796c6 100644 --- a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml @@ -28,7 +28,7 @@ com.fasterxml.jackson.module jackson-module-kotlin - 2.21.3 + ${jackson.version} org.jetbrains.kotlin diff --git a/querydsl-examples/querydsl-example-kotlin-codegen/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt b/querydsl-examples/querydsl-example-kotlin-codegen/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt index 09e4807d9a..c654c8f693 100644 --- a/querydsl-examples/querydsl-example-kotlin-codegen/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt +++ b/querydsl-examples/querydsl-example-kotlin-codegen/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt @@ -20,7 +20,7 @@ import com.querydsl.examples.kotlin.entity.ExampleEntity import com.querydsl.examples.kotlin.entity.QExampleEntity import com.querydsl.examples.kotlin.entity.QExampleEntity.Companion.exampleEntity import com.querydsl.jpa.impl.JPAQuery -import org.junit.Test +import org.junit.jupiter.api.Test class ExampleEntityTest { diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt b/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt index dd8b5425a7..f66279fcf2 100644 --- a/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt +++ b/querydsl-examples/querydsl-example-kotlin-jpa/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt @@ -20,7 +20,7 @@ import com.querydsl.examples.kotlin.entity.ExampleEntity import com.querydsl.examples.kotlin.entity.QExampleEntity import com.querydsl.examples.kotlin.entity.QExampleEntity.exampleEntity import com.querydsl.jpa.impl.JPAQuery -import org.junit.Test +import org.junit.jupiter.api.Test class ExampleEntityTest { diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml index b87d47a434..a551ff7daf 100644 --- a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml @@ -96,6 +96,7 @@ kapt + process-sources src/main/kotlin diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt b/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt index 2ea4c8d7a4..46417e3a76 100644 --- a/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/src/test/kotlin/com/querydsl/examples/kotlin/ExampleEntityTest.kt @@ -17,7 +17,7 @@ package com.querydsl.examples.kotlin import com.querydsl.examples.kotlin.entity.QExampleEntity -import org.junit.Test +import org.junit.jupiter.api.Test class ExampleEntityTest { diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java index df3ac225d3..ee9628dbe7 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java @@ -2,25 +2,25 @@ import com.querydsl.example.config.TestConfiguration; import com.querydsl.example.config.TestDataService; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {TestConfiguration.class}) public abstract class AbstractDaoTest { @Autowired TestDataService testDataService; - @Before + @BeforeEach public void setUp() { testDataService.addTestData(); } - @After + @AfterEach public void tearDown() throws Exception { testDataService.removeTestData(); } diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java index d808e99e89..090340d4a1 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java @@ -1,7 +1,7 @@ package com.querydsl.example.dao; import com.querydsl.example.dto.Customer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/OrderDaoTest.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/OrderDaoTest.java index 0e85d9db14..17c562962c 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/OrderDaoTest.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/OrderDaoTest.java @@ -4,7 +4,7 @@ import com.querydsl.example.dto.Order; import com.querydsl.example.dto.OrderProduct; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/PersonDaoTest.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/PersonDaoTest.java index 509353270a..c87b5c82bf 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/PersonDaoTest.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/PersonDaoTest.java @@ -1,7 +1,7 @@ package com.querydsl.example.dao; import com.querydsl.example.dto.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/ProductDaoTest.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/ProductDaoTest.java index d1357028bf..4da9afa6e9 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/ProductDaoTest.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/ProductDaoTest.java @@ -3,7 +3,7 @@ import com.querydsl.example.dto.Product; import com.querydsl.example.dto.ProductL10n; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java index 8425ab7fcc..093c37e4c8 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java @@ -1,7 +1,7 @@ package com.querydsl.example.dao; import com.querydsl.example.dto.Supplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/ConnectionContextTest.java b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/ConnectionContextTest.java index b8063b1ded..7cf2714592 100644 --- a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/ConnectionContextTest.java +++ b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/ConnectionContextTest.java @@ -3,16 +3,16 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.inject.Inject; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(GuiceTestRunner.class) +@ExtendWith(GuiceTestExtension.class) public class ConnectionContextTest { @Inject private ConnectionContext context; - @After + @AfterEach public void tearDown() { context.removeConnection(); } diff --git a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/GuiceTestExtension.java b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/GuiceTestExtension.java new file mode 100644 index 0000000000..21272fafaa --- /dev/null +++ b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/GuiceTestExtension.java @@ -0,0 +1,19 @@ +package com.querydsl.example.sql.guice; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstanceFactory; +import org.junit.jupiter.api.extension.TestInstanceFactoryContext; + +/** JUnit 5 replacement for the former {@code GuiceTestRunner}: builds test instances via Guice. */ +public class GuiceTestExtension implements TestInstanceFactory { + + private static final Injector injector = Guice.createInjector(new ServiceModule()); + + @Override + public Object createTestInstance( + TestInstanceFactoryContext factoryContext, ExtensionContext extensionContext) { + return injector.getInstance(factoryContext.getTestClass()); + } +} diff --git a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/GuiceTestRunner.java b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/GuiceTestRunner.java deleted file mode 100644 index 2bff970828..0000000000 --- a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/guice/GuiceTestRunner.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.querydsl.example.sql.guice; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.InitializationError; - -public class GuiceTestRunner extends BlockJUnit4ClassRunner { - - private static final Injector injector = Guice.createInjector(new ServiceModule()); - - public GuiceTestRunner(Class klass) throws InitializationError { - super(klass); - } - - @Override - protected Object createTest() throws Exception { - return injector.getInstance(getTestClass().getJavaClass()); - } -} diff --git a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/AbstractPersistenceTest.java b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/AbstractPersistenceTest.java index 28eaefb79e..c4c54c9a19 100644 --- a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/AbstractPersistenceTest.java +++ b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/AbstractPersistenceTest.java @@ -1,20 +1,20 @@ package com.querydsl.example.sql.repository; -import com.querydsl.example.sql.guice.GuiceTestRunner; +import com.querydsl.example.sql.guice.GuiceTestExtension; import com.querydsl.example.sql.guice.Transactional; import jakarta.inject.Inject; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(GuiceTestRunner.class) +@ExtendWith(GuiceTestExtension.class) public abstract class AbstractPersistenceTest { @Inject private DataSource dataSource; - @Before + @BeforeEach @Transactional public void before() { try (var connection = dataSource.getConnection()) { diff --git a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/TweetRepositoryTest.java b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/TweetRepositoryTest.java index c107c712a4..4f7acc62c9 100644 --- a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/TweetRepositoryTest.java +++ b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/TweetRepositoryTest.java @@ -6,8 +6,8 @@ import com.querydsl.example.sql.model.Tweet; import com.querydsl.example.sql.model.Usert; import jakarta.inject.Inject; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class TweetRepositoryTest extends AbstractPersistenceTest { @Inject private TweetRepository repository; @@ -16,7 +16,7 @@ public class TweetRepositoryTest extends AbstractPersistenceTest { private Long posterId; - @Before + @BeforeEach public void setUp() { var poster = new Usert(); poster.setUsername("dr_frank"); diff --git a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/UserRepositoryTest.java b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/UserRepositoryTest.java index 44207b5c74..65277a4da2 100644 --- a/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/UserRepositoryTest.java +++ b/querydsl-examples/querydsl-example-sql-guice/src/test/java/com/querydsl/example/sql/repository/UserRepositoryTest.java @@ -5,7 +5,7 @@ import com.querydsl.example.sql.model.Tweet; import com.querydsl.example.sql.model.Usert; import jakarta.inject.Inject; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UserRepositoryTest extends AbstractPersistenceTest { @Inject private UserRepository repository; diff --git a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java index 427cdba9d2..cb33ec4e27 100644 --- a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java +++ b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/AbstractDaoTest.java @@ -2,15 +2,15 @@ import com.querydsl.example.config.TestConfiguration; import com.querydsl.example.config.TestDataService; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {TestConfiguration.class}) @Rollback @Transactional @@ -18,7 +18,7 @@ public abstract class AbstractDaoTest { @Autowired TestDataService testDataService; - @Before + @BeforeEach public void setUp() { testDataService.addTestData(); } diff --git a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java index 6f4115b9d0..048a2830b8 100644 --- a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java +++ b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/CustomerDaoTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; public class CustomerDaoTest extends AbstractDaoTest { diff --git a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/OrderDaoTest.java b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/OrderDaoTest.java index 2ded404db4..fa711fe57a 100644 --- a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/OrderDaoTest.java +++ b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/OrderDaoTest.java @@ -6,7 +6,7 @@ import com.querydsl.example.dto.Order; import com.querydsl.example.dto.OrderProduct; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; public class OrderDaoTest extends AbstractDaoTest { diff --git a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/PersonDaoTest.java b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/PersonDaoTest.java index 2a262291bb..6377ac587b 100644 --- a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/PersonDaoTest.java +++ b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/PersonDaoTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.querydsl.example.dto.Person; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; public class PersonDaoTest extends AbstractDaoTest { diff --git a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/ProductDaoTest.java b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/ProductDaoTest.java index a1fb530474..5f149323c8 100644 --- a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/ProductDaoTest.java +++ b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/ProductDaoTest.java @@ -5,7 +5,7 @@ import com.querydsl.example.dto.Product; import com.querydsl.example.dto.ProductL10n; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; public class ProductDaoTest extends AbstractDaoTest { diff --git a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java index c26bf36ac1..b67c50421b 100644 --- a/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java +++ b/querydsl-examples/querydsl-example-sql-spring/src/test/java/com/querydsl/example/dao/SupplierDaoTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.querydsl.example.dto.Supplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; public class SupplierDaoTest extends AbstractDaoTest { diff --git a/querydsl/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultEvaluatorFactory.java b/querydsl/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultEvaluatorFactory.java index 276ad04f45..2a4bfa73e0 100644 --- a/querydsl/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultEvaluatorFactory.java +++ b/querydsl/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultEvaluatorFactory.java @@ -37,7 +37,7 @@ import com.querydsl.core.util.PrimitiveUtils; import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.tools.JavaCompiler; @@ -113,8 +113,8 @@ public Evaluator create( } serializer.append(";"); - var constantToLabel = serializer.getConstantToLabel(); - var constants = getConstants(metadata, constantToLabel); + var constants = + getConstants(metadata, serializer.getConstants(), serializer.getConstantToLabel()); var types = new Class[sources.size()]; var names = new String[sources.size()]; for (var i = 0; i < sources.size(); i++) { @@ -156,8 +156,7 @@ public Evaluator> createEvaluator( ser.append("}\n"); ser.append("return rv;"); - var constantToLabel = ser.getConstantToLabel(); - var constants = getConstants(metadata, constantToLabel); + var constants = getConstants(metadata, ser.getConstants(), ser.getConstantToLabel()); Type sourceType = new ClassType(TypeCategory.SIMPLE, source.getType()); var sourceListType = new ClassType(TypeCategory.SIMPLE, Iterable.class, sourceType); @@ -270,8 +269,7 @@ public Evaluator> createEvaluator( } ser.append("return rv;"); - var constantToLabel = ser.getConstantToLabel(); - var constants = getConstants(metadata, constantToLabel); + var constants = getConstants(metadata, ser.getConstants(), ser.getConstantToLabel()); var projectionType = new ClassType(TypeCategory.LIST, List.class, Types.OBJECTS); return factory.createEvaluator( @@ -284,19 +282,25 @@ public Evaluator> createEvaluator( } private Map getConstants( - QueryMetadata metadata, Map constantToLabel) { - Map constants = new HashMap<>(); - for (Map.Entry entry : constantToLabel.entrySet()) { - if (entry.getKey() instanceof ParamExpression) { - var value = metadata.getParams().get(entry.getKey()); + QueryMetadata metadata, List constants, Map constantToLabel) { + var result = new LinkedHashMap(); + + for (var constant : constants) { + var paramName = constantToLabel.get(constant); + + if (constant instanceof ParamExpression) { + var value = metadata.getParams().get(constant); if (value == null) { - throw new ParamNotSetException((ParamExpression) entry.getKey()); + throw new ParamNotSetException((ParamExpression) constant); } - constants.put(entry.getValue(), value); - } else { - constants.put(entry.getValue(), entry.getKey()); + + result.put(paramName, value); + continue; } + + result.put(paramName, constant); } - return constants; + + return result; } } diff --git a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JpaInsertNativeHelper.java b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JpaInsertNativeHelper.java index 207fbf314f..bf5a1cd531 100644 --- a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JpaInsertNativeHelper.java +++ b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JpaInsertNativeHelper.java @@ -30,8 +30,7 @@ /** * Helpers shared by {@link com.querydsl.jpa.impl.JPAInsertClause} and {@link - * com.querydsl.jpa.hibernate.HibernateInsertClause} to support {@code executeWithKey()} via native - * SQL INSERT. + * com.querydsl.jpa.hibernate.HibernateInsertClause} to execute INSERT statements via native SQL. * *

This is an internal API and not intended for direct use by application code. */ @@ -98,6 +97,25 @@ public static Object[] resolveConstants( return result; } + /** + * Execute a native SQL INSERT and return the number of affected rows. + * + * @param conn the JDBC connection (not closed by this method) + * @param sql the native SQL INSERT string + * @param params the parameter values to bind, in positional order + * @return the number of affected rows + * @throws SQLException if a database error occurs + */ + public static long executeUpdate(java.sql.Connection conn, String sql, Object[] params) + throws SQLException { + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + for (int i = 0; i < params.length; i++) { + stmt.setObject(i + 1, params[i]); + } + return stmt.executeUpdate(); + } + } + /** * Execute a native SQL INSERT with {@code RETURN_GENERATED_KEYS} and return the generated key. * diff --git a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java index cd28592c1c..d5ba39509f 100644 --- a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java +++ b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java @@ -21,6 +21,7 @@ import com.querydsl.core.types.Expression; import com.querydsl.core.types.Path; import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.TemplateExpression; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.HQLTemplates; import com.querydsl.jpa.JPAQueryMixin; @@ -90,21 +91,68 @@ public HibernateInsertClause( @Override public long execute() { - var serializer = new JPQLSerializer(templates, null); - serializer.serializeForInsert( - queryMixin.getMetadata(), - inserts.isEmpty() ? columns : inserts.keySet(), - values, - subQuery, - inserts); + if (subQuery != null || !hasTemplateValue()) { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForInsert( + queryMixin.getMetadata(), + inserts.isEmpty() ? columns : inserts.keySet(), + values, + subQuery, + inserts); + + Query query = session.createQuery(serializer.toString()); + for (Map.Entry, LockMode> entry : lockModes.entrySet()) { + query.setLockMode(entry.getKey().toString(), entry.getValue()); + } + HibernateUtil.setConstants( + query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + var effectiveColumns = JpaInsertNativeHelper.effectiveColumns(inserts, columns); + if (effectiveColumns.isEmpty()) { + throw new IllegalStateException("No columns specified for insert"); + } + var effectiveValues = JpaInsertNativeHelper.effectiveValues(inserts, values); - Query query = session.createQuery(serializer.toString()); - for (Map.Entry, LockMode> entry : lockModes.entrySet()) { - query.setLockMode(entry.getKey().toString(), entry.getValue()); + var entityClass = queryMixin.getMetadata().getJoins().get(0).getTarget().getType(); + + var serializer = new JpaNativeInsertSerializer(new Configuration(SQLTemplates.DEFAULT)); + serializer.serializeInsert(entityClass, effectiveColumns, effectiveValues); + + var sql = serializer.toString(); + var params = + JpaInsertNativeHelper.resolveConstants( + serializer.getConstants(), queryMixin.getMetadata().getParams()); + + return session.doReturningWork( + connection -> { + try { + return JpaInsertNativeHelper.executeUpdate(connection, sql, params); + } catch (SQLException e) { + throw new QueryException("Failed to execute insert", e); + } + }); + } + + /** + * Whether any value expression is a {@link TemplateExpression} — typically a schema-qualified + * function call from {@code SQLExpressions.function/stringFunction/numberFunction} that + * Hibernate's HQL parser cannot type-check. When true, we route through the native SQL path to + * bypass HQL semantic validation. + */ + private boolean hasTemplateValue() { + for (Object v : values) { + if (v instanceof TemplateExpression) { + return true; + } + } + for (Expression v : inserts.values()) { + if (v instanceof TemplateExpression) { + return true; + } } - HibernateUtil.setConstants( - query, serializer.getConstants(), queryMixin.getMetadata().getParams()); - return query.executeUpdate(); + return false; } /** diff --git a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAInsertClause.java b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAInsertClause.java index a7e20cf6c5..194a6bed37 100644 --- a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAInsertClause.java +++ b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAInsertClause.java @@ -21,6 +21,7 @@ import com.querydsl.core.types.Expression; import com.querydsl.core.types.Path; import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.TemplateExpression; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.JPAQueryMixin; import com.querydsl.jpa.JPQLSerializer; @@ -76,20 +77,66 @@ public JPAInsertClause(EntityManager em, EntityPath entity, JPQLTemplates tem @Override public long execute() { - var serializer = new JPQLSerializer(templates, entityManager); - serializer.serializeForInsert( - queryMixin.getMetadata(), - inserts.isEmpty() ? columns : inserts.keySet(), - values, - subQuery, - inserts); + if (subQuery != null || !hasTemplateValue()) { + var serializer = new JPQLSerializer(templates, entityManager); + serializer.serializeForInsert( + queryMixin.getMetadata(), + inserts.isEmpty() ? columns : inserts.keySet(), + values, + subQuery, + inserts); + + var query = entityManager.createQuery(serializer.toString()); + if (lockMode != null) { + query.setLockMode(lockMode); + } + JPAUtil.setConstants(query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + var effectiveColumns = JpaInsertNativeHelper.effectiveColumns(inserts, columns); + if (effectiveColumns.isEmpty()) { + throw new IllegalStateException("No columns specified for insert"); + } + var effectiveValues = JpaInsertNativeHelper.effectiveValues(inserts, values); + + var entityClass = queryMixin.getMetadata().getJoins().get(0).getTarget().getType(); + + var serializer = new JpaNativeInsertSerializer(new Configuration(SQLTemplates.DEFAULT)); + serializer.serializeInsert(entityClass, effectiveColumns, effectiveValues); - var query = entityManager.createQuery(serializer.toString()); - if (lockMode != null) { - query.setLockMode(lockMode); + var sql = serializer.toString(); + var params = + JpaInsertNativeHelper.resolveConstants( + serializer.getConstants(), queryMixin.getMetadata().getParams()); + + // Provider-neutral native execute: use the JPA standard EntityManager.createNativeQuery + // instead of unwrapping a Hibernate Session, so this path also works under EclipseLink/OpenJPA. + var nativeQuery = entityManager.createNativeQuery(sql); + for (int i = 0; i < params.length; i++) { + nativeQuery.setParameter(i + 1, params[i]); + } + return nativeQuery.executeUpdate(); + } + + /** + * Whether any value expression is a {@link TemplateExpression} — typically a schema-qualified + * function call from {@code SQLExpressions.function/stringFunction/numberFunction} that + * Hibernate's HQL parser cannot type-check. When true, we route through the native SQL path to + * bypass HQL semantic validation. + */ + private boolean hasTemplateValue() { + for (Object v : values) { + if (v instanceof TemplateExpression) { + return true; + } + } + for (Expression v : inserts.values()) { + if (v instanceof TemplateExpression) { + return true; + } } - JPAUtil.setConstants(query, serializer.getConstants(), queryMixin.getMetadata().getParams()); - return query.executeUpdate(); + return false; } /** diff --git a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/DialectSupport.java b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/DialectSupport.java index a862cdbe4b..a5146affd1 100644 --- a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/DialectSupport.java +++ b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/DialectSupport.java @@ -71,9 +71,7 @@ public static void extendRegistry( var basicTypeRegistry = functionContributions.getTypeConfiguration().getBasicTypeRegistry(); functions.forEach( - (name, template) -> - functionRegistry.registerPattern( - name, template.pattern(), basicTypeRegistry.resolve(template.type()))); + (name, template) -> registerPattern(functionRegistry, basicTypeRegistry, name, template)); } public static void extendRegistry( @@ -83,8 +81,23 @@ public static void extendRegistry( var functionRegistry = functionContributions.getFunctionRegistry(); var basicTypeRegistry = functionContributions.getTypeConfiguration().getBasicTypeRegistry(); - functionRegistry.registerPattern( - name, template.pattern(), basicTypeRegistry.resolve(template.type())); + registerPattern(functionRegistry, basicTypeRegistry, name, template); + } + + private static void registerPattern( + org.hibernate.query.sqm.function.SqmFunctionRegistry functionRegistry, + org.hibernate.type.BasicTypeRegistry basicTypeRegistry, + String name, + DialectFunctionTemplate template) { + // Operators such as CURRENT_DATE are declared with a generic Comparable type that does not map + // to a Hibernate BasicType. In that case register the pattern without an explicit return type + // and let Hibernate infer it, instead of failing on a null type. + if (template.type() == null) { + functionRegistry.registerPattern(name, template.pattern()); + } else { + functionRegistry.registerPattern( + name, template.pattern(), basicTypeRegistry.resolve(template.type())); + } } static class DialectFunctionTemplate { diff --git a/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QSQLServerDialect.java b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QSQLServerDialect.java new file mode 100644 index 0000000000..5e416b1d5c --- /dev/null +++ b/querydsl/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QSQLServerDialect.java @@ -0,0 +1,34 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.com.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.support; + +import com.querydsl.core.types.Ops; +import com.querydsl.sql.SQLServer2012Templates; +import org.hibernate.boot.model.FunctionContributions; +import org.hibernate.dialect.SQLServerDialect; + +/** {@code QSQLServerDialect} extends {@code SQLServerDialect} with additional functions */ +@Deprecated +public class QSQLServerDialect extends SQLServerDialect { + + @Override + public void initializeFunctionRegistry(FunctionContributions functionContributions) { + super.initializeFunctionRegistry(functionContributions); + DialectSupport.extendRegistry(SQLServer2012Templates.DEFAULT, functionContributions); + DialectSupport.extendRegistry( + "current_date", + DialectSupport.createFunction(SQLServer2012Templates.DEFAULT, Ops.DateTimeOps.CURRENT_DATE), + functionContributions); + } +} diff --git a/querydsl/querydsl-libraries/querydsl-sql-json/pom.xml b/querydsl/querydsl-libraries/querydsl-sql-json/pom.xml index 565e94fa3e..66c8f1ebc4 100644 --- a/querydsl/querydsl-libraries/querydsl-sql-json/pom.xml +++ b/querydsl/querydsl-libraries/querydsl-sql-json/pom.xml @@ -22,7 +22,7 @@ com.fasterxml.jackson jackson-bom - 2.21.3 + ${jackson.version} pom import diff --git a/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Keywords.java b/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Keywords.java index c97159bdf3..ae84a7defc 100644 --- a/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Keywords.java +++ b/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Keywords.java @@ -51,6 +51,7 @@ private static Set readLines(String path) { public static final Set ORACLE = readLines("oracle"); public static final Set POSTGRESQL = readLines("postgresql"); public static final Set SQLITE = readLines("sqlite"); + public static final Set TURSO = readLines("turso"); public static final Set SQLSERVER2005 = readLines("sqlserver2005"); public static final Set SQLSERVER2008 = readLines("sqlserver2008"); public static final Set SQLSERVER2012 = readLines("sqlserver2012"); diff --git a/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplatesRegistry.java b/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplatesRegistry.java index ae96b37233..a2ff6d2387 100644 --- a/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplatesRegistry.java +++ b/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplatesRegistry.java @@ -59,6 +59,8 @@ public SQLTemplates.Builder getBuilder(DatabaseMetaData md) throws SQLException return PostgreSQLTemplates.builder(); } else if (name.equals("sqlite")) { return SQLiteTemplates.builder(); + } else if (name.equals("turso")) { + return TursoTemplates.builder(); } else if (name.startsWith("teradata")) { return TeradataTemplates.builder(); } else if (name.equals("microsoft sql server")) { diff --git a/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TursoTemplates.java b/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TursoTemplates.java new file mode 100644 index 0000000000..313088b08f --- /dev/null +++ b/querydsl/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TursoTemplates.java @@ -0,0 +1,167 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.com.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.sql; + +import com.querydsl.core.types.Ops; +import com.querydsl.sql.types.BigDecimalAsDoubleType; +import com.querydsl.sql.types.BigIntegerAsLongType; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoField; + +/** + * {@code TursoTemplates} is a SQL dialect for Turso (https://github.com/tursodatabase/turso), a + * SQLite-compatible database + * + * @author tiwe + */ +@Deprecated +public class TursoTemplates extends SQLTemplates { + + private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + private static final DateTimeFormatter dateTimeFormatter = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + private static final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + + @SuppressWarnings("FieldNameHidesFieldInSuperclass") // Intentional + public static final TursoTemplates DEFAULT = new TursoTemplates(); + + public static Builder builder() { + return new Builder() { + @Override + protected SQLTemplates build(char escape, boolean quote) { + return new TursoTemplates(escape, quote); + } + }; + } + + public TursoTemplates() { + this('\\', false); + } + + public TursoTemplates(boolean quote) { + this('\\', quote); + } + + public TursoTemplates(char escape, boolean quote) { + super(Keywords.TURSO, "\"", escape, quote, false); + setDummyTable(null); + addCustomType(BigDecimalAsDoubleType.DEFAULT); + addCustomType(BigIntegerAsLongType.DEFAULT); + setUnionsWrapped(false); + setLimitRequired(true); + setNullsFirst(null); + setNullsLast(null); + setDefaultValues("\ndefault values"); + setArraysSupported(false); + setBatchToBulkSupported(false); + + setPrecedence(Precedence.COMPARISON - 1, Ops.LT, Ops.GT, Ops.LOE, Ops.GOE); + setPrecedence(Precedence.COMPARISON, Ops.EQ, Ops.EQ_IGNORE_CASE, Ops.NE); + + add(Ops.MOD, "{0} % {1}", Precedence.ARITH_HIGH); + + add(Ops.INDEX_OF, "charindex({1},{0},1)-1", Precedence.ARITH_LOW); + add(Ops.INDEX_OF_2ARGS, "charindex({1},{0},{2s}+1)-1", Precedence.ARITH_LOW); + + add(Ops.StringOps.LOCATE, "charindex({0},{1})"); + add(Ops.StringOps.LOCATE2, "charindex({0},{1},{2s})"); + + // TODO : optimize + add( + Ops.DateTimeOps.YEAR, + "cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.MONTH, + "cast(strftime('%m',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.WEEK, + "cast(strftime('%W',{0} / 1000, 'unixepoch', 'localtime') as integer) + 1"); + add( + Ops.DateTimeOps.DAY_OF_MONTH, + "cast(strftime('%d',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.DAY_OF_WEEK, + "cast(strftime('%w',{0} / 1000, 'unixepoch', 'localtime') as integer) + 1"); + add( + Ops.DateTimeOps.DAY_OF_YEAR, + "cast(strftime('%j',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.HOUR, + "cast(strftime('%H',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.MINUTE, + "cast(strftime('%M',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + add( + Ops.DateTimeOps.SECOND, + "cast(strftime('%S',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + + add( + Ops.DateTimeOps.YEAR_MONTH, + """ + cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') * 100 + strftime('%m',{0} / 1000,\ + 'unixepoch', 'localtime') as integer)\ + """); + add( + Ops.DateTimeOps.YEAR_WEEK, + "cast(strftime('%Y%W',{0} / 1000, 'unixepoch', 'localtime') as integer)"); + + add(Ops.DateTimeOps.ADD_YEARS, "date({0}, '+{1s} year')"); + add(Ops.DateTimeOps.ADD_MONTHS, "date({0}, '+{1s} month')"); + add(Ops.DateTimeOps.ADD_WEEKS, "date({0}, '+{1s} week')"); + add(Ops.DateTimeOps.ADD_DAYS, "date({0}, '+{1s} day')"); + add(Ops.DateTimeOps.ADD_HOURS, "date({0}, '+{1s} hour')"); + add(Ops.DateTimeOps.ADD_MINUTES, "date({0}, '+{1s} minute')"); + add(Ops.DateTimeOps.ADD_SECONDS, "date({0}, '+{1s} second')"); + + add(Ops.MathOps.RANDOM, "random()"); + add(Ops.MathOps.RANDOM2, "random({0})"); + add(Ops.MathOps.LN, "log({0})"); + add(Ops.MathOps.LOG, "log({0}) / log({1})", Precedence.ARITH_HIGH); + + add(SQLOps.GROUP_CONCAT2, "group_concat({0},{1})"); + + addTypeNameToCode("text", Types.VARCHAR); + } + + @Override + public String serialize(String literal, int jdbcType) { + // XXX doesn't work with LocalDate, LocalDateTime and LocalTime + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> + String.valueOf( + dateTimeFormatter + .parse(literal, LocalDateTime::from) + .toInstant(ZoneOffset.UTC) + .toEpochMilli()); + case Types.DATE -> + String.valueOf( + dateFormatter + .parse(literal, LocalDate::from) + .atStartOfDay(ZoneOffset.UTC) + .toInstant() + .toEpochMilli()); + case Types.TIME, TIME_WITH_TIMEZONE -> + String.valueOf( + timeFormatter.parse(literal, LocalTime::from).get(ChronoField.MILLI_OF_DAY)); + default -> super.serialize(literal, jdbcType); + }; + } +} diff --git a/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java b/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java index d07ca4ae91..024ac9ae89 100644 --- a/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java +++ b/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java @@ -37,9 +37,11 @@ import java.util.Set; import java.util.function.Function; import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.ErrorType; @@ -52,6 +54,7 @@ import javax.lang.model.type.TypeVariable; import javax.lang.model.type.TypeVisitor; import javax.lang.model.type.WildcardType; +import javax.lang.model.util.ElementFilter; import org.jetbrains.annotations.Nullable; /** @@ -374,8 +377,38 @@ private Type createType(TypeMirror typeMirror, List key, boolean deep) { } } + private boolean isKotlinValueClass(TypeElement typeElement) { + for (AnnotationMirror annotation : typeElement.getAnnotationMirrors()) { + if (annotation.getAnnotationType().toString().equals("kotlin.jvm.JvmInline")) { + return true; + } + } + return false; + } + + private TypeMirror getKotlinValueClassUnderlyingType(TypeElement typeElement) { + var instanceFields = new ArrayList(); + for (var field : ElementFilter.fieldsIn(typeElement.getEnclosedElements())) { + if (!field.getModifiers().contains(Modifier.STATIC)) { + instanceFields.add(field); + } + } + if (instanceFields.size() == 1) { + return instanceFields.get(0).asType(); + } + return null; + } + // TODO : simplify private Type createClassType(DeclaredType declaredType, TypeElement typeElement, boolean deep) { + // Kotlin value classes (@JvmInline) should be unwrapped to their underlying type + if (isKotlinValueClass(typeElement)) { + var underlyingType = getKotlinValueClassUnderlyingType(typeElement); + if (underlyingType != null) { + return getType(underlyingType, deep); + } + } + // other var name = typeElement.getQualifiedName().toString(); diff --git a/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeElementHandler.java b/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeElementHandler.java index 3a0820cbd7..e122ecb9ca 100644 --- a/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeElementHandler.java +++ b/querydsl/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeElementHandler.java @@ -192,6 +192,9 @@ public EntityType handleProjectionType( private Type getType(VariableElement element) { Type rv = typeFactory.getType(element.asType(), true); + if (rv == null) { + return null; + } if (element.getAnnotation(QueryType.class) != null) { var qt = element.getAnnotation(QueryType.class); if (qt.value() != PropertyType.NONE) { diff --git a/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JDKEvaluatorFactory.java b/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JDKEvaluatorFactory.java index 613386b54e..bdb6ccc9e3 100644 --- a/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JDKEvaluatorFactory.java +++ b/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JDKEvaluatorFactory.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Optional; import javax.tools.JavaCompiler; import javax.tools.SimpleJavaFileObject; import javax.tools.StandardLocation; @@ -52,10 +51,7 @@ public JDKEvaluatorFactory(ClassLoader parent, JavaCompiler compiler) { this.fileManager = new MemFileManager(parent, compiler.getStandardFileManager(null, null, null)); this.compiler = compiler; - this.classpath = - Optional.of(SimpleCompiler.getClassPath(parent)) - .filter(s -> !s.isEmpty()) - .orElseGet(() -> SimpleCompiler.getClassPath(compiler.getClass().getClassLoader())); + this.classpath = SimpleCompiler.getClassPath(parent); this.loader = fileManager.getClassLoader(StandardLocation.CLASS_OUTPUT); this.compilationOptions = Arrays.asList("-classpath", classpath, "-g:none"); } diff --git a/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/SimpleCompiler.java b/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/SimpleCompiler.java index caff256cff..700c26fc6e 100644 --- a/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/SimpleCompiler.java +++ b/querydsl/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/SimpleCompiler.java @@ -37,7 +37,7 @@ public class SimpleCompiler implements JavaCompiler { public static String getClassPath(ClassLoader cl) { - return new ClassGraph().overrideClassLoaders(cl).getClasspath(); + return new ClassGraph().addClassLoader(cl).getClasspath(); } private final ClassLoader classLoader; diff --git a/querydsl/querydsl-tooling/querydsl-kotlin-codegen/src/main/kotlin/com/querydsl/kotlin/codegen/Extensions.kt b/querydsl/querydsl-tooling/querydsl-kotlin-codegen/src/main/kotlin/com/querydsl/kotlin/codegen/Extensions.kt index da2d1d408d..7652e95497 100644 --- a/querydsl/querydsl-tooling/querydsl-kotlin-codegen/src/main/kotlin/com/querydsl/kotlin/codegen/Extensions.kt +++ b/querydsl/querydsl-tooling/querydsl-kotlin-codegen/src/main/kotlin/com/querydsl/kotlin/codegen/Extensions.kt @@ -27,10 +27,26 @@ import com.squareup.kotlinpoet.asTypeName import com.squareup.kotlinpoet.joinToCode import kotlin.reflect.KClass +private val PRIMITIVE_ARRAY_FULL_NAMES = + setOf("boolean[]", "byte[]", "char[]", "short[]", "int[]", "long[]", "float[]", "double[]") + +// Component type of an object array (e.g. String[]), or null for non-arrays and primitive +// arrays. Primitive arrays (int[], byte[], ...) keep their dedicated Kotlin array class +// (IntArray, ByteArray, ...) via asClassName() and must not be wrapped in Array. +private fun Type.objectArrayComponentType(): Type? = + componentType?.takeUnless { fullName in PRIMITIVE_ARRAY_FULL_NAMES } + @JvmOverloads -fun Type.asTypeName(out: Boolean = false): TypeName = asClassName().let { className -> - if (parameters.isNotEmpty()) - className.parameterizedBy(*parameters.map { if (out) it.asOutTypeName() else it.asTypeName() }.toTypedArray()) else className +fun Type.asTypeName(out: Boolean = false): TypeName { + // Object arrays (e.g. String[]) must be rendered as the Kotlin Array type. + objectArrayComponentType()?.let { component -> + return Array::class.asClassName() + .parameterizedBy(if (out) component.asOutTypeName() else component.asTypeName()) + } + return asClassName().let { className -> + if (parameters.isNotEmpty()) + className.parameterizedBy(*parameters.map { if (out) it.asOutTypeName() else it.asTypeName() }.toTypedArray()) else className + } } fun Type.asClassName(): ClassName = when (this.fullName) { @@ -67,7 +83,10 @@ private fun Type.enclosingTypeHierarchy(): List { fun ClassName.asClassStatement() = CodeBlock.of("%T::class.java", this) -fun Type.asClassNameStatement() = asClassName().asClassStatement() +fun Type.asClassNameStatement(): CodeBlock = + // Object arrays need the Kotlin Array::class.java form to resolve to the right runtime class. + objectArrayComponentType()?.let { CodeBlock.of("%T::class.java", asTypeName()) } + ?: asClassName().asClassStatement() fun TypeMappings.getPathClassName(type: Type, model: EntityType) = getPathType(type, model, true).asClassName() diff --git a/querydsl/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/QueryModelExtractor.kt b/querydsl/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/QueryModelExtractor.kt index 7d3cacd43e..46dfb8ceef 100644 --- a/querydsl/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/QueryModelExtractor.kt +++ b/querydsl/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/QueryModelExtractor.kt @@ -168,13 +168,22 @@ class QueryModelExtractor( } private fun toQueryModel(classDeclaration: KSClassDeclaration, type: QueryModelType, constructor: KSFunctionDeclaration?): QueryModel { + val simpleNames = generateSequence(classDeclaration) { it.parentDeclaration as? KSClassDeclaration } + .map { it.simpleName.asString() } + .toList() + .reversed() + return QueryModel( // Build the ClassName from raw KSP names to avoid kotlinpoet-ksp's // toClassName(), which invalidates KSP2 lifetime tokens (see // superclassOrNull above for the same workaround). + // Inner classes need the full parent hierarchy passed as vararg simple names + // so KotlinPoet emits a qualified reference (e.g. Outer.Inner) instead of + // the bare Inner, which fails to resolve at compile time. originalClassName = ClassName( classDeclaration.packageName.asString(), - classDeclaration.simpleName.asString() + simpleNames.first(), + *simpleNames.drop(1).toTypedArray() ), typeParameterCount = classDeclaration.typeParameters.size, className = queryClassName(classDeclaration, settings), diff --git a/querydsl/querydsl-tooling/querydsl-sql-codegen/src/main/java/com/querydsl/sql/codegen/MetaDataExporter.java b/querydsl/querydsl-tooling/querydsl-sql-codegen/src/main/java/com/querydsl/sql/codegen/MetaDataExporter.java index 5618b31ba0..2175be8b52 100644 --- a/querydsl/querydsl-tooling/querydsl-sql-codegen/src/main/java/com/querydsl/sql/codegen/MetaDataExporter.java +++ b/querydsl/querydsl-tooling/querydsl-sql-codegen/src/main/java/com/querydsl/sql/codegen/MetaDataExporter.java @@ -414,9 +414,13 @@ private void handleColumn(EntityType classModel, String tableName, ResultSet col var typeName = columns.getString("TYPE_NAME"); var columnSize = (Number) columns.getObject("COLUMN_SIZE"); var columnDigits = (Number) columns.getObject("DECIMAL_DIGITS"); - var columnIndex = columns.getInt("ORDINAL_POSITION"); + // Read the columns in ascending column-index order. In Oracle the COLUMN_DEF (index 13) value + // is exposed as a streamed LONG, and the driver closes that stream once a higher-indexed column + // (e.g. ORDINAL_POSITION, index 17) is read first, causing "ORA-17027: Stream has already been + // closed." on tables whose columns have default values. var nullable = columns.getInt("NULLABLE"); var columnDefaultValue = columns.getString("COLUMN_DEF"); + var columnIndex = columns.getInt("ORDINAL_POSITION"); var propertyName = namingStrategy.getPropertyName(normalizedColumnName, classModel); Class clazz = diff --git a/src/main/resources/bom-template.xml.vm b/src/main/resources/bom-template.xml.vm new file mode 100644 index 0000000000..9137cb5706 --- /dev/null +++ b/src/main/resources/bom-template.xml.vm @@ -0,0 +1,85 @@ + + + 4.0.0 + + + + + io.github.openfeign.querydsl + querydsl-root + ${model.version} + ../pom.xml + + + ${model.artifactId} + ${model.name} + pom + ${model.description} + + + #foreach($d in $model.dependencyManagement.dependencies) + + + ${d.groupId} + ${d.artifactId} + ${d.version}#if( $d.scope && $!d.scope != '' ) + + ${d.scope}#end#if( $d.type && $!d.type != '' && $!d.type != 'jar' && $!d.type != 'bundle') + + ${d.type}#end#if( $d.classifier && $!d.classifier != '' ) + + ${d.classifier}#end#if( $d.exclusions && $d.exclusions.size() > 0 ) + + #foreach( $e in $d.exclusions ) + + + ${e.groupId} + ${e.artifactId} + #end + + #end + + #end + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + ${flatten-maven-plugin.version} + false + + + + flatten + process-resources + + flatten + + + true + bom + + remove + keep + remove + remove + remove + remove + remove + remove + + + + + + + +