From d3d9ff99cc5bef4da2e211e2b88beba370755563 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 17 Apr 2024 20:19:30 +0800 Subject: [PATCH] update --- .../athena/application/ResourceConfig.java | 3 ++ .../docker-compose.yml | 2 +- .../mysql-init.sql | 29 +++++++++++++++++++ .../test/acceptance/InitStepDefinitions.java | 2 +- .../athena-example-books/docker-compose.yml | 4 +-- athena-examples/athena-example-books/pom.xml | 7 +++++ .../resources/applicationConfig.properties | 5 ++-- pom.xml | 2 +- 8 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 athena-examples/athena-example-acceptance-tests/mysql-init.sql diff --git a/athena-core/src/main/java/io/github/qubitpi/athena/application/ResourceConfig.java b/athena-core/src/main/java/io/github/qubitpi/athena/application/ResourceConfig.java index 5b946b4ae..5f76275d2 100644 --- a/athena-core/src/main/java/io/github/qubitpi/athena/application/ResourceConfig.java +++ b/athena-core/src/main/java/io/github/qubitpi/athena/application/ResourceConfig.java @@ -61,6 +61,9 @@ public class ResourceConfig extends org.glassfish.jersey.server.ResourceConfig { public ResourceConfig() throws ClassNotFoundException, InstantiationException, IllegalAccessException { final Class binderClass = Class.forName(getBindingFactory()) .asSubclass(BinderFactory.class); + + LOG.error(String.format("Binding resources using '%s'", binderClass.getCanonicalName())); + final BinderFactory binderFactory = binderClass.newInstance(); final Binder binder = binderFactory.buildBinder(); diff --git a/athena-examples/athena-example-acceptance-tests/docker-compose.yml b/athena-examples/athena-example-acceptance-tests/docker-compose.yml index 43d80e282..4e6fe3a5c 100644 --- a/athena-examples/athena-example-acceptance-tests/docker-compose.yml +++ b/athena-examples/athena-example-acceptance-tests/docker-compose.yml @@ -16,7 +16,7 @@ services: web: build: . ports: - - "80:8080" + - "8080:8080" depends_on: db: condition: service_healthy diff --git a/athena-examples/athena-example-acceptance-tests/mysql-init.sql b/athena-examples/athena-example-acceptance-tests/mysql-init.sql new file mode 100644 index 000000000..43cab2151 --- /dev/null +++ b/athena-examples/athena-example-acceptance-tests/mysql-init.sql @@ -0,0 +1,29 @@ +-- Copyright Jiaqi Liu +-- +-- 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. + +CREATE DATABASE IF NOT EXISTS Athena; +USE Athena; + +CREATE TABLE BOOK_META_DATA ( + id int NOT NULL AUTO_INCREMENT, + file_id VARCHAR(255) NOT NULL, + file_name VARCHAR(255) NOT NULL, + file_type VARCHAR(8) NOT NULL, + PRIMARY KEY (id) +); + +-- Predefined test data +INSERT INTO BOOK_META_DATA (file_id, file_name, file_type) VALUES ('1', 'Harry Potter', 'PDF'); +INSERT INTO BOOK_META_DATA (file_id, file_name, file_type) VALUES ('2', 'Moby Dick', 'PDF'); +INSERT INTO BOOK_META_DATA (file_id, file_name, file_type) VALUES ('3', 'Interview with the vampire', 'PDF'); diff --git a/athena-examples/athena-example-acceptance-tests/src/test/java/io/github/qubitpi/athena/test/acceptance/InitStepDefinitions.java b/athena-examples/athena-example-acceptance-tests/src/test/java/io/github/qubitpi/athena/test/acceptance/InitStepDefinitions.java index f3d926d37..fe596608c 100644 --- a/athena-examples/athena-example-acceptance-tests/src/test/java/io/github/qubitpi/athena/test/acceptance/InitStepDefinitions.java +++ b/athena-examples/athena-example-acceptance-tests/src/test/java/io/github/qubitpi/athena/test/acceptance/InitStepDefinitions.java @@ -39,7 +39,7 @@ public class InitStepDefinitions { @BeforeAll public static void beforeAll() { new DockerComposeContainer(new File("docker-compose.yml")) - .withExposedService("web", WS_PORT, Wait.forHttp("/v1/data/book").forStatusCode(200)) + .withExposedService("web", WS_PORT, Wait.forHttp("/v1/metadata/graphql").forStatusCode(200)) .start(); initRestAssured(); } diff --git a/athena-examples/athena-example-books/docker-compose.yml b/athena-examples/athena-example-books/docker-compose.yml index 43d80e282..d18a018ca 100644 --- a/athena-examples/athena-example-books/docker-compose.yml +++ b/athena-examples/athena-example-books/docker-compose.yml @@ -16,14 +16,14 @@ services: web: build: . ports: - - "80:8080" + - "8080:8080" depends_on: db: condition: service_healthy db: image: "mysql:5.7" ports: - - "3305:3306" + - "3306:3306" volumes: - "./mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql" environment: diff --git a/athena-examples/athena-example-books/pom.xml b/athena-examples/athena-example-books/pom.xml index e60aad602..b9cde49d4 100644 --- a/athena-examples/athena-example-books/pom.xml +++ b/athena-examples/athena-example-books/pom.xml @@ -34,6 +34,7 @@ io.github.qubitpi.athena athena-core test-jar + test io.github.qubitpi.athena @@ -68,6 +69,12 @@ + + + src/main/resources + + + org.apache.maven.plugins diff --git a/athena-examples/athena-example-books/src/main/resources/applicationConfig.properties b/athena-examples/athena-example-books/src/main/resources/applicationConfig.properties index 1aa3a119f..699b3805e 100644 --- a/athena-examples/athena-example-books/src/main/resources/applicationConfig.properties +++ b/athena-examples/athena-example-books/src/main/resources/applicationConfig.properties @@ -1,3 +1,2 @@ -athena__example_config_key="example-value" -athena__data_source_provider=io.github.qubitpi.athena.example.books.application.BooksBinderFactory\ - $MySQLDataSourceProvider +athena__data_source_provider=io.github.qubitpi.athena.example.books.application.BooksBinderFactory$MySQLDataSourceProvider +athena__resource_binder=io.github.qubitpi.athena.example.books.application.BooksBinderFactory diff --git a/pom.xml b/pom.xml index aab62f9f5..66f4ee3bd 100644 --- a/pom.xml +++ b/pom.xml @@ -516,7 +516,7 @@ %regex[.*Spec.*] - **/RunCucumberTest*.java + %regex[.*ITSpec.*]