From e57bf95a39b81e18577c083a1d7b72f0eb7d3737 Mon Sep 17 00:00:00 2001 From: amihaiemil Date: Sat, 20 Apr 2024 09:35:34 +0300 Subject: [PATCH] tests for Spring and Docker Compose YAMLs --- .../amihaiemil/eoyaml/RtYamlInputTest.java | 26 ++++++++- .../typicalSpringApplicationProperties.yml | 39 ------------- .../application.yml} | 1 + .../typical_examples/docker-compose.yml | 56 +++++++++++++++++++ 4 files changed, 81 insertions(+), 41 deletions(-) delete mode 100644 src/test/resources/typicalSpringApplicationProperties.yml rename src/test/resources/{typicalSpringApplicationProperties_printed.yml => typical_examples/application.yml} (89%) create mode 100644 src/test/resources/typical_examples/docker-compose.yml diff --git a/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java b/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java index 1c16dc4e..1bf8fcb5 100644 --- a/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java @@ -2085,7 +2085,7 @@ public void readsFlowSequenceOneLine() throws IOException { public void readsTypicalSpringApplicationProperties() throws IOException { final YamlInput input = Yaml.createYamlInput( new FileReader( - "src/test/resources/typicalSpringApplicationProperties.yml" + "src/test/resources/typical_examples/application.yml" ) ); final YamlMapping read = input.readYamlMapping(); @@ -2093,7 +2093,29 @@ public void readsTypicalSpringApplicationProperties() throws IOException { read.toString(), Matchers.equalTo( this.readTestResource( - "typicalSpringApplicationProperties_printed.yml" + "typical_examples/application.yml" + ) + ) + ); + } + + /** + * We can read a typical docker-compose.yml file. + * @throws IOException If something goes wrong. + */ + @Test + public void readsTypicalDockerComposeFile() throws IOException { + final YamlInput input = Yaml.createYamlInput( + new FileReader( + "src/test/resources/typical_examples/docker-compose.yml" + ) + ); + final YamlMapping read = input.readYamlMapping(); + MatcherAssert.assertThat( + read.toString(), + Matchers.equalTo( + this.readTestResource( + "typical_examples/docker-compose.yml" ) ) ); diff --git a/src/test/resources/typicalSpringApplicationProperties.yml b/src/test/resources/typicalSpringApplicationProperties.yml deleted file mode 100644 index 4714b967..00000000 --- a/src/test/resources/typicalSpringApplicationProperties.yml +++ /dev/null @@ -1,39 +0,0 @@ -logging: - level: - com: - selfxdsd: DEBUG - file: - name: ${self_logging_path}self-web-xdsd.log -spring: - security: - oauth2: - client: - registration: - github: - client-id: ${gh_client_id} - client-secret: ${gh_client_secret} - scope: repo - gitlab: - client-id: ${gl_client_id} - client-secret: ${gl_client_secret} - authorization-grant-type: authorization_code - redirect-uri: ${self_xdsd_base_url}/login/oauth2/code/gitlab - client-authentication-method: 'basic' - array-remains-string: "[config1, config2, config3]" - map-mains-string: "{a:b, c:d, e:f}" - null-string: "null" - other: null - scope: [api, read_user] - mail: - host: mailhog.keycloak.svc.cluster.local - port: 1025 - users: { - admin: mihai, - other: vlad - } - cloud: - kubernetes: - enabled: true - leader: - config-map-name: self-leader-election - diff --git a/src/test/resources/typicalSpringApplicationProperties_printed.yml b/src/test/resources/typical_examples/application.yml similarity index 89% rename from src/test/resources/typicalSpringApplicationProperties_printed.yml rename to src/test/resources/typical_examples/application.yml index aaba0748..5cc352bf 100644 --- a/src/test/resources/typicalSpringApplicationProperties_printed.yml +++ b/src/test/resources/typical_examples/application.yml @@ -1,3 +1,4 @@ +# This is a typical application.yml file from Spring Framework. logging: level: com: diff --git a/src/test/resources/typical_examples/docker-compose.yml b/src/test/resources/typical_examples/docker-compose.yml new file mode 100644 index 00000000..e440c731 --- /dev/null +++ b/src/test/resources/typical_examples/docker-compose.yml @@ -0,0 +1,56 @@ +version: 3.8 +name: docker-compose-dependencies +services: + mongo: + image: "mongo:5.0.0" + ports: + - "27017:27017" + command: "--bind_ip_all --replSet rs0" + healthcheck: + test: | + test $$(mongosh --quiet --eval "try { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'mongo' }] }).ok } catch (_) { rs.status().ok }") -eq 1 + interval: 10s + start_period: 5s + kafka: + image: "redpandadata/redpanda:v23.2.12" + ports: + - "9092:9092" + spicedb: + image: "authzed/spicedb:v1.25.0" + ports: + - "50051:50051" + environment: + SPICEDB_DATASTORE_ENGINE: memory + command: + - serve-testing + - "--load-configs" + - /spicedb.yml + volumes: + - "./spicedb.yml:/spicedb.yml" + keycloak: + image: "quay.io/keycloak/keycloak:latest" + ports: + - "8080:8080" + environment: + KEYCLOAK_ADMIN: admin + KEYCLOAK_ADMIN_PASSWORD: admin + command: + - start-dev + - "--import-realm" + volumes: + - "./keycloak/test-realm.json:/opt/keycloak/data/import/realm.json" + jsreport: + image: "jsreport/jsreport:4.2.0" + ports: + - "5488:5488" + volumes: + - "../../root/jsreportapp/data:/app/data" + # SMTP Server for e-mailing. + devSmtp: + image: "jcalonso/mailhog:v1.0.1" + ports: + - "8025:8025" + - "1025:1025" + expose: + - 1025 + - 8025 \ No newline at end of file