├── spring-test-core ├── src │ ├── test │ │ ├── resources │ │ │ └── dataset │ │ │ │ └── internal │ │ │ │ └── test_file.txt │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── core │ │ │ ├── annotation │ │ │ ├── SpringBootApp.java │ │ │ └── EnableIntegrationTestTest.java │ │ │ └── expected │ │ │ └── list │ │ │ └── messages │ │ │ └── MessagesDataSetTest.java │ └── main │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── core │ │ ├── expected │ │ └── list │ │ │ └── messages │ │ │ ├── DataSetPreProcessor.java │ │ │ ├── MessageBroker.java │ │ │ ├── Fail.java │ │ │ ├── ExpectedMessagesOptions.java │ │ │ ├── MessagesDataSet.java │ │ │ └── AssertReceivedMessages.java │ │ └── annotation │ │ └── EnableIntegrationTest.java └── pom.xml ├── spring-test-activemq ├── src │ ├── test │ │ ├── resources │ │ │ ├── datasets │ │ │ │ ├── expected_empty_file.json │ │ │ │ ├── expected_empty_list.json │ │ │ │ ├── expected_messages_with_date.json │ │ │ │ ├── expected_messages_with_js.json │ │ │ │ ├── expected_messages.json │ │ │ │ ├── expected_partial.json │ │ │ │ └── expected_messages_multiple_types.json │ │ │ └── logback-test.xml │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── activemq │ │ │ └── extension │ │ │ ├── SpringApp.java │ │ │ ├── expected │ │ │ ├── Bar.java │ │ │ ├── FooWithBar.java │ │ │ ├── Foo.java │ │ │ └── list │ │ │ │ └── messages │ │ │ │ ├── ExpectedListOfMessagesTest.java │ │ │ │ └── ActiveMqExpectedListOfMessagesExtensionTest.java │ │ │ ├── ActiveMqTcExtensionTest.java │ │ │ ├── EnableActiveMqWithListOfMessagesTest.java │ │ │ ├── EnableActiveMqTestContainersTest.java │ │ │ └── ActiveMqSmartDataSetTest.java │ └── main │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── activemq │ │ ├── annotation │ │ ├── ExpectedMessage.java │ │ ├── EnableActiveMqTestContainers.java │ │ ├── meta │ │ │ └── EnableActiveMqTest.java │ │ └── ExpectedMessages.java │ │ └── extension │ │ ├── expected │ │ └── list │ │ │ └── messages │ │ │ ├── ActiveMqMessageBroker.java │ │ │ ├── ExpectedMessagesMapper.java │ │ │ └── ActiveMqExpectedListOfMessagesExtension.java │ │ ├── ActiveMqTcExtension.java │ │ └── ActiveMqMessageExtension.java └── pom.xml ├── images ├── jms.png ├── embedded-web.png ├── jpa-containers.png ├── pg-annotations.png ├── mysql-annotations.png ├── activemq-annotations.png └── rabbitmq-annotations.png ├── spring-test-mysql ├── src │ ├── test │ │ ├── resources │ │ │ ├── datasets │ │ │ │ └── expected.json │ │ │ └── logback-test.xml │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── mysql │ │ │ ├── annotation │ │ │ ├── meta │ │ │ │ ├── EnableMySqlIntegrationTestTest.java │ │ │ │ └── EnableMySqlDataTestTest.java │ │ │ └── EnableMySqlTestContainersTest.java │ │ │ ├── extension │ │ │ ├── MySqlTcExtensionIntegrationTest.java │ │ │ └── MySqlTcExtensionTest.java │ │ │ └── TransactionalTestConfig.java │ └── main │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── mysql │ │ ├── annotation │ │ ├── meta │ │ │ ├── EnableMySqlDataTest.java │ │ │ └── EnableMySqlIntegrationTest.java │ │ └── EnableMySqlTestContainers.java │ │ └── extension │ │ └── MySqlTcExtension.java └── pom.xml ├── spring-test-postgres ├── src │ ├── test │ │ ├── resources │ │ │ ├── stored_functions │ │ │ │ └── test_func.sql │ │ │ ├── datasets │ │ │ │ └── expected.json │ │ │ └── logback-test.xml │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── postgres │ │ │ ├── annotation │ │ │ ├── meta │ │ │ │ ├── EnablePostgresIntegrationTestTest.java │ │ │ │ └── EnablePostgresDataTestTest.java │ │ │ └── EnablePostgresTestContainersTest.java │ │ │ ├── extension │ │ │ ├── PostgresTcExtensionTest.java │ │ │ └── PostgresTcExtensionIntegrationTest.java │ │ │ └── TransactionalTestConfig.java │ └── main │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── postgres │ │ ├── annotation │ │ ├── meta │ │ │ ├── EnablePostgresDataTest.java │ │ │ └── EnablePostgresIntegrationTest.java │ │ └── EnablePostgresTestContainers.java │ │ └── extension │ │ └── PostgresTcExtension.java ├── .gitignore └── pom.xml ├── spring-test-rabbitmq ├── src │ ├── test │ │ ├── resources │ │ │ ├── datasets │ │ │ │ ├── expected_messages_with_date.json │ │ │ │ ├── expected_messages_with_js.json │ │ │ │ ├── expected_messages.json │ │ │ │ ├── expected_partial.json │ │ │ │ ├── expected_messages_multiple_types.json │ │ │ │ └── expected_messages_with_nested_objects.json │ │ │ └── logback-test.xml │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── rabbitmq │ │ │ └── extension │ │ │ ├── pojo │ │ │ ├── Foo.java │ │ │ ├── Bar.java │ │ │ └── FooWithBar.java │ │ │ ├── ApplicationIT.java │ │ │ ├── ExpectedMessageTest.java │ │ │ ├── EnableRabbitMqTestTest.java │ │ │ ├── RabbitMqTcExtensionTest.java │ │ │ └── ExpectedMessagesExtensionTest.java │ └── main │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── rabbitmq │ │ ├── annotation │ │ ├── ExpectedMessage.java │ │ ├── EnableRabbitMqTestContainers.java │ │ ├── ExpectedMessages.java │ │ └── meta │ │ │ └── EnableRabbitMqTest.java │ │ └── extension │ │ ├── RabbitMqTcExtension.java │ │ ├── expected │ │ └── list │ │ │ └── messages │ │ │ ├── RabbitMqMessageBroker.java │ │ │ ├── ExpectedMessagesMapper.java │ │ │ └── RabbitMqExpectedListOfMessagesExtension.java │ │ └── RabbitMqMessageExtension.java └── pom.xml ├── spring-test-jpa ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── jpa │ │ │ ├── tracesql │ │ │ ├── QueryHandler.java │ │ │ ├── QueryType.java │ │ │ ├── exceptions │ │ │ │ ├── UndefinedSqlQueryTypeException.java │ │ │ │ └── SqlQueryCountException.java │ │ │ ├── QueryCountInfoHolder.java │ │ │ ├── StatementInspectorImpl.java │ │ │ ├── QueryCountInfo.java │ │ │ ├── AssertSqlQueryCount.java │ │ │ └── QueryCountInfoHandler.java │ │ │ ├── annotation │ │ │ ├── ExpectedSqlQueries.java │ │ │ ├── ExpectedSqlQuery.java │ │ │ ├── EnableRiderTest.java │ │ │ └── EnableDataTest.java │ │ │ └── extension │ │ │ ├── TraceSqlExtension.java │ │ │ └── ExpectedSqlQueryExtension.java │ └── test │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── jpa │ │ ├── extension │ │ ├── EnableIntegrationTestTest.java │ │ ├── EnableDataTestTest.java │ │ ├── TransactionalTestConfig.java │ │ ├── ExpectedSqlExtensionTest.java │ │ └── TraceSqlExtensionTest.java │ │ └── tracesql │ │ ├── QueryCountInfoHandlerTest.java │ │ └── QueryCountInfoTest.java └── pom.xml ├── spring-test-web ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── jupiter │ │ │ └── tools │ │ │ └── spring │ │ │ └── test │ │ │ └── web │ │ │ └── extension │ │ │ ├── SpringBootApp.java │ │ │ ├── EnableRestTestTest.java │ │ │ ├── RandomPortBindingExtensionTest.java │ │ │ ├── RandomPortBindingExtensionSecondTest.java │ │ │ └── ribbon │ │ │ ├── RedirectRibbonExtensionByFeignTest.java │ │ │ ├── RedirectRibbonToEmbeddedWebServerTest.java │ │ │ └── RedirectRibbonExtensionTest.java │ └── main │ │ └── java │ │ └── com │ │ └── jupiter │ │ └── tools │ │ └── spring │ │ └── test │ │ └── web │ │ ├── extension │ │ ├── ribbon │ │ │ ├── RedirectRibbonToEmbeddedWebServer.java │ │ │ ├── RedirectRibbonExtensionConfig.java │ │ │ ├── RedirectRibbonExtension.java │ │ │ └── RedirectRibbonServerList.java │ │ └── RandomPortBindingExtension.java │ │ └── annotation │ │ ├── EnableEmbeddedWebServerTest.java │ │ └── EnableRestTest.java └── pom.xml ├── .gitignore ├── .travis.yml └── pom.xml /spring-test-core/src/test/resources/dataset/internal/test_file.txt: -------------------------------------------------------------------------------- 1 | secret-123 -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_empty_file.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /images/jms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/jms.png -------------------------------------------------------------------------------- /images/embedded-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/embedded-web.png -------------------------------------------------------------------------------- /images/jpa-containers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/jpa-containers.png -------------------------------------------------------------------------------- /images/pg-annotations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/pg-annotations.png -------------------------------------------------------------------------------- /images/mysql-annotations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/mysql-annotations.png -------------------------------------------------------------------------------- /images/activemq-annotations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/activemq-annotations.png -------------------------------------------------------------------------------- /images/rabbitmq-annotations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiter-tools/spring-boot-extensions/HEAD/images/rabbitmq-annotations.png -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_empty_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.activemq.extension.expected.Foo": [ ] 3 | } -------------------------------------------------------------------------------- /spring-test-mysql/src/test/resources/datasets/expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [ 3 | { 4 | "id": 1, 5 | "field": "tru la la.." 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /spring-test-postgres/src/test/resources/stored_functions/test_func.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION rnd() 2 | RETURNS INTEGER AS 3 | 'BEGIN RETURN 123;END' 4 | LANGUAGE plpgsql; -------------------------------------------------------------------------------- /spring-test-postgres/src/test/resources/datasets/expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "transactional_test_config$foo": [ 3 | { 4 | "id": 1, 5 | "field": "tru la la.." 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_messages_with_date.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar": [ 3 | { 4 | "time": "date-match:[NOW]" 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/datasets/expected_messages_with_date.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.FooWithBar": [ 3 | { 4 | "time": "date-match:[NOW]" 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/datasets/expected_messages_with_js.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Foo": [ 3 | { 4 | "value":"js-match: value == 1+2+3+4+5" 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_messages_with_js.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.activemq.extension.expected.Foo": [ 3 | { 4 | "value":"js-match: value == 1+2+3+4+5" 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/datasets/expected_messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Foo": [ 3 | { 4 | "value":"123" 5 | }, 6 | { 7 | "value":"456" 8 | }, 9 | { 10 | "value":"789" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.activemq.extension.expected.Foo": [ 3 | { 4 | "value":"123" 5 | }, 6 | { 7 | "value":"456" 8 | }, 9 | { 10 | "value":"789" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryHandler.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | /** 4 | * @author Igor Dmitriev 5 | * @author Mikalai Alimenkou 6 | * @author Korovin Anatoliy 7 | */ 8 | public interface QueryHandler { 9 | void handleSql(String sql); 10 | } 11 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryType.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | /** 4 | * Created on 12/6/15 5 | * 6 | * @author Igor Dmitriev 7 | * @author Mikalai Alimenkou 8 | * @author Korovin Anatoliy 9 | */ 10 | public enum QueryType { 11 | SELECT, INSERT, UPDATE, DELETE, OTHER, CALL 12 | } 13 | -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/SpringBootApp.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | /** 6 | * Created on 29.01.2019. 7 | * 8 | * @author Korovin Anatoliy 9 | */ 10 | @SpringBootApplication 11 | public class SpringBootApp { 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/SpringApp.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | /** 6 | * Created on 28.01.2019. 7 | * 8 | * @author Korovin Anatoliy 9 | */ 10 | @SpringBootApplication 11 | public class SpringApp { 12 | } 13 | -------------------------------------------------------------------------------- /spring-test-core/src/test/java/com/jupiter/tools/spring/test/core/annotation/SpringBootApp.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.annotation; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | /** 6 | * Created on 29.01.2019. 7 | * 8 | * @author Korovin Anatoliy 9 | */ 10 | @SpringBootApplication 11 | public class SpringBootApp { 12 | } 13 | -------------------------------------------------------------------------------- /spring-test-postgres/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/datasets/expected_partial.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.FooWithBar": [ 3 | { 4 | "foo": { 5 | "value": "parent foo" 6 | }, 7 | "bar": { 8 | "name": "parent bar" 9 | }, 10 | "child": { 11 | "foo": { 12 | "value": "child foo" 13 | } 14 | } 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_partial.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar": [ 3 | { 4 | "foo": { 5 | "value": "parent foo" 6 | }, 7 | "bar": { 8 | "name": "parent bar" 9 | }, 10 | "child": { 11 | "foo": { 12 | "value": "child foo" 13 | } 14 | } 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/exceptions/UndefinedSqlQueryTypeException.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql.exceptions; 2 | 3 | /** 4 | * Created on 15.04.2019. 5 | * @author Korovin Anatoliy 6 | */ 7 | public class UndefinedSqlQueryTypeException extends RuntimeException { 8 | 9 | public UndefinedSqlQueryTypeException(String message) { 10 | super(message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/datasets/expected_messages_multiple_types.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Foo": [ 3 | { 4 | "value":"123" 5 | } 6 | ], 7 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Bar":[ 8 | { 9 | "name":"AAA", 10 | "count":1 11 | }, 12 | { 13 | "name":"BBB", 14 | "count":2 15 | }, 16 | { 17 | "name":"CCC", 18 | "count":3 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/datasets/expected_messages_multiple_types.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.activemq.extension.expected.Foo": [ 3 | { 4 | "value":"123" 5 | } 6 | ], 7 | "com.jupiter.tools.spring.test.activemq.extension.expected.Bar":[ 8 | { 9 | "name":"AAA", 10 | "count":1 11 | }, 12 | { 13 | "name":"BBB", 14 | "count":2 15 | }, 16 | { 17 | "name":"CCC", 18 | "count":3 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | 5 | script: 6 | - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.issue.ignore.multicriteria="e1" -Dsonar.issue.ignore.multicriteria.e1.ruleKey="squid:S00119" -Dsonar.issue.ignore.multicriteria.e1.resourceKey="**/*.java" 7 | 8 | addons: 9 | sonarcloud: 10 | organization: "antkorwin-github" 11 | token: $SONAR_CLOUD_KEY 12 | 13 | after_success: 14 | - mvn cobertura:cobertura 15 | - bash <(curl -s https://codecov.io/bash) 16 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryCountInfoHolder.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | /** 4 | * @author Igor Dmitriev 5 | * @author Mikalai Alimenkou 6 | * @author Korovin Anatoliy 7 | */ 8 | public class QueryCountInfoHolder { 9 | 10 | private static final ThreadLocal QUERY_INFO_HOLDER = 11 | ThreadLocal.withInitial(() -> new QueryCountInfo()); 12 | 13 | public static QueryCountInfo getQueryInfo() { 14 | return QUERY_INFO_HOLDER.get(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/datasets/expected_messages_with_nested_objects.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.jupiter.tools.spring.test.rabbitmq.extension.pojo.FooWithBar": [ 3 | { 4 | "foo": { 5 | "value": "parent foo" 6 | }, 7 | "bar": { 8 | "name": "parent bar", 9 | "count": 2 10 | }, 11 | "child": { 12 | "foo": { 13 | "value": "child foo" 14 | }, 15 | "bar": { 16 | "name": "child bar", 17 | "count": 1 18 | }, 19 | "child": null 20 | } 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/expected/Bar.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | /** 10 | * Created on 08.02.2019. 11 | * 12 | * @author Korovin Anatoliy 13 | */ 14 | @Getter 15 | @Setter 16 | @Builder 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class Bar { 20 | private String name; 21 | private int count; 22 | } 23 | -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/expected/list/messages/DataSetPreProcessor.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | 4 | import com.jupitertools.datasetroll.DataSet; 5 | 6 | /** 7 | * Pre-processing the DataSet from one state to another 8 | * 9 | * @author Korovin Anatoliy 10 | */ 11 | public interface DataSetPreProcessor { 12 | 13 | /** 14 | * transform the source dataset 15 | * 16 | * @param source input dataset 17 | * @return transformed version of the dataset 18 | */ 19 | DataSet run(DataSet source); 20 | } 21 | -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/expected/list/messages/MessageBroker.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | /** 4 | * Created on 27.03.2019. 5 | * 6 | * This interface used by {@link AssertReceivedMessages} to retrieve message from brokers. 7 | * 8 | * You need to wrap your JmsTemplate, AmqpTemplate, 9 | * or something else to use with the {@link AssertReceivedMessages}. 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | public interface MessageBroker { 14 | 15 | Object receive(String queueName, long timeout); 16 | } 17 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/pojo/Foo.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension.pojo; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | 11 | /** 12 | * Created on 07.02.2019 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | @Getter 17 | @Setter 18 | @Builder 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class Foo implements Serializable { 22 | 23 | private String value; 24 | } 25 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/pojo/Bar.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension.pojo; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | 11 | /** 12 | * Created on 08.02.2019. 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | @Getter 17 | @Setter 18 | @Builder 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class Bar implements Serializable { 22 | private String name; 23 | private int count; 24 | } 25 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/pojo/FooWithBar.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension.pojo; 2 | 3 | 4 | import java.util.Date; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Getter; 9 | import lombok.NoArgsConstructor; 10 | import lombok.Setter; 11 | 12 | 13 | /** 14 | * Created on 07.02.2019 15 | * 16 | * @author Korovin Anatoliy 17 | */ 18 | @Getter 19 | @Setter 20 | @Builder 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class FooWithBar { 24 | Foo foo; 25 | Bar bar; 26 | FooWithBar child; 27 | Date time; 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/annotation/ExpectedMessage.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created on 22.01.2019. 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.METHOD) 15 | public @interface ExpectedMessage { 16 | 17 | String message(); 18 | 19 | String queue(); 20 | 21 | int timeout() default 3000; 22 | } 23 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/annotation/ExpectedMessage.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created on 22.01.2019. 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.METHOD) 15 | public @interface ExpectedMessage { 16 | 17 | String message(); 18 | 19 | String queue(); 20 | 21 | int timeout() default 3000; 22 | } 23 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/expected/FooWithBar.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected; 2 | 3 | 4 | import java.util.Date; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Getter; 9 | import lombok.NoArgsConstructor; 10 | import lombok.Setter; 11 | 12 | 13 | /** 14 | * Created on 07.02.2019 15 | * 16 | * @author Korovin Anatoliy 17 | */ 18 | @Getter 19 | @Setter 20 | @Builder 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class FooWithBar { 24 | Foo foo; 25 | Bar bar; 26 | FooWithBar child; 27 | Date time; 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit.jupiter.SpringExtension; 10 | 11 | @ExtendWith(SpringExtension.class) 12 | @SpringBootTest 13 | @SpringBootApplication 14 | class ApplicationIT { 15 | 16 | @Test 17 | void contextLoads() { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/expected/Foo.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created on 07.02.2019. 7 | * 8 | * @author Korovin Anatoliy 9 | */ 10 | public class Foo implements Serializable { 11 | 12 | private String value; 13 | 14 | public Foo() { 15 | } 16 | 17 | public Foo(String value) { 18 | this.value = value; 19 | } 20 | 21 | public String getValue() { 22 | return value; 23 | } 24 | 25 | public Foo setValue(String value) { 26 | this.value = value; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/exceptions/SqlQueryCountException.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql.exceptions; 2 | 3 | import com.jupiter.tools.spring.test.jpa.tracesql.QueryType; 4 | 5 | /** 6 | * Created on 15.04.2019. 7 | * @author Korovin Anatoliy 8 | */ 9 | public class SqlQueryCountException extends RuntimeException { 10 | 11 | public SqlQueryCountException(QueryType queryType, int expectedCount, int actualCount) { 12 | super(String.format("Expected query: %s, count: %d, but actual count: %d", 13 | queryType, 14 | expectedCount, 15 | actualCount)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-test-mysql/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/StatementInspectorImpl.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | import org.hibernate.resource.jdbc.spi.StatementInspector; 4 | 5 | /** 6 | * Created by Korovin Anatolii on 14.11.17. 7 | * 8 | * We using statement inspector for handling and counting sql query 9 | * 10 | * @author Igor Dmitriev 11 | * @author Mikalai Alimenkou 12 | * @author Korovin Anatolii 13 | */ 14 | public class StatementInspectorImpl implements StatementInspector { 15 | 16 | private static final QueryHandler QUERY_HANDLER = new QueryCountInfoHandler(); 17 | 18 | @Override 19 | public String inspect(String sql) { 20 | QUERY_HANDLER.handleSql(sql); 21 | return sql; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-test-postgres/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/annotation/EnableIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.annotation; 2 | 3 | import org.junit.jupiter.api.extension.ExtendWith; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.junit.jupiter.SpringExtension; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Created on 17.07.2018. 14 | * 15 | * Start all application context configuration for a test 16 | * 17 | * @author Korovin Anatoliy 18 | */ 19 | @Retention(RetentionPolicy.RUNTIME) 20 | @Target(ElementType.TYPE) 21 | @SpringBootTest 22 | @ExtendWith(SpringExtension.class) 23 | public @interface EnableIntegrationTest { 24 | } 25 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/annotation/ExpectedSqlQueries.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import com.jupiter.tools.spring.test.jpa.extension.ExpectedSqlQueryExtension; 8 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 12 | 13 | /** 14 | * Created on 15.04.2019. 15 | * @author Korovin Anatoliy 16 | */ 17 | @Retention(RUNTIME) 18 | @Target(ElementType.METHOD) 19 | @ExtendWith(TraceSqlExtension.class) 20 | @ExtendWith(ExpectedSqlQueryExtension.class) 21 | public @interface ExpectedSqlQueries { 22 | 23 | ExpectedSqlQuery[] value(); 24 | } 25 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/annotation/EnableActiveMqTestContainers.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.annotation; 2 | 3 | import com.jupiter.tools.spring.test.activemq.extension.ActiveMqTcExtension; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.test.context.ActiveProfiles; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Created on 28.01.2019. 14 | * 15 | * @author Korovin Anatoliy 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target(ElementType.TYPE) 19 | @ExtendWith(ActiveMqTcExtension.class) 20 | @ActiveProfiles("jupiter-tools.spring-test-activemq.test-containers") 21 | public @interface EnableActiveMqTestContainers { 22 | } 23 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/annotation/EnableRabbitMqTestContainers.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.jupiter.tools.spring.test.rabbitmq.extension.RabbitMqTcExtension; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.springframework.test.context.ActiveProfiles; 11 | 12 | /** 13 | * Created on 28.01.2019. 14 | * 15 | * @author Korovin Anatoliy 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target(ElementType.TYPE) 19 | @ExtendWith(RabbitMqTcExtension.class) 20 | @ActiveProfiles("jupiter-tools.spring-test-rabbitmq.test-containers") 21 | public @interface EnableRabbitMqTestContainers { 22 | } 23 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/extension/RabbitMqTcExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | import org.junit.jupiter.api.extension.Extension; 4 | import org.testcontainers.containers.GenericContainer; 5 | 6 | /** 7 | * Created on 07.08.2018. 8 | * 9 | * @author Korovin Anatoliy 10 | */ 11 | public class RabbitMqTcExtension implements Extension { 12 | 13 | private static final Integer RABBIT_PORT = 5672; 14 | private static GenericContainer rabbitmq = 15 | new GenericContainer("rabbitmq:management").withExposedPorts(RABBIT_PORT, 15672); 16 | 17 | static { 18 | rabbitmq.start(); 19 | System.setProperty("spring.rabbitmq.host", rabbitmq.getContainerIpAddress()); 20 | System.setProperty("spring.rabbitmq.port", rabbitmq.getMappedPort(RABBIT_PORT).toString()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-test-mysql/src/main/java/com/jupiter/tools/spring/test/mysql/annotation/meta/EnableMySqlDataTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.annotation.meta; 2 | 3 | import com.jupiter.tools.spring.test.jpa.annotation.EnableDataTest; 4 | import com.jupiter.tools.spring.test.jpa.annotation.EnableRiderTest; 5 | import com.jupiter.tools.spring.test.mysql.annotation.EnableMySqlTestContainers; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Created on 19.07.2018. 14 | * 15 | * Meta-annotation for the combination of: 16 | * DataTests, RiderTests and MySQL docker-container 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target(ElementType.TYPE) 22 | @EnableDataTest 23 | @EnableRiderTest 24 | @EnableMySqlTestContainers 25 | public @interface EnableMySqlDataTest { 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonToEmbeddedWebServer.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import org.junit.jupiter.api.extension.ExtendWith; 4 | import org.springframework.cloud.netflix.ribbon.RibbonClients; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | /** 12 | * Created on 05.02.2019. 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @ExtendWith(RedirectRibbonExtension.class) 19 | @RibbonClients(defaultConfiguration = RedirectRibbonExtensionConfig.class) 20 | public @interface RedirectRibbonToEmbeddedWebServer { 21 | 22 | /** 23 | * @return List of client names which should be redirected to the embedded web server 24 | */ 25 | String[] value() default {}; 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-postgres/src/main/java/com/jupiter/tools/spring/test/postgres/annotation/meta/EnablePostgresDataTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.annotation.meta; 2 | 3 | import com.jupiter.tools.spring.test.jpa.annotation.EnableDataTest; 4 | import com.jupiter.tools.spring.test.jpa.annotation.EnableRiderTest; 5 | import com.jupiter.tools.spring.test.postgres.annotation.EnablePostgresTestContainers; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Created on 19.07.2018. 14 | * 15 | * Meta-annotation for the combination of: DataTests, RiderTests 16 | * and PostgreSQL docker container. 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target(ElementType.TYPE) 22 | @EnableDataTest 23 | @EnableRiderTest 24 | @EnablePostgresTestContainers 25 | public @interface EnablePostgresDataTest { 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-mysql/src/main/java/com/jupiter/tools/spring/test/mysql/annotation/meta/EnableMySqlIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.annotation.meta; 2 | 3 | import com.jupiter.tools.spring.test.core.annotation.EnableIntegrationTest; 4 | import com.jupiter.tools.spring.test.jpa.annotation.EnableRiderTest; 5 | import com.jupiter.tools.spring.test.mysql.annotation.EnableMySqlTestContainers; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Created on 19.07.2018. 14 | * 15 | * Meta-annotation for the combination of: 16 | * IntegrationTests, RiderTests and MySQL docker-container 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target(ElementType.TYPE) 22 | @EnableIntegrationTest 23 | @EnableRiderTest 24 | @EnableMySqlTestContainers 25 | public @interface EnableMySqlIntegrationTest { 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-core/src/test/java/com/jupiter/tools/spring/test/core/annotation/EnableIntegrationTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.annotation; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.TestConfiguration; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | /** 11 | * Created on 29.01.2019. 12 | * 13 | * @author Korovin Anatoliy 14 | */ 15 | @EnableIntegrationTest 16 | class EnableIntegrationTestTest { 17 | 18 | @Autowired 19 | private String testBean; 20 | 21 | @Test 22 | void testDi() { 23 | assertThat(testBean).isNotNull() 24 | .isEqualTo("test"); 25 | } 26 | 27 | @TestConfiguration 28 | public static class TestConfig { 29 | 30 | @Bean 31 | public String testBean() { 32 | return "test"; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/extension/RandomPortBindingExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension; 2 | 3 | import org.junit.jupiter.api.extension.BeforeAllCallback; 4 | import org.junit.jupiter.api.extension.Extension; 5 | import org.junit.jupiter.api.extension.ExtensionContext; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import org.springframework.util.SocketUtils; 9 | 10 | /** 11 | * Created on 29.08.2018. 12 | * 13 | * Bind a random available TCP port to the server.port property 14 | * 15 | * @author Korovin Anatoliy 16 | */ 17 | public class RandomPortBindingExtension implements Extension, BeforeAllCallback { 18 | 19 | @Override 20 | public void beforeAll(ExtensionContext context) throws Exception { 21 | int port = SocketUtils.findAvailableTcpPort(); 22 | LoggerFactory.getLogger(RandomPortBindingExtension.class).info("\n binding -> server.port = "+port+"\n"); 23 | System.setProperty("server.port", String.valueOf(port)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-test-postgres/src/main/java/com/jupiter/tools/spring/test/postgres/annotation/meta/EnablePostgresIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.annotation.meta; 2 | 3 | 4 | import com.jupiter.tools.spring.test.core.annotation.EnableIntegrationTest; 5 | import com.jupiter.tools.spring.test.jpa.annotation.EnableRiderTest; 6 | import com.jupiter.tools.spring.test.postgres.annotation.EnablePostgresTestContainers; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * Created on 19.07.2018. 15 | * 16 | * Meta-annotation for the combination of: IntegrationTests, RiderTests 17 | * and PostgreSQL docker container. 18 | * 19 | * @author Korovin Anatoliy 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | @Target(ElementType.TYPE) 23 | @EnableIntegrationTest 24 | @EnableRiderTest 25 | @EnablePostgresTestContainers 26 | public @interface EnablePostgresIntegrationTest { 27 | } 28 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/extension/expected/list/messages/RabbitMqMessageBroker.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.core.expected.list.messages.AssertReceivedMessages; 4 | import com.jupiter.tools.spring.test.core.expected.list.messages.MessageBroker; 5 | 6 | import org.springframework.amqp.core.AmqpTemplate; 7 | 8 | /** 9 | * Created on 27.03.2019. 10 | * 11 | * Wrapped the AmqpTemplate, to use in 12 | * the {@link AssertReceivedMessages} 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | public class RabbitMqMessageBroker implements MessageBroker { 17 | 18 | private final AmqpTemplate amqpTemplate; 19 | 20 | public RabbitMqMessageBroker(AmqpTemplate amqpTemplate) { 21 | this.amqpTemplate = amqpTemplate; 22 | } 23 | 24 | @Override 25 | public Object receive(String queueName, long timeout) { 26 | return amqpTemplate.receiveAndConvert(queueName, timeout); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-mysql/src/test/java/com/jupiter/tools/spring/test/mysql/annotation/meta/EnableMySqlIntegrationTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.annotation.meta; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 5 | import com.jupiter.tools.spring.test.mysql.TransactionalTestConfig; 6 | import org.junit.jupiter.api.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Import; 9 | 10 | /** 11 | * Created on 26.01.2019. 12 | * 13 | * @author Korovin Anatoliy 14 | */ 15 | @EnableMySqlIntegrationTest 16 | @Import(TransactionalTestConfig.class) 17 | class EnableMySqlIntegrationTestTest { 18 | 19 | @Autowired 20 | private TransactionalTestConfig.TestService testService; 21 | 22 | @Test 23 | @DataSet(cleanBefore = true, cleanAfter = true) 24 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 25 | void testCreate() { 26 | testService.ok(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/extension/expected/list/messages/ActiveMqMessageBroker.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.core.expected.list.messages.AssertReceivedMessages; 4 | import com.jupiter.tools.spring.test.core.expected.list.messages.MessageBroker; 5 | 6 | import org.springframework.jms.core.JmsTemplate; 7 | 8 | /** 9 | * Created on 27.03.2019. 10 | * 11 | * Wrapped the JmsTemplate, to use in 12 | * the {@link AssertReceivedMessages} 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | public class ActiveMqMessageBroker implements MessageBroker { 17 | 18 | private final JmsTemplate jmsTemplate; 19 | 20 | public ActiveMqMessageBroker(JmsTemplate jmsTemplate) { 21 | this.jmsTemplate = jmsTemplate; 22 | } 23 | 24 | @Override 25 | public Object receive(String queueName, long timeout) { 26 | jmsTemplate.setReceiveTimeout(timeout); 27 | return jmsTemplate.receiveAndConvert(queueName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-test-postgres/src/test/java/com/jupiter/tools/spring/test/postgres/annotation/meta/EnablePostgresIntegrationTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.annotation.meta; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 5 | import com.jupiter.tools.spring.test.postgres.TransactionalTestConfig; 6 | import org.junit.jupiter.api.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Import; 9 | 10 | /** 11 | * Created on 23.01.2019. 12 | * 13 | * @author Korovin Anatoliy 14 | */ 15 | @EnablePostgresIntegrationTest 16 | @Import(TransactionalTestConfig.class) 17 | class EnablePostgresIntegrationTestTest { 18 | 19 | @Autowired 20 | private TransactionalTestConfig.TestService testService; 21 | 22 | @Test 23 | @DataSet(cleanBefore = true, cleanAfter = true) 24 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 25 | void testCreate() { 26 | testService.ok(); 27 | } 28 | } -------------------------------------------------------------------------------- /spring-test-postgres/src/main/java/com/jupiter/tools/spring/test/postgres/annotation/EnablePostgresTestContainers.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.annotation; 2 | 3 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 4 | import com.jupiter.tools.spring.test.postgres.extension.PostgresTcExtension; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.springframework.test.context.ActiveProfiles; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * Created on 17.07.2018. 15 | *

16 | * Start a PostgreSQL container in Docker, by a test-containers library. 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target(ElementType.TYPE) 22 | @ExtendWith(PostgresTcExtension.class) 23 | @ExtendWith(TraceSqlExtension.class) 24 | @ActiveProfiles("jupiter-tools.spring-test-postgres.test-containers") 25 | public @interface EnablePostgresTestContainers { 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/annotation/ExpectedSqlQuery.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Repeatable; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.jupiter.tools.spring.test.jpa.extension.ExpectedSqlQueryExtension; 10 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 11 | import com.jupiter.tools.spring.test.jpa.tracesql.QueryType; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | 14 | /** 15 | * Created on 15.04.2019. 16 | * 17 | * Assert count of executed queries after the test execution 18 | * 19 | * @author Korovin Anatoliy 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | @Target(ElementType.METHOD) 23 | @ExtendWith(TraceSqlExtension.class) 24 | @ExtendWith(ExpectedSqlQueryExtension.class) 25 | @Repeatable(ExpectedSqlQueries.class) 26 | public @interface ExpectedSqlQuery { 27 | 28 | QueryType type(); 29 | 30 | int count(); 31 | } 32 | -------------------------------------------------------------------------------- /spring-test-mysql/src/main/java/com/jupiter/tools/spring/test/mysql/annotation/EnableMySqlTestContainers.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.annotation; 2 | 3 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 4 | import com.jupiter.tools.spring.test.mysql.extension.MySqlTcExtension; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.springframework.test.context.ActiveProfiles; 7 | import org.springframework.test.context.ContextConfiguration; 8 | 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.RetentionPolicy; 12 | import java.lang.annotation.Target; 13 | 14 | /** 15 | * Created on 18.07.2018. 16 | *

17 | * Start a MySQL container in Docker, by the test-containers library. 18 | * 19 | * @author Korovin Anatoliy 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | @Target(ElementType.TYPE) 23 | @ExtendWith(MySqlTcExtension.class) 24 | @ExtendWith(TraceSqlExtension.class) 25 | @ActiveProfiles("jupiter-tools.spring-test-mysql.test-containers") 26 | public @interface EnableMySqlTestContainers { 27 | } 28 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonExtensionConfig.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import com.netflix.client.config.IClientConfig; 4 | import com.netflix.loadbalancer.Server; 5 | import com.netflix.loadbalancer.ServerList; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | /** 12 | * Created on 06.02.2019. 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | public class RedirectRibbonExtensionConfig { 17 | 18 | private static List clientNames; 19 | 20 | /** 21 | * set list of client which will be redirect to local embedded server 22 | * 23 | * @param clients list of ribbon client names 24 | */ 25 | public static void setClients(String... clients) { 26 | clientNames = Arrays.asList(clients); 27 | } 28 | 29 | @Bean 30 | public ServerList customServerList(IClientConfig ribbonClientConfig) { 31 | return new RedirectRibbonServerList(ribbonClientConfig, clientNames); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/annotation/EnableEmbeddedWebServerTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.jupiter.tools.spring.test.web.extension.RandomPortBindingExtension; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit.jupiter.SpringExtension; 13 | 14 | /** 15 | * Created on 29.08.2018. 16 | * 17 | * Change the server.port property to available TCP port, 18 | * than start web environment for this port 19 | * 20 | * @author Korovin Anatoliy 21 | */ 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @Target({ElementType.TYPE}) 24 | @ExtendWith(RandomPortBindingExtension.class) 25 | @ExtendWith(SpringExtension.class) 26 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) 27 | public @interface EnableEmbeddedWebServerTest { 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/extension/ActiveMqTcExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import org.junit.jupiter.api.extension.Extension; 4 | import org.testcontainers.containers.GenericContainer; 5 | 6 | /** 7 | * Created on 07.08.2018. 8 | * 9 | * @author Korovin Anatoliy 10 | */ 11 | public class ActiveMqTcExtension implements Extension { 12 | 13 | private static final Integer MQ_PORT = 61616; 14 | private static GenericContainer activemq = 15 | new GenericContainer("rmohr/activemq:latest").withExposedPorts(MQ_PORT); 16 | 17 | static { 18 | 19 | activemq.start(); 20 | 21 | String brokerUrl = String.format("tcp://%s:%s", 22 | activemq.getContainerIpAddress(), 23 | activemq.getMappedPort(MQ_PORT)); 24 | 25 | System.setProperty("spring.activemq.broker-url", brokerUrl); 26 | System.setProperty("spring.activemq.user", "admin"); 27 | System.setProperty("spring.activemq.password", "secret"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/annotation/ExpectedMessages.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created on 22.01.2019. 10 | * 11 | * By the use of this annotation, you can declare a list of 12 | * expected messages in JSON format, which you expect after the test execution. 13 | * Also, you can set a timeout, which will wait. 14 | * 15 | * @author Korovin Anatoliy 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target(ElementType.METHOD) 19 | public @interface ExpectedMessages { 20 | 21 | /** 22 | * The name of a queue for messages 23 | */ 24 | String queue(); 25 | 26 | /** 27 | * The timeout for wait messages after the test execution (10 sec. by default) 28 | */ 29 | int timeout() default 10000; 30 | 31 | /** 32 | * The path to the JSON file with expected messages 33 | */ 34 | String messagesFile(); 35 | } 36 | -------------------------------------------------------------------------------- /spring-test-mysql/src/main/java/com/jupiter/tools/spring/test/mysql/extension/MySqlTcExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.extension; 2 | 3 | import org.hibernate.dialect.MySQL5Dialect; 4 | import org.junit.jupiter.api.extension.Extension; 5 | import org.testcontainers.containers.MySQLContainer; 6 | 7 | /** 8 | * Created on 07.08.2018. 9 | * 10 | * @author Korovin Anatoliy 11 | */ 12 | public class MySqlTcExtension implements Extension { 13 | 14 | static { 15 | System.out.println("Start MySql testcontainers extension...\n"); 16 | 17 | MySQLContainer mysql = new MySQLContainer(); 18 | mysql.start(); 19 | 20 | System.setProperty("spring.datasource.driver-class-name", mysql.getDriverClassName()); 21 | System.setProperty("spring.datasource.url", mysql.getJdbcUrl() + "?useSSL=false"); 22 | System.setProperty("spring.datasource.username", mysql.getUsername()); 23 | System.setProperty("spring.datasource.password", mysql.getPassword()); 24 | System.setProperty("spring.jpa.properties.hibernate.dialect", MySQL5Dialect.class.getCanonicalName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-postgres/src/main/java/com/jupiter/tools/spring/test/postgres/extension/PostgresTcExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.extension; 2 | 3 | import org.hibernate.dialect.PostgreSQL9Dialect; 4 | import org.junit.jupiter.api.extension.Extension; 5 | import org.testcontainers.containers.PostgreSQLContainer; 6 | 7 | /** 8 | * Created on 06.08.2018. 9 | * 10 | * @author Korovin Anatoliy 11 | */ 12 | public class PostgresTcExtension implements Extension { 13 | 14 | static { 15 | System.out.println("Start Postgres testcontainers extension...\n"); 16 | 17 | PostgreSQLContainer postgres = new PostgreSQLContainer(); 18 | postgres.start(); 19 | 20 | System.setProperty("spring.datasource.driver-class-name", postgres.getDriverClassName()); 21 | System.setProperty("spring.datasource.url", postgres.getJdbcUrl()); 22 | System.setProperty("spring.datasource.username", postgres.getUsername()); 23 | System.setProperty("spring.datasource.password", postgres.getPassword()); 24 | System.setProperty("spring.jpa.properties.hibernate.dialect", PostgreSQL9Dialect.class.getCanonicalName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/annotation/EnableRiderTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.annotation; 2 | 3 | import com.github.database.rider.spring.api.DBRider; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created on 17.07.2018. 12 | * 13 | * Enable a configuration for the writing tests with 14 | * DatabaseRider library. 15 | * 16 | * You can combine this configuration with 17 | * EnableIntegrationTests or EnableDataTests. 18 | * 19 | * In order to work with a real DataBase in tests, you can use 20 | * this annotation in combination with some of TestContainersConfiguration: 21 | * - EnablePostgresTestContainers 22 | * - EnableMySqlTestContainers 23 | * By default use a configuration with H2 24 | * 25 | * 26 | * Main test-cases: 27 | * - init DataSet 28 | * - check expected DataSets after test 29 | * - generate DataSet 30 | * 31 | * @author Korovin Anatoliy 32 | */ 33 | @DBRider 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target(ElementType.TYPE) 36 | public @interface EnableRiderTest { 37 | } 38 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/extension/expected/list/messages/ExpectedMessagesMapper.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages; 4 | import com.jupiter.tools.spring.test.core.expected.list.messages.ExpectedMessagesOptions; 5 | 6 | /** 7 | * Created on 28.03.2019. 8 | * 9 | * Convert from {@link ExpectedMessages} to {@link ExpectedMessagesOptions} 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | public class ExpectedMessagesMapper { 14 | 15 | private final ExpectedMessages expectedMessages; 16 | 17 | public ExpectedMessagesMapper(ExpectedMessages expectedMessages){ 18 | this.expectedMessages = expectedMessages; 19 | } 20 | 21 | public ExpectedMessagesOptions getOptions() { 22 | return ExpectedMessagesOptions.builder() 23 | .messagesFile(expectedMessages.messagesFile()) 24 | .queue(expectedMessages.queue()) 25 | .timeout(expectedMessages.timeout()) 26 | .build(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/extension/expected/list/messages/ExpectedMessagesMapper.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.core.expected.list.messages.ExpectedMessagesOptions; 4 | import com.jupiter.tools.spring.test.rabbitmq.annotation.ExpectedMessages; 5 | 6 | /** 7 | * Created on 28.03.2019. 8 | * 9 | * Convert from {@link ExpectedMessages} to {@link ExpectedMessagesOptions} 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | public class ExpectedMessagesMapper { 14 | 15 | private final ExpectedMessages expectedMessages; 16 | 17 | public ExpectedMessagesMapper(ExpectedMessages expectedMessages){ 18 | this.expectedMessages = expectedMessages; 19 | } 20 | 21 | public ExpectedMessagesOptions getOptions() { 22 | return ExpectedMessagesOptions.builder() 23 | .messagesFile(expectedMessages.messagesFile()) 24 | .queue(expectedMessages.queue()) 25 | .timeout(expectedMessages.timeout()) 26 | .build(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import org.junit.jupiter.api.extension.AfterAllCallback; 4 | import org.junit.jupiter.api.extension.BeforeEachCallback; 5 | import org.junit.jupiter.api.extension.Extension; 6 | import org.junit.jupiter.api.extension.ExtensionContext; 7 | 8 | /** 9 | * Created on 05.02.2019. 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | public class RedirectRibbonExtension implements Extension, BeforeEachCallback, AfterAllCallback { 14 | 15 | @Override 16 | public void beforeEach(ExtensionContext context) throws Exception { 17 | RedirectRibbonExtensionConfig.setClients(getClientNameFromTestClass(context)); 18 | } 19 | 20 | @Override 21 | public void afterAll(ExtensionContext context) throws Exception { 22 | RedirectRibbonExtensionConfig.setClients(); 23 | } 24 | 25 | private String[] getClientNameFromTestClass(ExtensionContext context) { 26 | return context.getRequiredTestClass() 27 | .getAnnotation(RedirectRibbonToEmbeddedWebServer.class) 28 | .value(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/annotation/meta/EnableActiveMqTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.annotation.meta; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.jupiter.tools.spring.test.activemq.annotation.EnableActiveMqTestContainers; 9 | import com.jupiter.tools.spring.test.activemq.extension.ActiveMqMessageExtension; 10 | import com.jupiter.tools.spring.test.activemq.extension.expected.list.messages.ActiveMqExpectedListOfMessagesExtension; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.test.context.junit.jupiter.SpringExtension; 15 | 16 | /** 17 | * Created on 28.01.2019. 18 | * 19 | * @author Korovin Anatoliy 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | @Target(ElementType.TYPE) 23 | @SpringBootTest 24 | @ExtendWith(SpringExtension.class) 25 | @EnableActiveMqTestContainers 26 | @ExtendWith(ActiveMqMessageExtension.class) 27 | @ExtendWith(ActiveMqExpectedListOfMessagesExtension.class) 28 | public @interface EnableActiveMqTest { 29 | } 30 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/annotation/meta/EnableRabbitMqTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.annotation.meta; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.jupiter.tools.spring.test.rabbitmq.annotation.EnableRabbitMqTestContainers; 9 | import com.jupiter.tools.spring.test.rabbitmq.extension.RabbitMqMessageExtension; 10 | import com.jupiter.tools.spring.test.rabbitmq.extension.expected.list.messages.RabbitMqExpectedListOfMessagesExtension; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.test.context.junit.jupiter.SpringExtension; 15 | 16 | /** 17 | * Created on 07.08.2018. 18 | * 19 | * @author Korovin Anatoliy 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | @Target(ElementType.TYPE) 23 | @SpringBootTest 24 | @ExtendWith(SpringExtension.class) 25 | @EnableRabbitMqTestContainers 26 | @ExtendWith(RabbitMqMessageExtension.class) 27 | @ExtendWith(RabbitMqExpectedListOfMessagesExtension.class) 28 | public @interface EnableRabbitMqTest { 29 | } 30 | -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/extension/EnableIntegrationTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import com.jupiter.tools.spring.test.core.annotation.EnableIntegrationTest; 4 | import com.jupiter.tools.spring.test.jpa.tracesql.AssertSqlQueryCount; 5 | import com.jupiter.tools.spring.test.jpa.tracesql.QueryType; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.context.annotation.Import; 11 | 12 | /** 13 | * Created on 26.01.2019. 14 | * 15 | * @author Korovin Anatoliy 16 | */ 17 | @EnableIntegrationTest 18 | @ExtendWith(TraceSqlExtension.class) 19 | @Import(TransactionalTestConfig.class) 20 | class EnableIntegrationTestTest { 21 | 22 | @Autowired 23 | private TransactionalTestConfig.TestService testService; 24 | 25 | @BeforeEach 26 | void setUp() { 27 | AssertSqlQueryCount.reset(); 28 | } 29 | 30 | @Test 31 | void testInsert() { 32 | // Act 33 | testService.ok(); 34 | // Assert 35 | AssertSqlQueryCount.assertCount(QueryType.INSERT, 1); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/annotation/ExpectedMessages.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created on 22.01.2019. 10 | * 11 | * By the use of this annotation, you can declare a list of 12 | * expected messages in JSON format, which you expect after the test execution. 13 | * Also, you can set a timeout, which will wait. 14 | * 15 | * @author Korovin Anatoliy 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target(ElementType.METHOD) 19 | public @interface ExpectedMessages { 20 | 21 | /** 22 | * The name of a queue for messages 23 | */ 24 | String queue(); 25 | 26 | /** 27 | * The timeout for wait messages after the test execution (10 sec. by default) 28 | */ 29 | int timeout() default 10000; 30 | 31 | /** 32 | * The path to the JSON file with expected messages 33 | */ 34 | String messagesFile(); 35 | 36 | /** 37 | * Ignore the receiving of unexpected messages (if true) 38 | */ 39 | boolean ignoreUnexpected() default false; 40 | } 41 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/ActiveMqTcExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessage; 4 | import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import org.springframework.amqp.core.Queue; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.TestConfiguration; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.jms.core.JmsTemplate; 12 | 13 | /** 14 | * Created on 07.08.2018. 15 | * 16 | * @author Korovin Anatoliy 17 | */ 18 | @EnableActiveMqTest 19 | public class ActiveMqTcExtensionTest { 20 | 21 | @Autowired 22 | private JmsTemplate jmsTemplate; 23 | 24 | @Test 25 | @ExpectedMessage(queue = "test-queue", message = "123") 26 | void testSend() { 27 | jmsTemplate.convertAndSend("test-queue", "123"); 28 | } 29 | 30 | @TestConfiguration 31 | public static class TestConfig { 32 | @Bean 33 | public Queue testQueue() { 34 | return new Queue("test-queue"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/annotation/EnableRestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.jupiter.tools.spring.test.core.annotation.EnableIntegrationTest; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit.jupiter.SpringExtension; 14 | 15 | /** 16 | * Created on 17.07.2018. 17 | * 18 | * Enable configuration for tests with an API level. 19 | * Run entire application context and configure a MockMvc. 20 | * 21 | * Main test-cases: 22 | * - test REST API communication 23 | * - test API response/request converters 24 | * - test all application scoup from REST-API (for example: API->Service->DAO->JPA) 25 | * 26 | * @author Korovin Anatoliy 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.TYPE) 30 | @EnableIntegrationTest 31 | @AutoConfigureMockMvc 32 | public @interface EnableRestTest { 33 | } 34 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/annotation/EnableDataTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.annotation; 2 | 3 | import org.junit.jupiter.api.extension.ExtendWith; 4 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 5 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * Created on 17.07.2018. 15 | * 16 | * Enable a configuration for the test with a database specific. 17 | * Use this only for testing DAO level. 18 | * Does not load entire context configuration. 19 | * 20 | * Main test cases: 21 | * - testing db.schem and constraints 22 | * - testing queries created by the spring-data, specification, querydsl 23 | * - testing custom query 24 | * - asserts sql query count 25 | * 26 | * @author Korovin Anatoliy 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.TYPE) 30 | @ExtendWith(SpringExtension.class) 31 | @DataJpaTest 32 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 33 | public @interface EnableDataTest { 34 | } 35 | -------------------------------------------------------------------------------- /spring-test-mysql/src/test/java/com/jupiter/tools/spring/test/mysql/annotation/meta/EnableMySqlDataTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.annotation.meta; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 5 | import com.jupiter.tools.spring.test.mysql.TransactionalTestConfig; 6 | import org.junit.jupiter.api.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Import; 9 | import org.springframework.test.annotation.Commit; 10 | 11 | /** 12 | * Created on 26.01.2019. 13 | * 14 | * @author Korovin Anatoliy 15 | */ 16 | @EnableMySqlDataTest 17 | @Import(TransactionalTestConfig.class) 18 | class EnableMySqlDataTestTest { 19 | 20 | @Autowired 21 | private TransactionalTestConfig.FooRepository repository; 22 | 23 | @Test 24 | @Commit 25 | @DataSet(cleanBefore = true, cleanAfter = true) 26 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 27 | void testCreate() throws Exception { 28 | 29 | repository.saveAndFlush(TransactionalTestConfig.Foo.builder() 30 | .field("tru la la..") 31 | .build()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/expected/list/messages/Fail.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.junit.jupiter.api.Assertions; 6 | 7 | /** 8 | * Created on 27.03.2019. 9 | * 10 | * Assert.fail with object serialization in the log. 11 | * 12 | * @author Korovin Anatoliy 13 | */ 14 | public class Fail { 15 | 16 | private final ObjectMapper mapper = new ObjectMapper(); 17 | private String message; 18 | private String object; 19 | 20 | public Fail(String errorText) { 21 | message = errorText; 22 | object = ""; 23 | } 24 | 25 | public Fail withObject(Object object) { 26 | 27 | if(object instanceof String){ 28 | this.object = (String) object; 29 | return this; 30 | } 31 | 32 | try { 33 | this.object = mapper.writeValueAsString(object); 34 | } 35 | catch (JsonProcessingException e) { 36 | e.printStackTrace(); 37 | throw new RuntimeException("Object Serialization Error"); 38 | } 39 | return this; 40 | } 41 | 42 | public void fire() { 43 | Assertions.fail(message + "\n" + object); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/expected/list/messages/ExpectedMessagesOptions.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | /** 7 | * Created on 27.03.2019. 8 | * 9 | * Options to work with {@link AssertReceivedMessages}. 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | @Data 14 | @Builder 15 | public class ExpectedMessagesOptions { 16 | 17 | /** 18 | * The name of a queue(or topic) for messages 19 | */ 20 | private String queue; 21 | 22 | /** 23 | * The timeout for wait messages after the test execution 24 | */ 25 | private long timeout; 26 | 27 | /** 28 | * The path to the JSON file with expected messages 29 | */ 30 | private String messagesFile; 31 | 32 | /** 33 | * Applies to the expected data-set after retrieve from json-file 34 | */ 35 | private DataSetPreProcessor expectedDataSetPreProcessor; 36 | 37 | /** 38 | * Applies to the actual data-set after receiving messages from queue(topic) 39 | */ 40 | private DataSetPreProcessor actualDataSetPreProcessor; 41 | 42 | /** 43 | * The list of queues(or topics) to wait for messages when using {@link AssertReceivedMessages#doAssertSilence()} 44 | */ 45 | private String[] allQueues; 46 | } 47 | -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/extension/EnableDataTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import com.jupiter.tools.spring.test.jpa.annotation.EnableDataTest; 4 | import com.jupiter.tools.spring.test.jpa.tracesql.AssertSqlQueryCount; 5 | import com.jupiter.tools.spring.test.jpa.tracesql.QueryType; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.context.annotation.Import; 11 | import org.springframework.test.annotation.Commit; 12 | import org.springframework.transaction.annotation.Propagation; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | /** 16 | * Created on 26.01.2019. 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @EnableDataTest 21 | @ExtendWith(TraceSqlExtension.class) 22 | @Import(TransactionalTestConfig.class) 23 | class EnableDataTestTest { 24 | 25 | @Autowired 26 | private TransactionalTestConfig.FooRepository fooRepository; 27 | 28 | @BeforeEach 29 | void setUp() { 30 | AssertSqlQueryCount.reset(); 31 | } 32 | 33 | @Test 34 | @Commit 35 | @Transactional(propagation = Propagation.NOT_SUPPORTED) 36 | void testInsert() { 37 | // Act 38 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 39 | // Assert 40 | AssertSqlQueryCount.assertCount(QueryType.INSERT,1); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-test-mysql/src/test/java/com/jupiter/tools/spring/test/mysql/annotation/EnableMySqlTestContainersTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.annotation; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 5 | import com.github.database.rider.spring.api.DBRider; 6 | import com.jupiter.tools.spring.test.mysql.TransactionalTestConfig; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.context.annotation.Import; 13 | import org.springframework.test.context.junit.jupiter.SpringExtension; 14 | 15 | /** 16 | * Created on 26.01.2019. 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @EnableMySqlTestContainers 21 | //----> 22 | @SpringBootTest 23 | @DBRider 24 | @ExtendWith(SpringExtension.class) 25 | @Import(TransactionalTestConfig.class) 26 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 27 | class EnableMySqlTestContainersTest { 28 | 29 | @Autowired 30 | private TransactionalTestConfig.TestService testService; 31 | 32 | @Test 33 | @DataSet(cleanBefore = true, cleanAfter = true) 34 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 35 | void testCreate() { 36 | testService.ok(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-test-postgres/src/test/java/com/jupiter/tools/spring/test/postgres/annotation/EnablePostgresTestContainersTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.annotation; 2 | 3 | import org.assertj.core.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 7 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 8 | import org.springframework.test.context.jdbc.Sql; 9 | import org.springframework.test.context.junit.jupiter.SpringExtension; 10 | 11 | import javax.persistence.EntityManager; 12 | import javax.persistence.PersistenceContext; 13 | import javax.persistence.StoredProcedureQuery; 14 | import java.util.List; 15 | 16 | /** 17 | * Created on 26.01.2019. 18 | * 19 | * @author Korovin Anatoliy 20 | */ 21 | @DataJpaTest 22 | @ExtendWith(SpringExtension.class) 23 | @EnablePostgresTestContainers 24 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 25 | class EnablePostgresTestContainersTest { 26 | 27 | @PersistenceContext 28 | private EntityManager entityManager; 29 | 30 | @Test 31 | @Sql("/stored_functions/test_func.sql") 32 | void testStoredFunc() { 33 | // Arrange 34 | StoredProcedureQuery query = entityManager.createStoredProcedureQuery("rnd"); 35 | // Act 36 | query.execute(); 37 | // Assert 38 | List resultList = query.getResultList(); 39 | int rnd = (int) resultList.get(0); 40 | Assertions.assertThat(rnd).isEqualTo(123); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/expected/list/messages/MessagesDataSet.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import com.fasterxml.jackson.databind.ObjectMapper; 11 | import com.jupitertools.datasetroll.DataSet; 12 | 13 | /** 14 | * DataSet to represent a list of messages. 15 | * Matches canonical class name of a message object to the list of messages converted to Map. 16 | * 17 | * @author Korovin Anatoliy 18 | */ 19 | public class MessagesDataSet implements DataSet { 20 | 21 | private final List messages; 22 | private final ObjectMapper objectMapper; 23 | 24 | /** 25 | * Make the DataSet from a list of received messages. 26 | * 27 | * @param messages the list of messages objects 28 | */ 29 | public MessagesDataSet(List messages) { 30 | this.messages = messages; 31 | this.objectMapper = new ObjectMapper(); 32 | } 33 | 34 | @Override 35 | public Map>> read() { 36 | 37 | Map>> result = new HashMap<>(); 38 | 39 | for (Object message : messages) { 40 | 41 | String className = message.getClass().getCanonicalName(); 42 | Map messageFields = objectMapper.convertValue(message, Map.class); 43 | 44 | List> entry = result.get(className); 45 | if (entry == null) { 46 | result.put(className, new ArrayList<>(Arrays.asList(messageFields))); 47 | } else { 48 | entry.add(messageFields); 49 | } 50 | } 51 | 52 | return result; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryCountInfo.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | /** 4 | * Created on 12/6/15 5 | * 6 | * @author Igor Dmitriev 7 | * @author Mikalai Alimenkou 8 | * @author Korovin Anatoliy 9 | */ 10 | public class QueryCountInfo { 11 | private int selectCount; 12 | private int insertCount; 13 | private int updateCount; 14 | private int deleteCount; 15 | private int callCount; 16 | private int otherCount; 17 | 18 | public void incrementSelectCount() { 19 | selectCount++; 20 | } 21 | 22 | public void incrementInsertCount() { 23 | insertCount++; 24 | } 25 | 26 | public void incrementUpdateCount() { 27 | updateCount++; 28 | } 29 | 30 | public void incrementDeleteCount() { 31 | deleteCount++; 32 | } 33 | 34 | public void incrementCallCount() { 35 | callCount++; 36 | } 37 | 38 | public void incrementOtherCount() { 39 | otherCount++; 40 | } 41 | 42 | public void clear() { 43 | selectCount = 0; 44 | insertCount = 0; 45 | updateCount = 0; 46 | deleteCount = 0; 47 | callCount = 0; 48 | otherCount = 0; 49 | } 50 | 51 | public int getSelectCount() { 52 | return selectCount; 53 | } 54 | 55 | public int getInsertCount() { 56 | return insertCount; 57 | } 58 | 59 | public int getUpdateCount() { 60 | return updateCount; 61 | } 62 | 63 | public int getDeleteCount() { 64 | return deleteCount; 65 | } 66 | 67 | public int getCallCount() { 68 | return callCount; 69 | } 70 | 71 | public int getOtherCount() { 72 | return otherCount; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/ExpectedMessageTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | import com.jupiter.tools.spring.test.rabbitmq.annotation.ExpectedMessage; 4 | import com.jupiter.tools.spring.test.rabbitmq.annotation.ExpectedMessages; 5 | import com.jupiter.tools.spring.test.rabbitmq.annotation.meta.EnableRabbitMqTest; 6 | import com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Foo; 7 | import org.junit.jupiter.api.Test; 8 | 9 | import org.springframework.amqp.core.AmqpTemplate; 10 | import org.springframework.amqp.core.Queue; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.TestConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | 15 | /** 16 | * Created on 22.01.2019. 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | @EnableRabbitMqTest 21 | public class ExpectedMessageTest { 22 | 23 | @Autowired 24 | private AmqpTemplate amqpTemplate; 25 | 26 | @Test 27 | @ExpectedMessage(queue = "test-queue", message = "123") 28 | void testSend() { 29 | amqpTemplate.convertAndSend("test-queue", "123"); 30 | } 31 | 32 | @Test 33 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages.json") 34 | void testSendListOfMessages() { 35 | amqpTemplate.convertAndSend("test-queue", new Foo("123")); 36 | amqpTemplate.convertAndSend("test-queue", new Foo("456")); 37 | amqpTemplate.convertAndSend("test-queue", new Foo("789")); 38 | } 39 | 40 | @TestConfiguration 41 | public static class TestConfig { 42 | @Bean 43 | public Queue testQueue() { 44 | return new Queue("test-queue"); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-test-mysql/src/test/java/com/jupiter/tools/spring/test/mysql/extension/MySqlTcExtensionIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.extension; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.DataSetFormat; 5 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 6 | import com.github.database.rider.core.api.exporter.ExportDataSet; 7 | import com.github.database.rider.spring.api.DBRider; 8 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 9 | import com.jupiter.tools.spring.test.mysql.TransactionalTestConfig; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.test.context.junit.jupiter.SpringExtension; 17 | 18 | /** 19 | * Created on 25.01.2019. 20 | * 21 | * @author Korovin Anatoliy 22 | */ 23 | @SpringBootTest 24 | @DBRider 25 | @ExtendWith(SpringExtension.class) 26 | @ExtendWith(MySqlTcExtension.class) 27 | @ExtendWith(TraceSqlExtension.class) 28 | @Import(TransactionalTestConfig.class) 29 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 30 | class MySqlTcExtensionIntegrationTest { 31 | 32 | @Autowired 33 | private TransactionalTestConfig.TestService testService; 34 | 35 | @Test 36 | @DataSet(cleanBefore = true, cleanAfter = true) 37 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 38 | void testCreate() { 39 | testService.ok(); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /spring-test-postgres/src/test/java/com/jupiter/tools/spring/test/postgres/extension/PostgresTcExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.extension; 2 | 3 | import javax.persistence.EntityManager; 4 | import javax.persistence.PersistenceContext; 5 | import javax.persistence.StoredProcedureQuery; 6 | import java.util.List; 7 | 8 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 9 | import org.assertj.core.api.Assertions; 10 | import org.junit.jupiter.api.Disabled; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | 14 | import org.springframework.boot.autoconfigure.SpringBootApplication; 15 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 16 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 17 | import org.springframework.test.context.jdbc.Sql; 18 | import org.springframework.test.context.junit.jupiter.SpringExtension; 19 | 20 | /** 21 | * Created on 23.01.2019. 22 | * 23 | * @author Korovin Anatoliy 24 | */ 25 | @DataJpaTest 26 | @ExtendWith(SpringExtension.class) 27 | @ExtendWith(PostgresTcExtension.class) 28 | @ExtendWith(TraceSqlExtension.class) 29 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 30 | class PostgresTcExtensionTest { 31 | 32 | @PersistenceContext 33 | private EntityManager entityManager; 34 | 35 | @Test 36 | @Sql("/stored_functions/test_func.sql") 37 | void testStoredFunc() { 38 | // Arrange 39 | StoredProcedureQuery query = entityManager.createStoredProcedureQuery("rnd"); 40 | // Act 41 | query.execute(); 42 | // Assert 43 | List resultList = query.getResultList(); 44 | int rnd = (int) resultList.get(0); 45 | Assertions.assertThat(rnd).isEqualTo(123); 46 | } 47 | } -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/extension/TraceSqlExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import com.jupiter.tools.spring.test.jpa.tracesql.StatementInspectorImpl; 4 | import com.zaxxer.hikari.HikariDataSource; 5 | import org.junit.jupiter.api.extension.Extension; 6 | 7 | /** 8 | * Created on 07.08.2018. 9 | * 10 | * @author Korovin Anatoliy 11 | */ 12 | public class TraceSqlExtension implements Extension { 13 | 14 | static { 15 | setUpDbConnectionSetting(); 16 | setUpCustomStatementInspector(); 17 | setUpTraceProperties(); 18 | } 19 | 20 | private static void setUpDbConnectionSetting() { 21 | System.setProperty("spring.datasource.type", HikariDataSource.class.getCanonicalName()); 22 | System.setProperty("spring.jpa.generate-ddl", "true"); 23 | System.setProperty("spring.jpa.hibernate.ddl-auto", "create-drop"); 24 | System.setProperty("spring.jpa.show-sql", "true"); 25 | System.setProperty("spring.jpa.properties.hibernate.hbm2ddl.auto", "create-drop"); 26 | } 27 | 28 | private static void setUpCustomStatementInspector() { 29 | System.setProperty("spring.jpa.properties.hibernate.session_factory.statement_inspector", 30 | StatementInspectorImpl.class.getCanonicalName()); 31 | } 32 | 33 | 34 | private static void setUpTraceProperties() { 35 | System.setProperty("spring.jpa.show-sql", "true"); 36 | System.setProperty("spring.jpa.properties.hibernate.type", "trace"); 37 | System.setProperty("spring.jpa.properties.hibernate.format_sql", "true"); 38 | System.setProperty("spring.jpa.properties.hibernate.use_sql_comments", "true"); 39 | System.setProperty("logging.level.org.hibernate.type.descriptor.sql", "trace"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/EnableRestTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension; 2 | 3 | import com.jupiter.tools.spring.test.web.annotation.EnableRestTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.TestConfiguration; 8 | import org.springframework.test.web.servlet.MockMvc; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 15 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 16 | 17 | /** 18 | * Created on 29.01.2019. 19 | * 20 | * @author Korovin Anatoliy 21 | */ 22 | @EnableRestTest 23 | public class EnableRestTestTest { 24 | 25 | @Autowired 26 | private MockMvc mockMvc; 27 | 28 | @Test 29 | void testApi() throws Exception { 30 | // Arrange 31 | // Act 32 | String result = mockMvc.perform(get("/api/test")) 33 | // Assert 34 | .andExpect(status().isOk()) 35 | .andReturn().getResponse().getContentAsString(); 36 | 37 | assertThat(result).isEqualTo("hello world"); 38 | } 39 | 40 | @TestConfiguration 41 | public static class TestConfig { 42 | 43 | @RestController 44 | @RequestMapping("api") 45 | public class TestController { 46 | 47 | @GetMapping("test") 48 | public String test() { 49 | return "hello world"; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryCountInfoHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.Arguments; 7 | import org.junit.jupiter.params.provider.MethodSource; 8 | 9 | import java.util.function.Function; 10 | import java.util.stream.Stream; 11 | 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | 14 | /** 15 | * Created on 27.01.2019. 16 | * 17 | * @author Korovin Anatoliy 18 | */ 19 | class QueryCountInfoHandlerTest { 20 | 21 | private static Stream params() { 22 | return Stream.of(new TestArg("insert ...", QueryCountInfo::getInsertCount), 23 | new TestArg("select ...", QueryCountInfo::getSelectCount), 24 | new TestArg("update ...", QueryCountInfo::getUpdateCount), 25 | new TestArg("delete ...", QueryCountInfo::getDeleteCount), 26 | new TestArg("call ...", QueryCountInfo::getCallCount), 27 | new TestArg("oops ...", QueryCountInfo::getOtherCount)); 28 | } 29 | 30 | @ParameterizedTest 31 | @MethodSource("params") 32 | void handleOp(TestArg arg) { 33 | // Arrange 34 | QueryCountInfoHolder.getQueryInfo().clear(); 35 | QueryCountInfoHandler handler = new QueryCountInfoHandler(); 36 | // Act 37 | handler.handleSql(arg.getRequest()); 38 | // Asserts 39 | int count = arg.getRetrieveCount().apply(QueryCountInfoHolder.getQueryInfo()); 40 | assertThat(count).isEqualTo(1); 41 | } 42 | 43 | @Getter 44 | @AllArgsConstructor 45 | static class TestArg { 46 | String request; 47 | Function retrieveCount; 48 | } 49 | } -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/RandomPortBindingExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension; 2 | 3 | import com.jupiter.tools.spring.test.web.annotation.EnableEmbeddedWebServerTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.test.context.TestConfiguration; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import org.springframework.web.client.RestTemplate; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | /** 18 | * Created on 29.01.2019. 19 | * 20 | * @author Korovin Anatoliy 21 | */ 22 | @EnableEmbeddedWebServerTest 23 | class RandomPortBindingExtensionTest { 24 | 25 | @Autowired 26 | private RestTemplate restTemplate; 27 | 28 | @Value("${server.port}") 29 | private String port; 30 | 31 | @Test 32 | void invokeEmbeddedWebServer() { 33 | // Arrange 34 | String url = "http://localhost:" + port + "/api/test"; 35 | // Act 36 | String test = restTemplate.getForObject(url, String.class); 37 | // Assert 38 | assertThat(test).isEqualTo("A"); 39 | } 40 | 41 | @TestConfiguration 42 | public static class TestConfig { 43 | 44 | @Bean 45 | public RestTemplate restTemplate() { 46 | return new RestTemplate(); 47 | } 48 | 49 | @RestController 50 | @RequestMapping("api") 51 | public class TestController { 52 | 53 | @GetMapping("test") 54 | public String test() { 55 | return "A"; 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/RandomPortBindingExtensionSecondTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension; 2 | 3 | import com.jupiter.tools.spring.test.web.annotation.EnableEmbeddedWebServerTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.test.context.TestConfiguration; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import org.springframework.web.client.RestTemplate; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | /** 18 | * Created on 29.01.2019. 19 | * 20 | * @author Korovin Anatoliy 21 | */ 22 | @EnableEmbeddedWebServerTest 23 | class RandomPortBindingExtensionSecondTest { 24 | 25 | @Autowired 26 | private RestTemplate restTemplate; 27 | 28 | @Value("${server.port}") 29 | private String port; 30 | 31 | @Test 32 | void invokeEmbeddedWebServer() { 33 | // Arrange 34 | String url = "http://localhost:" + port + "/api/test"; 35 | // Act 36 | String test = restTemplate.getForObject(url, String.class); 37 | // Assert 38 | assertThat(test).isEqualTo("B"); 39 | } 40 | 41 | @TestConfiguration 42 | public static class TestConfig { 43 | 44 | @Bean 45 | public RestTemplate restTemplate() { 46 | return new RestTemplate(); 47 | } 48 | 49 | @RestController 50 | @RequestMapping("api") 51 | public class TestController { 52 | 53 | @GetMapping("test") 54 | public String test() { 55 | return "B"; 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/extension/RabbitMqMessageExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | import com.jupiter.tools.spring.test.rabbitmq.annotation.ExpectedMessage; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.extension.AfterEachCallback; 6 | import org.junit.jupiter.api.extension.BeforeAllCallback; 7 | import org.junit.jupiter.api.extension.ExtensionContext; 8 | 9 | import org.springframework.amqp.core.AmqpTemplate; 10 | import org.springframework.amqp.core.Message; 11 | import org.springframework.test.context.junit.jupiter.SpringExtension; 12 | 13 | /** 14 | * Created on 22.01.2019. 15 | * 16 | * @author Korovin Anatoliy 17 | */ 18 | public class RabbitMqMessageExtension implements BeforeAllCallback, AfterEachCallback { 19 | 20 | private AmqpTemplate amqpTemplate; 21 | 22 | @Override 23 | public void afterEach(ExtensionContext context) throws Exception { 24 | 25 | ExpectedMessage expectedMessage = 26 | context.getRequiredTestMethod().getAnnotation(ExpectedMessage.class); 27 | 28 | if (expectedMessage == null) { 29 | return; 30 | } 31 | 32 | Message message = amqpTemplate.receive(expectedMessage.queue(), expectedMessage.timeout()); 33 | 34 | if(message == null){ 35 | throw new Error(String.format("Expected but not received: %s", expectedMessage.message())); 36 | } 37 | 38 | Assertions.assertEquals(new String(message.getBody()), expectedMessage.message()); 39 | } 40 | 41 | @Override 42 | public void beforeAll(ExtensionContext context) throws Exception { 43 | 44 | amqpTemplate = SpringExtension.getApplicationContext(context) 45 | .getBean(AmqpTemplate.class); 46 | 47 | if (amqpTemplate == null) { 48 | throw new RuntimeException("Not found the AmqpTemplate bean in the current spring context."); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-test-web/src/main/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonServerList.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import com.netflix.client.config.IClientConfig; 4 | import com.netflix.loadbalancer.AbstractServerList; 5 | import com.netflix.loadbalancer.Server; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | /** 11 | * Created on 06.02.2019. 12 | * 13 | * @author Korovin Anatoliy 14 | */ 15 | public class RedirectRibbonServerList extends AbstractServerList { 16 | 17 | private final List clientNames; 18 | private IClientConfig clientConfig; 19 | 20 | 21 | public RedirectRibbonServerList(IClientConfig clientConfig, List clientNames) { 22 | if (clientNames == null) { 23 | throw new RuntimeException("clientNames must be not null"); 24 | } 25 | this.clientConfig = clientConfig; 26 | this.clientNames = clientNames; 27 | } 28 | 29 | @Override 30 | public List getInitialListOfServers() { 31 | return getUpdatedListOfServers(); 32 | } 33 | 34 | @Override 35 | public List getUpdatedListOfServers() { 36 | 37 | // processing of default value of the RedirectRibbonToEmbeddedWebServer annotation 38 | if (clientNames.isEmpty()) { 39 | return getEmbeddedServers(); 40 | } 41 | 42 | if (clientConfig != null && clientNames.contains(clientConfig.getClientName())) { 43 | return getEmbeddedServers(); 44 | } else { 45 | return Collections.emptyList(); 46 | } 47 | } 48 | 49 | @Override 50 | public void initWithNiwsConfig(IClientConfig clientConfig) { 51 | this.clientConfig = clientConfig; 52 | } 53 | 54 | private List getEmbeddedServers() { 55 | return Collections.singletonList(new Server("127.0.0.1", getPort())); 56 | } 57 | 58 | private Integer getPort() { 59 | return Integer.valueOf(System.getProperty("server.port")); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonExtensionByFeignTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import com.jupiter.tools.spring.test.web.annotation.EnableEmbeddedWebServerTest; 4 | import feign.Client; 5 | import feign.Feign; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.TestConfiguration; 10 | import org.springframework.cloud.openfeign.support.SpringMvcContract; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | 18 | /** 19 | * Created on 06.02.2019. 20 | * 21 | * @author Korovin Anatoliy 22 | */ 23 | @EnableEmbeddedWebServerTest 24 | @RedirectRibbonToEmbeddedWebServer("test-service") 25 | class RedirectRibbonExtensionByFeignTest { 26 | 27 | @Autowired 28 | private CustomFeign customFeign; 29 | 30 | @Test 31 | void feign() { 32 | String test = customFeign.test(); 33 | assertThat(test).isEqualTo("123"); 34 | } 35 | 36 | @TestConfiguration 37 | public static class TestCfg { 38 | 39 | @RestController 40 | @RequestMapping("/messages") 41 | public class TestApi { 42 | 43 | @GetMapping("/test") 44 | public String test() { 45 | return "123"; 46 | } 47 | } 48 | 49 | @Bean 50 | public CustomFeign customFeign(Client client) { 51 | return Feign.builder() 52 | .contract(new SpringMvcContract()) 53 | .client(client) 54 | .target(CustomFeign.class, "http://test-service"); 55 | } 56 | } 57 | 58 | public interface CustomFeign { 59 | @GetMapping("/messages/test") 60 | String test(); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /spring-test-core/src/test/java/com/jupiter/tools/spring/test/core/expected/list/messages/MessagesDataSetTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import com.google.common.collect.ImmutableMap; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import org.junit.jupiter.api.Test; 11 | 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | 14 | class MessagesDataSetTest { 15 | 16 | @Test 17 | void singleTypeOfMessages() { 18 | Foo foo1 = new Foo("111"); 19 | Foo foo2 = new Foo("222"); 20 | List messages = Arrays.asList(foo1, foo2); 21 | MessagesDataSet dataSet = new MessagesDataSet(messages); 22 | // Act 23 | Map>> map = dataSet.read(); 24 | // Assert 25 | assertThat(map).containsKeys(Foo.class.getCanonicalName()); 26 | assertThat(map.get(Foo.class.getCanonicalName())).contains(ImmutableMap.of("name", "111"), 27 | ImmutableMap.of("name", "222")); 28 | } 29 | 30 | @Test 31 | void multipleTypes() { 32 | Foo foo1 = new Foo("111"); 33 | Foo foo2 = new Foo("222"); 34 | Bar bar = new Bar("AAA"); 35 | List messages = Arrays.asList(foo1, foo2, bar); 36 | MessagesDataSet dataSet = new MessagesDataSet(messages); 37 | // Act 38 | Map>> map = dataSet.read(); 39 | // Assert 40 | assertThat(map).containsKeys(Foo.class.getCanonicalName()); 41 | assertThat(map.get(Foo.class.getCanonicalName())).contains(ImmutableMap.of("name", "111"), 42 | ImmutableMap.of("name", "222")); 43 | assertThat(map).containsKeys(Bar.class.getCanonicalName()); 44 | assertThat(map.get(Bar.class.getCanonicalName())).contains(ImmutableMap.of("value", "AAA")); 45 | } 46 | 47 | @Data 48 | @AllArgsConstructor 49 | static class Foo { 50 | private String name; 51 | } 52 | 53 | @Data 54 | @AllArgsConstructor 55 | static class Bar { 56 | private String value; 57 | } 58 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/extension/ActiveMqMessageExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import javax.jms.Message; 4 | 5 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessage; 6 | import org.apache.activemq.command.ActiveMQTextMessage; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.extension.AfterEachCallback; 9 | import org.junit.jupiter.api.extension.BeforeAllCallback; 10 | import org.junit.jupiter.api.extension.ExtensionContext; 11 | 12 | import org.springframework.jms.core.JmsTemplate; 13 | import org.springframework.test.context.junit.jupiter.SpringExtension; 14 | 15 | /** 16 | * Created on 22.01.2019. 17 | * 18 | * @author Korovin Anatoliy 19 | */ 20 | public class ActiveMqMessageExtension implements BeforeAllCallback, AfterEachCallback { 21 | 22 | private JmsTemplate jmsTemplate; 23 | 24 | @Override 25 | public void afterEach(ExtensionContext context) throws Exception { 26 | 27 | ExpectedMessage expectedMessage = context.getRequiredTestMethod() 28 | .getAnnotation(ExpectedMessage.class); 29 | if(expectedMessage ==null){ 30 | return; 31 | } 32 | 33 | jmsTemplate.setReceiveTimeout(expectedMessage.timeout()); 34 | Message message = jmsTemplate.receive(expectedMessage.queue()); 35 | 36 | if(message == null){ 37 | throw new Error(String.format("Expected but not received: %s", expectedMessage.message())); 38 | } 39 | Assertions.assertEquals(((ActiveMQTextMessage) message).getText(), expectedMessage.message()); 40 | } 41 | 42 | @Override 43 | public void beforeAll(ExtensionContext context) throws Exception { 44 | jmsTemplate = SpringExtension.getApplicationContext(context) 45 | .getBean(JmsTemplate.class); 46 | 47 | if (jmsTemplate == null) { 48 | throw new RuntimeException("Not found the JmsTemplate bean in the current spring context."); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/extension/ExpectedSqlQueryExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import com.jupiter.tools.spring.test.jpa.annotation.ExpectedSqlQueries; 4 | import com.jupiter.tools.spring.test.jpa.annotation.ExpectedSqlQuery; 5 | import com.jupiter.tools.spring.test.jpa.tracesql.AssertSqlQueryCount; 6 | import org.junit.jupiter.api.extension.AfterEachCallback; 7 | import org.junit.jupiter.api.extension.BeforeEachCallback; 8 | import org.junit.jupiter.api.extension.Extension; 9 | import org.junit.jupiter.api.extension.ExtensionContext; 10 | 11 | /** 12 | * Created on 15.04.2019. 13 | * 14 | * Extension to process the expected count of executed sql queries 15 | * after a test execution 16 | * 17 | * @author Korovin Anatoliy 18 | */ 19 | public class ExpectedSqlQueryExtension implements Extension, 20 | BeforeEachCallback, 21 | AfterEachCallback { 22 | 23 | @Override 24 | public void beforeEach(ExtensionContext context) throws Exception { 25 | AssertSqlQueryCount.reset(); 26 | } 27 | 28 | @Override 29 | public void afterEach(ExtensionContext context) throws Exception { 30 | 31 | // processing the usage of repeatable annotations 32 | ExpectedSqlQueries sqlQueries = context.getRequiredTestMethod() 33 | .getAnnotation(ExpectedSqlQueries.class); 34 | if (sqlQueries != null) { 35 | for (ExpectedSqlQuery sqlQuery : sqlQueries.value()) { 36 | AssertSqlQueryCount.assertCount(sqlQuery.type(), sqlQuery.count()); 37 | } 38 | } 39 | 40 | // processing the usage of a single annotation 41 | ExpectedSqlQuery expectedSqlQuery = context.getRequiredTestMethod() 42 | .getAnnotation(ExpectedSqlQuery.class); 43 | if (expectedSqlQuery != null) { 44 | AssertSqlQueryCount.assertCount(expectedSqlQuery.type(), expectedSqlQuery.count()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/EnableActiveMqWithListOfMessagesTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages; 4 | import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest; 5 | import com.jupiter.tools.spring.test.activemq.extension.expected.Foo; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import org.springframework.amqp.core.Queue; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.TestConfiguration; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.jms.core.JmsTemplate; 13 | import org.springframework.jms.support.converter.MappingJackson2MessageConverter; 14 | import org.springframework.jms.support.converter.MessageConverter; 15 | import org.springframework.jms.support.converter.MessageType; 16 | 17 | /** 18 | * Created on 25.03.2019. 19 | * 20 | * @author Korovin Anatoliy 21 | */ 22 | @EnableActiveMqTest 23 | public class EnableActiveMqWithListOfMessagesTest { 24 | 25 | @Autowired 26 | private JmsTemplate jmsTemplate; 27 | 28 | @Test 29 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages.json") 30 | void testSendListOfMessages() { 31 | jmsTemplate.convertAndSend("test-queue", new Foo("123")); 32 | jmsTemplate.convertAndSend("test-queue", new Foo("456")); 33 | jmsTemplate.convertAndSend("test-queue", new Foo("789")); 34 | } 35 | 36 | @TestConfiguration 37 | public static class TestConfig { 38 | @Bean 39 | public Queue testQueue() { 40 | return new Queue("test-queue"); 41 | } 42 | 43 | @Bean // Serialize message content to json using TextMessage 44 | public MessageConverter jacksonJmsMessageConverter() { 45 | MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); 46 | converter.setTargetType(MessageType.TEXT); 47 | converter.setTypeIdPropertyName("_type"); 48 | return converter; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-test-postgres/src/test/java/com/jupiter/tools/spring/test/postgres/annotation/meta/EnablePostgresDataTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.annotation.meta; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 5 | import com.jupiter.tools.spring.test.postgres.TransactionalTestConfig; 6 | import org.assertj.core.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Import; 10 | import org.springframework.test.annotation.Commit; 11 | import org.springframework.test.context.jdbc.Sql; 12 | import org.springframework.transaction.annotation.Propagation; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | import javax.persistence.EntityManager; 16 | import javax.persistence.PersistenceContext; 17 | import javax.persistence.StoredProcedureQuery; 18 | import java.util.List; 19 | 20 | /** 21 | * Created on 23.01.2019. 22 | * 23 | * @author Korovin Anatoliy 24 | */ 25 | @EnablePostgresDataTest 26 | @Import(TransactionalTestConfig.class) 27 | class EnablePostgresDataTestTest { 28 | 29 | @PersistenceContext 30 | private EntityManager entityManager; 31 | 32 | @Autowired 33 | private TransactionalTestConfig.FooRepository repository; 34 | 35 | @Test 36 | @Sql("/stored_functions/test_func.sql") 37 | void testStoredFunc() { 38 | // Arrange 39 | StoredProcedureQuery query = entityManager.createStoredProcedureQuery("rnd"); 40 | // Act 41 | query.execute(); 42 | // Assert 43 | List resultList = query.getResultList(); 44 | int rnd = (int) resultList.get(0); 45 | Assertions.assertThat(rnd).isEqualTo(123); 46 | } 47 | 48 | @Test 49 | @Commit 50 | @Transactional(propagation = Propagation.NOT_SUPPORTED) 51 | @DataSet(cleanBefore = true, cleanAfter = true) 52 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 53 | void testCreate() { 54 | repository.saveAndFlush(TransactionalTestConfig.Foo.builder() 55 | .field("tru la la..") 56 | .build()); 57 | } 58 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/main/java/com/jupiter/tools/spring/test/activemq/extension/expected/list/messages/ActiveMqExpectedListOfMessagesExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages; 4 | import com.jupiter.tools.spring.test.core.expected.list.messages.AssertReceivedMessages; 5 | import com.jupiter.tools.spring.test.core.expected.list.messages.ExpectedMessagesOptions; 6 | import com.jupiter.tools.spring.test.core.expected.list.messages.MessageBroker; 7 | import org.junit.jupiter.api.extension.AfterEachCallback; 8 | import org.junit.jupiter.api.extension.BeforeAllCallback; 9 | import org.junit.jupiter.api.extension.ExtensionContext; 10 | 11 | import org.springframework.jms.core.JmsTemplate; 12 | import org.springframework.test.context.junit.jupiter.SpringExtension; 13 | 14 | /** 15 | * Created on 07.02.2019. 16 | * 17 | * This extension provides an ability to assert sent messages after test execution. 18 | * You can declare a list of expected messages in JSON format. 19 | * 20 | * @author Korovin Anatoliy 21 | */ 22 | public class ActiveMqExpectedListOfMessagesExtension implements BeforeAllCallback, AfterEachCallback { 23 | 24 | private MessageBroker messageBroker; 25 | 26 | @Override 27 | public void afterEach(ExtensionContext context) throws Exception { 28 | 29 | ExpectedMessages expectedMessages = context.getRequiredTestMethod() 30 | .getAnnotation(ExpectedMessages.class); 31 | if(expectedMessages == null) { 32 | return; 33 | } 34 | 35 | ExpectedMessagesOptions options = new ExpectedMessagesMapper(expectedMessages).getOptions(); 36 | new AssertReceivedMessages(options, messageBroker).doAssert(); 37 | } 38 | 39 | @Override 40 | public void beforeAll(ExtensionContext context) throws Exception { 41 | JmsTemplate jmsTemplate = SpringExtension.getApplicationContext(context) 42 | .getBean(JmsTemplate.class); 43 | 44 | if (jmsTemplate == null) { 45 | throw new RuntimeException("Not found the JmsTemplate bean in the current spring context."); 46 | } 47 | 48 | messageBroker = new ActiveMqMessageBroker(jmsTemplate); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-test-postgres/src/test/java/com/jupiter/tools/spring/test/postgres/extension/PostgresTcExtensionIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres.extension; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 5 | import com.github.database.rider.spring.api.DBRider; 6 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 7 | import com.jupiter.tools.spring.test.postgres.TransactionalTestConfig; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 13 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.test.context.junit.jupiter.SpringExtension; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | /** 21 | * Created on 23.01.2019. 22 | * 23 | * @author Korovin Anatoliy 24 | */ 25 | @DBRider 26 | @SpringBootTest 27 | @ExtendWith(SpringExtension.class) 28 | @ExtendWith(PostgresTcExtension.class) 29 | @ExtendWith(TraceSqlExtension.class) 30 | @Import(TransactionalTestConfig.class) 31 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 32 | class PostgresTcExtensionIntegrationTest { 33 | 34 | @Autowired 35 | private TransactionalTestConfig.TestService testService; 36 | 37 | @Test 38 | @DataSet(cleanBefore = true, cleanAfter = true) 39 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 40 | void testCreate() { 41 | testService.ok(); 42 | } 43 | 44 | @Autowired 45 | private TransactionalTestConfig.FooRepository fooRepository; 46 | 47 | @Test 48 | void name() { 49 | // Arrange 50 | // Act 51 | assertThat(fooRepository.nativeQuery()).isEqualTo("3"); 52 | // Assert 53 | } 54 | 55 | @Test 56 | void pid() { 57 | // Arrange 58 | // Act 59 | String pid = fooRepository.getPid(); 60 | System.out.println("! PID: "+pid+" !"); 61 | // Assert 62 | assertThat(pid).isNotNull(); 63 | } 64 | } -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/main/java/com/jupiter/tools/spring/test/rabbitmq/extension/expected/list/messages/RabbitMqExpectedListOfMessagesExtension.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension.expected.list.messages; 2 | 3 | 4 | import com.jupiter.tools.spring.test.core.expected.list.messages.AssertReceivedMessages; 5 | import com.jupiter.tools.spring.test.core.expected.list.messages.ExpectedMessagesOptions; 6 | import com.jupiter.tools.spring.test.core.expected.list.messages.MessageBroker; 7 | import com.jupiter.tools.spring.test.rabbitmq.annotation.ExpectedMessages; 8 | import org.junit.jupiter.api.extension.AfterEachCallback; 9 | import org.junit.jupiter.api.extension.BeforeAllCallback; 10 | import org.junit.jupiter.api.extension.ExtensionContext; 11 | 12 | import org.springframework.amqp.core.AmqpTemplate; 13 | import org.springframework.test.context.junit.jupiter.SpringExtension; 14 | 15 | /** 16 | * Created on 07.02.2019. 17 | * 18 | * This extension provides an ability to assert sent messages after test execution. 19 | * You can declare a list of expected messages in JSON format. 20 | * 21 | * @author Korovin Anatoliy 22 | */ 23 | public class RabbitMqExpectedListOfMessagesExtension implements BeforeAllCallback, AfterEachCallback { 24 | 25 | private MessageBroker messageBroker; 26 | 27 | @Override 28 | public void afterEach(ExtensionContext context) throws Exception { 29 | 30 | ExpectedMessages expectedMessages = context.getRequiredTestMethod() 31 | .getAnnotation(ExpectedMessages.class); 32 | if (expectedMessages == null) { 33 | return; 34 | } 35 | 36 | ExpectedMessagesOptions options = new ExpectedMessagesMapper(expectedMessages).getOptions(); 37 | new AssertReceivedMessages(options, messageBroker).doAssert(); 38 | } 39 | 40 | @Override 41 | public void beforeAll(ExtensionContext context) throws Exception { 42 | AmqpTemplate amqpTemplate = SpringExtension.getApplicationContext(context) 43 | .getBean(AmqpTemplate.class); 44 | 45 | if (amqpTemplate == null) { 46 | throw new RuntimeException("Not found the JmsTemplate bean in the current spring context."); 47 | } 48 | 49 | messageBroker = new RabbitMqMessageBroker(amqpTemplate); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/EnableRabbitMqTestTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | import com.jupiter.tools.spring.test.rabbitmq.annotation.meta.EnableRabbitMqTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.amqp.core.AmqpTemplate; 6 | import org.springframework.amqp.core.Queue; 7 | import org.springframework.amqp.rabbit.annotation.EnableRabbit; 8 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.TestConfiguration; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.stereotype.Component; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.concurrent.TimeUnit; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.awaitility.Awaitility.await; 20 | 21 | /** 22 | * Created on 23.01.2019. 23 | * 24 | * @author Korovin Anatoliy 25 | */ 26 | @EnableRabbitMqTest 27 | class EnableRabbitMqTestTest { 28 | 29 | @Autowired 30 | private AmqpTemplate amqpTemplate; 31 | 32 | @Test 33 | void testSend() { 34 | // Arrange 35 | // Act 36 | amqpTemplate.convertAndSend("second-test-queue", "123"); 37 | 38 | await().atMost(3, TimeUnit.SECONDS) 39 | .until(() -> TestConfig.events.size() > 0); 40 | 41 | // Asserts 42 | assertThat(TestConfig.events).containsOnly("123"); 43 | } 44 | 45 | @TestConfiguration 46 | public static class TestConfig { 47 | 48 | public static List events = new ArrayList<>(); 49 | 50 | @Bean 51 | public Queue testQueue() { 52 | return new Queue("second-test-queue"); 53 | } 54 | 55 | @Component 56 | @EnableRabbit 57 | public class TestRabbitListener { 58 | 59 | @RabbitListener(queues = "second-test-queue") 60 | public void receive(String message) { 61 | try { 62 | Thread.sleep(1000); 63 | } catch (InterruptedException e) { 64 | e.printStackTrace(); 65 | } 66 | events.add(message); 67 | System.out.println("!!!! " + message); 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/AssertSqlQueryCount.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | import com.jupiter.tools.spring.test.jpa.tracesql.exceptions.SqlQueryCountException; 4 | import com.jupiter.tools.spring.test.jpa.tracesql.exceptions.UndefinedSqlQueryTypeException; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import static com.jupiter.tools.spring.test.jpa.tracesql.QueryCountInfoHolder.getQueryInfo; 9 | 10 | /** 11 | * Created on 15.04.2019. 12 | * 13 | * @author Korovin Anatoliy 14 | */ 15 | public class AssertSqlQueryCount { 16 | 17 | private static Logger log = LoggerFactory.getLogger(AssertSqlQueryCount.class); 18 | 19 | /** 20 | * reset the thread-local counter of current executed queries 21 | */ 22 | public static void reset() { 23 | log.debug("assertSql.reset()"); 24 | getQueryInfo().clear(); 25 | } 26 | 27 | /** 28 | * Assert count of executed queries 29 | * 30 | * @param queryType SQL query type 31 | * @param expectedCount expected count of invocation this type of SQL statements 32 | */ 33 | public static void assertCount(QueryType queryType, int expectedCount) { 34 | assertSqlCount(queryType, expectedCount, getActualQueryCount(queryType)); 35 | } 36 | 37 | 38 | private static int getActualQueryCount(QueryType queryType) { 39 | switch (queryType) { 40 | case CALL: 41 | return getQueryInfo().getCallCount(); 42 | case SELECT: 43 | return getQueryInfo().getSelectCount(); 44 | case DELETE: 45 | return getQueryInfo().getDeleteCount(); 46 | case INSERT: 47 | return getQueryInfo().getInsertCount(); 48 | case UPDATE: 49 | return getQueryInfo().getUpdateCount(); 50 | case OTHER: 51 | return getQueryInfo().getOtherCount(); 52 | default: 53 | throw new UndefinedSqlQueryTypeException("Undefined SQL query type:" + queryType); 54 | } 55 | } 56 | 57 | private static void assertSqlCount(QueryType queryType, int expectedCount, int actualCount) { 58 | log.debug("assertSql.assert({}, {}, {})", queryType, expectedCount, actualCount); 59 | if (expectedCount != actualCount) { 60 | throw new SqlQueryCountException(queryType, expectedCount, actualCount); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonToEmbeddedWebServerTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import com.jupiter.tools.spring.test.web.annotation.EnableEmbeddedWebServerTest; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.TestConfiguration; 8 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | import org.springframework.web.client.RestTemplate; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | /** 22 | * Created on 06.02.2019. 23 | * 24 | * @author Korovin Anatoliy 25 | */ 26 | @EnableEmbeddedWebServerTest 27 | @RedirectRibbonToEmbeddedWebServer 28 | class RedirectRibbonToEmbeddedWebServerTest { 29 | 30 | @Autowired 31 | private RestTemplate restTemplate; 32 | 33 | @Test 34 | void anyClientNamesRedirectToEmbedded() { 35 | String message = "test-message"; 36 | // Act 37 | String size = restTemplate.getForObject("http://any-service-name/messages/{message}/size", 38 | String.class, 39 | message); 40 | // Assert 41 | assertThat(TestCfg.messages).containsOnly(message); 42 | assertThat(Integer.valueOf(size)).isEqualTo(message.length()); 43 | } 44 | 45 | @TestConfiguration 46 | public static class TestCfg { 47 | 48 | static List messages = new ArrayList<>(); 49 | 50 | @Bean 51 | @LoadBalanced 52 | public RestTemplate restTemplate() { 53 | return new RestTemplate(); 54 | } 55 | 56 | @RestController 57 | @RequestMapping("/messages") 58 | public class TestApi { 59 | 60 | @GetMapping("/{message}/size") 61 | public String getLength(@PathVariable("message") String message) { 62 | messages.add(message); 63 | return String.valueOf(message.length()); 64 | } 65 | } 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/RabbitMqTcExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | import org.springframework.amqp.core.AmqpTemplate; 11 | import org.springframework.amqp.core.Queue; 12 | import org.springframework.amqp.rabbit.annotation.EnableRabbit; 13 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.test.context.SpringBootTest; 16 | import org.springframework.boot.test.context.TestConfiguration; 17 | import org.springframework.context.annotation.Bean; 18 | import org.springframework.stereotype.Component; 19 | import org.springframework.test.context.junit.jupiter.SpringExtension; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.awaitility.Awaitility.await; 23 | 24 | /** 25 | * Created on 23.01.2019. 26 | * 27 | * @author Korovin Anatoliy 28 | */ 29 | @SpringBootTest 30 | @ExtendWith(SpringExtension.class) 31 | @ExtendWith(RabbitMqTcExtension.class) 32 | class RabbitMqTcExtensionTest { 33 | 34 | @Autowired 35 | private AmqpTemplate amqpTemplate; 36 | 37 | @Test 38 | void testSend() { 39 | // Arrange 40 | // Act 41 | amqpTemplate.convertAndSend("test-queue-with-listener", "123"); 42 | 43 | await().atMost(3, TimeUnit.SECONDS) 44 | .until(() -> TestConfig.events.size() > 0); 45 | 46 | // Asserts 47 | assertThat(TestConfig.events).containsOnly("123"); 48 | } 49 | 50 | @TestConfiguration 51 | public static class TestConfig { 52 | 53 | public static List events = new ArrayList<>(); 54 | 55 | @Bean 56 | public Queue testQueue() { 57 | return new Queue("test-queue-with-listener"); 58 | } 59 | 60 | @Component 61 | @EnableRabbit 62 | public class TestRabbitListener { 63 | 64 | @RabbitListener(queues = "test-queue-with-listener") 65 | public void receive(String message) { 66 | try { 67 | Thread.sleep(1000); 68 | } 69 | catch (InterruptedException e) { 70 | e.printStackTrace(); 71 | } 72 | events.add(message); 73 | System.out.println("!!!! " + message); 74 | } 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /spring-test-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-core 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-core 17 | JUnit5 utils and extensions to make integration tests with Spring 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 2.11.0 24 | ${jackson.version} 25 | ${jackson.version} 26 | 27 | 28 | 29 | 30 | commons-io 31 | commons-io 32 | 2.4 33 | 34 | 35 | com.fasterxml.jackson.core 36 | jackson-databind 37 | ${jackson.version.databind} 38 | compile 39 | 40 | 41 | 42 | org.projectlombok 43 | lombok 44 | 45 | 46 | 47 | com.jupiter-tools 48 | datasetroll 49 | 0.1 50 | 51 | 52 | 53 | 54 | 55 | 56 | ${project.basedir}/src/main/resources 57 | true 58 | 59 | 60 | 61 | 62 | ${project.basedir}/src/test/resources 63 | true 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/EnableActiveMqTestContainersTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import com.jupiter.tools.spring.test.activemq.annotation.EnableActiveMqTestContainers; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import org.springframework.amqp.core.Queue; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.boot.test.context.TestConfiguration; 15 | import org.springframework.context.annotation.Bean; 16 | import org.springframework.jms.annotation.EnableJms; 17 | import org.springframework.jms.annotation.JmsListener; 18 | import org.springframework.jms.core.JmsTemplate; 19 | import org.springframework.stereotype.Component; 20 | import org.springframework.test.context.junit.jupiter.SpringExtension; 21 | 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | import static org.awaitility.Awaitility.await; 24 | 25 | /** 26 | * Created on 07.08.2018. 27 | * 28 | * @author Korovin Anatoliy 29 | */ 30 | @SpringBootTest 31 | @ExtendWith(SpringExtension.class) 32 | @EnableActiveMqTestContainers 33 | public class EnableActiveMqTestContainersTest { 34 | 35 | @Autowired 36 | private JmsTemplate jmsTemplate; 37 | 38 | @Test 39 | void testSend() { 40 | // Act 41 | jmsTemplate.convertAndSend("simple-queue", "123"); 42 | 43 | await().atMost(3, TimeUnit.SECONDS) 44 | .until(() -> TestConfig.events.size() > 0); 45 | // Asserts 46 | assertThat(TestConfig.events).containsOnly("123"); 47 | } 48 | 49 | @TestConfiguration 50 | public static class TestConfig { 51 | 52 | public static List events = new ArrayList<>(); 53 | 54 | @Bean 55 | public Queue testQueue() { 56 | return new Queue("simple-queue"); 57 | } 58 | 59 | @Component 60 | @EnableJms 61 | public class TestListener { 62 | 63 | @JmsListener(destination = "simple-queue") 64 | public void processMessage(String message) { 65 | try { 66 | Thread.sleep(1000); 67 | } 68 | catch (InterruptedException e) { 69 | e.printStackTrace(); 70 | } 71 | events.add(message); 72 | System.out.println("!!!! " + message); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/extension/TransactionalTestConfig.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import lombok.*; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.domain.EntityScan; 7 | import org.springframework.boot.test.context.TestConfiguration; 8 | import org.springframework.data.jpa.repository.JpaRepository; 9 | import org.springframework.data.jpa.repository.Query; 10 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 11 | import org.springframework.stereotype.Repository; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.transaction.annotation.Isolation; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | import javax.persistence.Column; 17 | import javax.persistence.Entity; 18 | import javax.persistence.GeneratedValue; 19 | import javax.persistence.Id; 20 | 21 | /** 22 | * Created on 12.07.2018. 23 | * 24 | * Transaction Persistence layer configuration, 25 | * for testing transactional methods in wrappers and service. 26 | * 27 | * @author Korovin Anatoliy 28 | */ 29 | @SpringBootApplication 30 | @TestConfiguration 31 | @EnableJpaRepositories(considerNestedRepositories = true) 32 | @EntityScan(basePackageClasses = {TransactionalTestConfig.class}) 33 | public class TransactionalTestConfig { 34 | 35 | @Repository 36 | public interface FooRepository extends JpaRepository { 37 | @Query(value = "call RAND() *1000", nativeQuery = true) 38 | long rand(); 39 | } 40 | 41 | @Entity 42 | @Setter 43 | @Getter 44 | @Builder 45 | @NoArgsConstructor 46 | @AllArgsConstructor 47 | public static class Foo { 48 | @Id 49 | @GeneratedValue 50 | private Long id; 51 | 52 | @Column(nullable = false) 53 | private String field; 54 | } 55 | 56 | @Service 57 | public class TestService { 58 | @Autowired 59 | private FooRepository fooRepository; 60 | 61 | @Transactional 62 | public Foo ok() { 63 | Foo foo = new Foo(); 64 | foo.setField("tru la la.."); 65 | return fooRepository.save(foo); 66 | } 67 | 68 | @Transactional 69 | public void fail() { 70 | fooRepository.save(new Foo()); 71 | } 72 | 73 | @Transactional(readOnly = true) 74 | public long size() { 75 | return fooRepository.count(); 76 | } 77 | 78 | @Transactional(isolation = Isolation.SERIALIZABLE) 79 | public void clear() { 80 | fooRepository.deleteAll(); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /spring-test-mysql/src/test/java/com/jupiter/tools/spring/test/mysql/TransactionalTestConfig.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql; 2 | 3 | import lombok.*; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.domain.EntityScan; 7 | import org.springframework.boot.test.context.TestConfiguration; 8 | import org.springframework.data.jpa.repository.JpaRepository; 9 | import org.springframework.data.jpa.repository.Query; 10 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 11 | import org.springframework.stereotype.Repository; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.transaction.annotation.Isolation; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | import javax.persistence.Column; 17 | import javax.persistence.Entity; 18 | import javax.persistence.GeneratedValue; 19 | import javax.persistence.Id; 20 | import javax.persistence.Table; 21 | 22 | /** 23 | * Created on 12.07.2018. 24 | * 25 | * Transaction Persistence layer configuration, 26 | * for testing transactional methods in wrappers and service. 27 | * 28 | * @author Korovin Anatoliy 29 | */ 30 | @SpringBootApplication 31 | @TestConfiguration 32 | @EnableJpaRepositories(considerNestedRepositories = true) 33 | @EntityScan(basePackageClasses = {TransactionalTestConfig.class}) 34 | public class TransactionalTestConfig { 35 | 36 | @Repository 37 | public interface FooRepository extends JpaRepository { 38 | @Query(value = "SELECT JSON_OBJECT('id', 87, 'name', 'prime')", nativeQuery = true) 39 | String nativeJson(); 40 | } 41 | 42 | @Table(name = "foo") 43 | @Entity 44 | @Setter 45 | @Getter 46 | @Builder 47 | @NoArgsConstructor 48 | @AllArgsConstructor 49 | public static class Foo { 50 | @Id 51 | @GeneratedValue 52 | private Long id; 53 | 54 | @Column(nullable = false) 55 | private String field; 56 | } 57 | 58 | @Service 59 | public class TestService { 60 | @Autowired 61 | private FooRepository fooRepository; 62 | 63 | @Transactional 64 | public Foo ok() { 65 | Foo foo = new Foo(); 66 | foo.setField("tru la la.."); 67 | return fooRepository.save(foo); 68 | } 69 | 70 | @Transactional 71 | public void fail() { 72 | fooRepository.save(new Foo()); 73 | } 74 | 75 | @Transactional(readOnly = true) 76 | public long size() { 77 | return fooRepository.count(); 78 | } 79 | 80 | @Transactional(isolation = Isolation.SERIALIZABLE) 81 | public void clear() { 82 | fooRepository.deleteAll(); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /spring-test-mysql/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-mysql 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-mysql 17 | JUnit5 utils and extensions to make integration tests for MySQL with Spring 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-jpa 29 | provided 30 | 31 | 32 | com.jupiter-tools 33 | spring-test-jpa 34 | ${parent.version} 35 | 36 | 37 | 38 | 39 | org.testcontainers 40 | mysql 41 | 1.11.4 42 | compile 43 | 44 | 45 | 46 | 47 | 48 | mysql 49 | mysql-connector-java 50 | 5.1.47 51 | provided 52 | 53 | 54 | 55 | 56 | org.projectlombok 57 | lombok 58 | test 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | ${project.basedir}/src/main/resources 67 | true 68 | 69 | 70 | 71 | 72 | ${project.basedir}/src/test/resources 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /spring-test-web/src/test/java/com/jupiter/tools/spring/test/web/extension/ribbon/RedirectRibbonExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.web.extension.ribbon; 2 | 3 | import com.jupiter.tools.spring.test.web.annotation.EnableEmbeddedWebServerTest; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.TestConfiguration; 8 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | import org.springframework.web.client.RestTemplate; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | /** 22 | * Created on 06.02.2019. 23 | * 24 | * @author Korovin Anatoliy 25 | */ 26 | @EnableEmbeddedWebServerTest 27 | @RedirectRibbonToEmbeddedWebServer("test-service") 28 | class RedirectRibbonExtensionTest { 29 | 30 | @Autowired 31 | private RestTemplate restTemplate; 32 | 33 | @Test 34 | void testRedirect() { 35 | String message = "test-message"; 36 | // Act 37 | String size = restTemplate.getForObject("http://test-service/messages/{message}/size", 38 | String.class, 39 | message); 40 | // Assert 41 | assertThat(TestCfg.messages).containsOnly(message); 42 | assertThat(Integer.valueOf(size)).isEqualTo(message.length()); 43 | } 44 | 45 | @Test 46 | void testRedirectToUnknownClient() { 47 | // Act 48 | Assertions.assertThrows(Exception.class, 49 | () -> restTemplate.getForObject("http://foo-service/messages/{message}/size", 50 | String.class, 51 | "test-message")); 52 | } 53 | 54 | @TestConfiguration 55 | public static class TestCfg { 56 | 57 | static List messages = new ArrayList<>(); 58 | 59 | @Bean 60 | @LoadBalanced 61 | public RestTemplate restTemplate() { 62 | return new RestTemplate(); 63 | } 64 | 65 | @RestController 66 | @RequestMapping("/messages") 67 | public class TestApi { 68 | 69 | @GetMapping("/{message}/size") 70 | public String getLength(@PathVariable("message") String message) { 71 | messages.add(message); 72 | return String.valueOf(message.length()); 73 | } 74 | } 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /spring-test-postgres/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-postgres 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-postgres 17 | JUnit5 utils and extensions to make integration tests for PostgreSQL with Spring 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 3.3.2 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | provided 31 | 32 | 33 | 34 | com.jupiter-tools 35 | spring-test-jpa 36 | ${parent.version} 37 | 38 | 39 | 40 | 41 | org.testcontainers 42 | postgresql 43 | 1.11.4 44 | compile 45 | 46 | 47 | 48 | 49 | 50 | org.postgresql 51 | postgresql 52 | provided 53 | 54 | 55 | 56 | 57 | org.projectlombok 58 | lombok 59 | test 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | ${project.basedir}/src/main/resources 70 | true 71 | 72 | 73 | 74 | 75 | ${project.basedir}/src/test/resources 76 | true 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /spring-test-jpa/src/main/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryCountInfoHandler.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * Created on 12/6/15 8 | * 9 | * @author Igor Dmitriev 10 | * @author Mikalai Alimenkou 11 | * @author Korovin Anatoliy 12 | */ 13 | public class QueryCountInfoHandler implements QueryHandler { 14 | 15 | private static Logger log = LoggerFactory.getLogger(QueryCountInfoHandler.class); 16 | 17 | @Override 18 | public void handleSql(String sql) { 19 | QueryType queryType = getQueryType(sql); 20 | QueryCountInfo queryCountInfo = QueryCountInfoHolder.getQueryInfo(); 21 | log.debug("assertSql.handle({})", queryType); 22 | switch (queryType) { 23 | case SELECT: 24 | queryCountInfo.incrementSelectCount(); 25 | break; 26 | case INSERT: 27 | queryCountInfo.incrementInsertCount(); 28 | break; 29 | case UPDATE: 30 | queryCountInfo.incrementUpdateCount(); 31 | break; 32 | case DELETE: 33 | queryCountInfo.incrementDeleteCount(); 34 | break; 35 | case CALL: 36 | queryCountInfo.incrementCallCount(); 37 | break; 38 | case OTHER: 39 | queryCountInfo.incrementOtherCount(); 40 | break; 41 | default: 42 | throw new IllegalArgumentException("There is no QueryType handler:" + queryType); 43 | } 44 | } 45 | 46 | protected QueryType getQueryType(String query) { 47 | query = query.toLowerCase(); 48 | final String trimmedQuery = removeRedundantSymbols(query); 49 | final char firstChar = trimmedQuery.charAt(0); 50 | 51 | final QueryType type; 52 | switch (firstChar) { 53 | case 'w': // query can be started 'with' 54 | case 's': 55 | type = QueryType.SELECT; 56 | break; 57 | case 'i': 58 | type = QueryType.INSERT; 59 | break; 60 | case 'u': 61 | type = QueryType.UPDATE; 62 | break; 63 | case 'd': 64 | type = QueryType.DELETE; 65 | break; 66 | case 'c': 67 | case '?': 68 | type = QueryType.CALL; 69 | break; 70 | default: 71 | log.warn("Unknown QueryType handle by StatementInspector: "+query); 72 | type = QueryType.OTHER; 73 | } 74 | return type; 75 | } 76 | 77 | private String removeRedundantSymbols(String query) { 78 | return query.replaceAll("--.*\n", "") 79 | .replaceAll("\n", "") 80 | .replaceAll("/\\*.*\\*/", "") 81 | .trim(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /spring-test-mysql/src/test/java/com/jupiter/tools/spring/test/mysql/extension/MySqlTcExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.mysql.extension; 2 | 3 | import com.github.database.rider.core.api.dataset.DataSet; 4 | import com.github.database.rider.core.api.dataset.DataSetFormat; 5 | import com.github.database.rider.core.api.dataset.ExpectedDataSet; 6 | import com.github.database.rider.core.api.exporter.ExportDataSet; 7 | import com.github.database.rider.spring.api.DBRider; 8 | import com.jupiter.tools.spring.test.jpa.extension.TraceSqlExtension; 9 | import com.jupiter.tools.spring.test.mysql.TransactionalTestConfig; 10 | import org.junit.jupiter.api.Disabled; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 15 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 16 | import org.springframework.context.annotation.Import; 17 | import org.springframework.test.annotation.Commit; 18 | import org.springframework.test.context.junit.jupiter.SpringExtension; 19 | import org.springframework.transaction.annotation.Propagation; 20 | import org.springframework.transaction.annotation.Transactional; 21 | 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | 24 | /** 25 | * Created on 25.01.2019. 26 | * 27 | * @author Korovin Anatoliy 28 | */ 29 | @DataJpaTest 30 | @DBRider 31 | @ExtendWith(SpringExtension.class) 32 | @ExtendWith(MySqlTcExtension.class) 33 | @ExtendWith(TraceSqlExtension.class) 34 | @Import(TransactionalTestConfig.class) 35 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 36 | class MySqlTcExtensionTest { 37 | 38 | @Autowired 39 | private TransactionalTestConfig.FooRepository repository; 40 | 41 | @Test 42 | @Commit 43 | @DataSet(cleanBefore = true, cleanAfter = true) 44 | @ExpectedDataSet(value = "/datasets/expected.json", ignoreCols = "ID") 45 | void testCreate() throws Exception { 46 | 47 | repository.saveAndFlush(TransactionalTestConfig.Foo.builder() 48 | .field("tru la la..") 49 | .build()); 50 | } 51 | 52 | @Disabled 53 | @Test 54 | @Commit 55 | @DataSet(cleanBefore = true, cleanAfter = true) 56 | @Transactional(propagation = Propagation.NOT_SUPPORTED) 57 | @ExportDataSet(outputName = "target/dataset/export.json", format = DataSetFormat.JSON) 58 | void generate() throws Exception { 59 | 60 | repository.save(TransactionalTestConfig.Foo.builder() 61 | .field("tru la la..") 62 | .build()); 63 | } 64 | 65 | @Test 66 | @DataSet(cleanBefore = true, cleanAfter = true) 67 | void nativeJson() { 68 | assertThat(repository.nativeJson()).isNotNull(); 69 | } 70 | } -------------------------------------------------------------------------------- /spring-test-postgres/src/test/java/com/jupiter/tools/spring/test/postgres/TransactionalTestConfig.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.postgres; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Builder; 10 | import lombok.Getter; 11 | import lombok.NoArgsConstructor; 12 | import lombok.Setter; 13 | 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.autoconfigure.SpringBootApplication; 16 | import org.springframework.boot.autoconfigure.domain.EntityScan; 17 | import org.springframework.boot.test.context.TestConfiguration; 18 | import org.springframework.data.jpa.repository.JpaRepository; 19 | import org.springframework.data.jpa.repository.Query; 20 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 21 | import org.springframework.stereotype.Repository; 22 | import org.springframework.stereotype.Service; 23 | import org.springframework.transaction.annotation.Isolation; 24 | import org.springframework.transaction.annotation.Transactional; 25 | 26 | /** 27 | * Created on 12.07.2018. 28 | * 29 | * Transaction Persistence layer configuration, 30 | * for testing transactional methods in wrappers and service. 31 | * 32 | * @author Korovin Anatoliy 33 | */ 34 | @SpringBootApplication 35 | @TestConfiguration 36 | @EnableJpaRepositories(considerNestedRepositories = true) 37 | @EntityScan(basePackageClasses = {TransactionalTestConfig.class}) 38 | public class TransactionalTestConfig { 39 | 40 | @Repository 41 | public interface FooRepository extends JpaRepository { 42 | @Query(value = "SELECT octet_length('123')", nativeQuery = true) 43 | String nativeQuery(); 44 | 45 | @Query(value = "SELECT pg_backend_pid()", nativeQuery = true) 46 | String getPid(); 47 | } 48 | 49 | @Entity 50 | @Setter 51 | @Getter 52 | @Builder 53 | @NoArgsConstructor 54 | @AllArgsConstructor 55 | public static class Foo { 56 | @Id 57 | @GeneratedValue 58 | private Long id; 59 | 60 | @Column(nullable = false) 61 | private String field; 62 | } 63 | 64 | @Service 65 | public class TestService { 66 | @Autowired 67 | private FooRepository fooRepository; 68 | 69 | @Transactional 70 | public Foo ok() { 71 | Foo foo = new Foo(); 72 | foo.setField("tru la la.."); 73 | return fooRepository.save(foo); 74 | } 75 | 76 | @Transactional 77 | public void fail() { 78 | fooRepository.save(new Foo()); 79 | } 80 | 81 | @Transactional(readOnly = true) 82 | public long size() { 83 | return fooRepository.count(); 84 | } 85 | 86 | @Transactional(isolation = Isolation.SERIALIZABLE) 87 | public void clear() { 88 | fooRepository.deleteAll(); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/expected/list/messages/ExpectedListOfMessagesTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages; 4 | import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest; 5 | import com.jupiter.tools.spring.test.activemq.extension.expected.Bar; 6 | import com.jupiter.tools.spring.test.activemq.extension.expected.Foo; 7 | import com.jupiter.tools.spring.test.activemq.extension.expected.list.messages.ActiveMqExpectedListOfMessagesExtension; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import org.springframework.amqp.core.Queue; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.boot.test.context.TestConfiguration; 15 | import org.springframework.context.annotation.Bean; 16 | import org.springframework.jms.core.JmsTemplate; 17 | import org.springframework.jms.support.converter.MappingJackson2MessageConverter; 18 | import org.springframework.jms.support.converter.MessageConverter; 19 | import org.springframework.jms.support.converter.MessageType; 20 | 21 | /** 22 | * Created on 07.08.2018. 23 | * 24 | * @author Korovin Anatoliy 25 | */ 26 | @SpringBootTest 27 | @EnableActiveMqTest 28 | @ExtendWith(ActiveMqExpectedListOfMessagesExtension.class) 29 | public class ExpectedListOfMessagesTest { 30 | 31 | @Autowired 32 | private JmsTemplate jmsTemplate; 33 | 34 | @Test 35 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages.json") 36 | void testSend() { 37 | jmsTemplate.convertAndSend("test-queue", new Foo("123")); 38 | jmsTemplate.convertAndSend("test-queue", new Foo("456")); 39 | jmsTemplate.convertAndSend("test-queue", new Foo("789")); 40 | } 41 | 42 | @Test 43 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_multiple_types.json") 44 | void sendMultipleTypes() { 45 | // first type: 46 | jmsTemplate.convertAndSend("test-queue", new Foo("123")); 47 | // second type: 48 | jmsTemplate.convertAndSend("test-queue", new Bar("AAA", 1)); 49 | jmsTemplate.convertAndSend("test-queue", new Bar("BBB",2)); 50 | jmsTemplate.convertAndSend("test-queue", new Bar("CCC",3)); 51 | } 52 | 53 | @TestConfiguration 54 | public static class TestConfig { 55 | @Bean 56 | public Queue testQueue() { 57 | return new Queue("test-queue"); 58 | } 59 | 60 | @Bean // Serialize message content to json using TextMessage 61 | public MessageConverter jacksonJmsMessageConverter() { 62 | MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); 63 | converter.setTargetType(MessageType.TEXT); 64 | converter.setTypeIdPropertyName("_type"); 65 | return converter; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /spring-test-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-web 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-web 17 | JUnit5 utils and extensions to make integration tests with REST API 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 1.11.4 24 | 25 | Greenwich.RELEASE 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-dependencies 33 | ${spring-cloud.version} 34 | pom 35 | import 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | com.jupiter-tools 44 | spring-test-core 45 | ${parent.version} 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-web 51 | provided 52 | 53 | 54 | org.springframework.cloud 55 | spring-cloud-starter-netflix-ribbon 56 | 57 | 58 | 59 | org.springframework.cloud 60 | spring-cloud-starter-openfeign 61 | test 62 | 63 | 64 | 65 | 66 | 67 | 68 | ${project.basedir}/src/main/resources 69 | true 70 | 71 | 72 | 73 | 74 | ${project.basedir}/src/test/resources 75 | true 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-rabbitmq 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-rabbitmq 17 | JUnit5 utils and extensions to make integration tests for RabbitMq with Spring 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 1.11.4 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-amqp 31 | provided 32 | 33 | 34 | 35 | 36 | 37 | com.jupiter-tools 38 | spring-test-core 39 | ${parent.version} 40 | 41 | 42 | 43 | 44 | 45 | org.testcontainers 46 | testcontainers 47 | ${test.containers.version} 48 | compile 49 | 50 | 51 | 52 | 53 | 54 | org.awaitility 55 | awaitility 56 | 3.1.0 57 | 58 | 59 | 60 | 61 | 62 | org.projectlombok 63 | lombok 64 | test 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | ${project.basedir}/src/main/resources 74 | true 75 | 76 | 77 | 78 | 79 | ${project.basedir}/src/test/resources 80 | true 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/expected/list/messages/ActiveMqExpectedListOfMessagesExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension.expected.list.messages; 2 | 3 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages; 4 | import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest; 5 | import com.jupiter.tools.spring.test.activemq.extension.expected.Foo; 6 | import com.jupiter.tools.spring.test.activemq.extension.expected.list.messages.ActiveMqExpectedListOfMessagesExtension; 7 | import org.junit.jupiter.api.Disabled; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import org.springframework.amqp.core.Queue; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.TestConfiguration; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.jms.core.JmsTemplate; 16 | import org.springframework.jms.support.converter.MappingJackson2MessageConverter; 17 | import org.springframework.jms.support.converter.MessageConverter; 18 | import org.springframework.jms.support.converter.MessageType; 19 | 20 | /** 21 | * Created on 26.03.2019. 22 | * 23 | * @author Korovin Anatoliy 24 | */ 25 | @EnableActiveMqTest 26 | @ExtendWith(ActiveMqExpectedListOfMessagesExtension.class) 27 | class ActiveMqExpectedListOfMessagesExtensionTest { 28 | 29 | @Autowired 30 | private JmsTemplate jmsTemplate; 31 | 32 | @Test 33 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_empty_list.json") 34 | void testEmptyListInFile() { 35 | //NOP 36 | } 37 | 38 | @Test 39 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_empty_file.json") 40 | void testEmptyFile() { 41 | //NOP 42 | } 43 | 44 | @Disabled("TODO: find a way to test exceptions in extensions") 45 | @Test 46 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_empty_list.json") 47 | void testEmptyListInFileWithUnexpectedSending() { 48 | jmsTemplate.convertAndSend("test-queue", new Foo("789")); 49 | } 50 | 51 | @Disabled("TODO: find a way to test exceptions in extensions") 52 | @Test 53 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_empty_file.json") 54 | void testEmptyFileWithUnexpectedSending() { 55 | jmsTemplate.convertAndSend("test-queue", new Foo("789")); 56 | } 57 | 58 | @TestConfiguration 59 | public static class TestConfig { 60 | @Bean 61 | public Queue testQueue() { 62 | return new Queue("test-queue"); 63 | } 64 | 65 | @Bean // Serialize message content to json using TextMessage 66 | public MessageConverter jacksonJmsMessageConverter() { 67 | MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); 68 | converter.setTargetType(MessageType.TEXT); 69 | converter.setTypeIdPropertyName("_type"); 70 | return converter; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /spring-test-jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-jpa 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-jpa 17 | JUnit5 utils and extensions to make integration tests on JPA with Spring 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 24 | 25 | 26 | 27 | 28 | 29 | com.jupiter-tools 30 | spring-test-core 31 | ${parent.version} 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-data-jpa 38 | provided 39 | 40 | 41 | 42 | org.projectlombok 43 | lombok 44 | test 45 | 46 | 47 | 48 | com.h2database 49 | h2 50 | test 51 | 52 | 53 | 54 | 55 | com.github.database-rider 56 | rider-spring 57 | 1.7.2 58 | compile 59 | 60 | 61 | org.slf4j 62 | slf4j-api 63 | 64 | 65 | org.slf4j 66 | slf4j-simple 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | ${project.basedir}/src/main/resources 77 | true 78 | 79 | 80 | 81 | 82 | ${project.basedir}/src/test/resources 83 | true 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /spring-test-activemq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.jupiter-tools 8 | spring-boot-extensions-parent 9 | 0.4 10 | 11 | 12 | spring-test-activemq 13 | ${parent.version} 14 | jar 15 | 16 | spring-test-activemq 17 | JUnit5 utils and extensions to make integration tests for ActiveMQ with Spring 18 | 19 | 20 | UTF-8 21 | UTF-8 22 | 1.8 23 | 1.11.4 24 | 25 | 26 | 27 | 28 | 29 | com.jupiter-tools 30 | spring-test-core 31 | ${parent.version} 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-activemq 39 | provided 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-amqp 44 | test 45 | 46 | 47 | 48 | 49 | 50 | org.testcontainers 51 | testcontainers 52 | ${test.containers.version} 53 | compile 54 | 55 | 56 | 57 | 58 | 59 | org.awaitility 60 | awaitility 61 | 3.1.0 62 | 63 | 64 | 65 | 66 | org.projectlombok 67 | lombok 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | ${project.basedir}/src/main/resources 77 | true 78 | 79 | 80 | 81 | 82 | ${project.basedir}/src/test/resources 83 | true 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/tracesql/QueryCountInfoTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.tracesql; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | import static org.junit.jupiter.api.Assertions.*; 7 | 8 | /** 9 | * Created on 27.01.2019. 10 | * 11 | * @author Korovin Anatoliy 12 | */ 13 | class QueryCountInfoTest { 14 | 15 | @Test 16 | void incrementSelectCount() { 17 | // Arrange 18 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 19 | assertThat(queryCountInfo.getSelectCount()).isEqualTo(0); 20 | // Act 21 | queryCountInfo.incrementSelectCount(); 22 | // Asserts 23 | assertThat(queryCountInfo.getSelectCount()).isEqualTo(1); 24 | } 25 | 26 | @Test 27 | void incrementInsertCount() { 28 | // Arrange 29 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 30 | assertThat(queryCountInfo.getInsertCount()).isEqualTo(0); 31 | // Act 32 | queryCountInfo.incrementInsertCount(); 33 | // Asserts 34 | assertThat(queryCountInfo.getInsertCount()).isEqualTo(1); 35 | } 36 | 37 | @Test 38 | void incrementUpdateCount() { 39 | // Arrange 40 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 41 | assertThat(queryCountInfo.getUpdateCount()).isEqualTo(0); 42 | // Act 43 | queryCountInfo.incrementUpdateCount(); 44 | // Asserts 45 | assertThat(queryCountInfo.getUpdateCount()).isEqualTo(1); 46 | } 47 | 48 | @Test 49 | void incrementDeleteCount() { 50 | // Arrange 51 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 52 | assertThat(queryCountInfo.getDeleteCount()).isEqualTo(0); 53 | // Act 54 | queryCountInfo.incrementDeleteCount(); 55 | // Asserts 56 | assertThat(queryCountInfo.getDeleteCount()).isEqualTo(1); 57 | } 58 | 59 | @Test 60 | void incrementCallCount() { 61 | // Arrange 62 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 63 | assertThat(queryCountInfo.getCallCount()).isEqualTo(0); 64 | // Act 65 | queryCountInfo.incrementCallCount(); 66 | // Asserts 67 | assertThat(queryCountInfo.getCallCount()).isEqualTo(1); 68 | } 69 | 70 | @Test 71 | void incrementOtherCount() { 72 | // Arrange 73 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 74 | assertThat(queryCountInfo.getOtherCount()).isEqualTo(0); 75 | // Act 76 | queryCountInfo.incrementOtherCount(); 77 | // Asserts 78 | assertThat(queryCountInfo.getOtherCount()).isEqualTo(1); 79 | } 80 | 81 | @Test 82 | void clear() { 83 | // Arrange 84 | QueryCountInfo queryCountInfo = new QueryCountInfo(); 85 | queryCountInfo.incrementInsertCount(); 86 | queryCountInfo.incrementOtherCount(); 87 | queryCountInfo.incrementCallCount(); 88 | queryCountInfo.incrementDeleteCount(); 89 | queryCountInfo.incrementUpdateCount(); 90 | queryCountInfo.incrementSelectCount(); 91 | // Act 92 | queryCountInfo.clear(); 93 | // Asserts 94 | assertThat(queryCountInfo.getCallCount()).isEqualTo(0); 95 | assertThat(queryCountInfo.getOtherCount()).isEqualTo(0); 96 | assertThat(queryCountInfo.getDeleteCount()).isEqualTo(0); 97 | assertThat(queryCountInfo.getUpdateCount()).isEqualTo(0); 98 | assertThat(queryCountInfo.getInsertCount()).isEqualTo(0); 99 | assertThat(queryCountInfo.getSelectCount()).isEqualTo(0); 100 | } 101 | } -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/extension/ExpectedSqlExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import com.jupiter.tools.spring.test.jpa.annotation.ExpectedSqlQuery; 7 | import com.jupiter.tools.spring.test.jpa.tracesql.AssertSqlQueryCount; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.test.context.junit.jupiter.SpringExtension; 17 | 18 | import static com.jupiter.tools.spring.test.jpa.tracesql.QueryType.CALL; 19 | import static com.jupiter.tools.spring.test.jpa.tracesql.QueryType.DELETE; 20 | import static com.jupiter.tools.spring.test.jpa.tracesql.QueryType.INSERT; 21 | import static com.jupiter.tools.spring.test.jpa.tracesql.QueryType.SELECT; 22 | import static com.jupiter.tools.spring.test.jpa.tracesql.QueryType.UPDATE; 23 | import static org.assertj.core.api.Assertions.assertThat; 24 | 25 | /** 26 | * Created on 26.01.2019. 27 | * 28 | * @author Korovin Anatoliy 29 | */ 30 | @ExtendWith(SpringExtension.class) 31 | @SpringBootTest 32 | @Import(TransactionalTestConfig.class) 33 | class ExpectedSqlExtensionTest { 34 | 35 | @Autowired 36 | private TransactionalTestConfig.FooRepository fooRepository; 37 | 38 | @BeforeEach 39 | void setUp() { 40 | fooRepository.deleteAll(); 41 | AssertSqlQueryCount.reset(); 42 | } 43 | 44 | @Test 45 | @ExpectedSqlQuery(type = INSERT, count = 1) 46 | void testInsert() { 47 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 48 | } 49 | 50 | @Test 51 | @ExpectedSqlQuery(type = SELECT, count = 1) 52 | void testSelect() { 53 | fooRepository.findAll(); 54 | } 55 | 56 | @Test 57 | @ExpectedSqlQuery(type = UPDATE, count = 1) 58 | void testUpdate() { 59 | // Arrange 60 | TransactionalTestConfig.Foo foo = 61 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 62 | 63 | foo.setField("up"); 64 | // Act 65 | fooRepository.save(foo); 66 | } 67 | 68 | 69 | @Test 70 | @ExpectedSqlQuery(type = DELETE, count = 1) 71 | void testDelete() { 72 | // Arrange 73 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 74 | // Act 75 | fooRepository.deleteAll(); 76 | } 77 | 78 | @Test 79 | @ExpectedSqlQuery(type = CALL, count = 1) 80 | void testCall() { 81 | // Act 82 | fooRepository.rand(); 83 | } 84 | 85 | @Test 86 | @ExpectedSqlQuery(type = CALL, count = 10) 87 | void testCallSeq() { 88 | // Arrange 89 | Set rands = new HashSet<>(); 90 | // Act 91 | for (int i = 0; i < 10; i++) { 92 | rands.add(fooRepository.rand()); 93 | } 94 | // Asserts 95 | assertThat(rands.size() > 3).isTrue(); 96 | } 97 | 98 | @Test 99 | @ExpectedSqlQuery(type = UPDATE, count = 1) 100 | @ExpectedSqlQuery(type = SELECT, count = 3) 101 | void testRepeatableAnnotations() { 102 | // Arrange 103 | TransactionalTestConfig.Foo foo = 104 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 105 | 106 | foo.setField("up"); 107 | // UPDATE 108 | fooRepository.save(foo); 109 | // SELECT 110 | fooRepository.findAll(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /spring-test-activemq/src/test/java/com/jupiter/tools/spring/test/activemq/extension/ActiveMqSmartDataSetTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.activemq.extension; 2 | 3 | import java.util.Date; 4 | 5 | import com.jupiter.tools.spring.test.activemq.annotation.ExpectedMessages; 6 | import com.jupiter.tools.spring.test.activemq.annotation.meta.EnableActiveMqTest; 7 | import com.jupiter.tools.spring.test.activemq.extension.expected.Bar; 8 | import com.jupiter.tools.spring.test.activemq.extension.expected.Foo; 9 | import com.jupiter.tools.spring.test.activemq.extension.expected.FooWithBar; 10 | import org.junit.jupiter.api.Test; 11 | 12 | import org.springframework.amqp.core.Queue; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.TestConfiguration; 15 | import org.springframework.context.annotation.Bean; 16 | import org.springframework.jms.core.JmsTemplate; 17 | import org.springframework.jms.support.converter.MappingJackson2MessageConverter; 18 | import org.springframework.jms.support.converter.MessageConverter; 19 | import org.springframework.jms.support.converter.MessageType; 20 | 21 | /** 22 | * Created on 25.03.2019. 23 | * 24 | * @author Korovin Anatoliy 25 | */ 26 | @EnableActiveMqTest 27 | public class ActiveMqSmartDataSetTest { 28 | 29 | @Autowired 30 | private JmsTemplate jmsTemplate; 31 | 32 | @Test 33 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages.json") 34 | void testSendListOfMessages() { 35 | jmsTemplate.convertAndSend("test-queue", new Foo("123")); 36 | jmsTemplate.convertAndSend("test-queue", new Foo("456")); 37 | jmsTemplate.convertAndSend("test-queue", new Foo("789")); 38 | } 39 | 40 | @Test 41 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_js.json") 42 | void testExpectedDataSetWithJavaScript() { 43 | jmsTemplate.convertAndSend("test-queue", new Foo( String.valueOf(1+2+3+4+5))); 44 | } 45 | 46 | @Test 47 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_date.json") 48 | void testExpectedWithDate() { 49 | // Arrange 50 | FooWithBar fooWithBar = FooWithBar.builder() 51 | // NOW 52 | .time(new Date()) 53 | .build(); 54 | // Act 55 | jmsTemplate.convertAndSend("test-queue", fooWithBar); 56 | } 57 | 58 | @Test 59 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_partial.json") 60 | void testExpectedPartialFields() { 61 | 62 | Foo childFoo = new Foo("child foo"); 63 | Bar childBar = new Bar("child bar", 1); 64 | FooWithBar child = FooWithBar.builder() 65 | .foo(childFoo) 66 | .bar(childBar) 67 | .build(); 68 | 69 | Foo foo = new Foo("parent foo"); 70 | Bar bar = new Bar("parent bar", 2); 71 | FooWithBar fooWithBar = FooWithBar.builder() 72 | .foo(foo) 73 | .bar(bar) 74 | .child(child) 75 | .build(); 76 | 77 | jmsTemplate.convertAndSend("test-queue", fooWithBar); 78 | } 79 | 80 | @TestConfiguration 81 | public static class TestConfig { 82 | @Bean 83 | public Queue testQueue() { 84 | return new Queue("test-queue"); 85 | } 86 | 87 | @Bean // Serialize message content to json using TextMessage 88 | public MessageConverter jacksonJmsMessageConverter() { 89 | MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); 90 | converter.setTargetType(MessageType.TEXT); 91 | converter.setTypeIdPropertyName("_type"); 92 | return converter; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /spring-test-jpa/src/test/java/com/jupiter/tools/spring/test/jpa/extension/TraceSqlExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.jpa.extension; 2 | 3 | import com.jupiter.tools.spring.test.jpa.tracesql.AssertSqlQueryCount; 4 | import com.jupiter.tools.spring.test.jpa.tracesql.QueryType; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.context.annotation.Import; 12 | import org.springframework.test.context.junit.jupiter.SpringExtension; 13 | 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | import static org.assertj.core.api.Assertions.assertThat; 18 | 19 | /** 20 | * Created on 26.01.2019. 21 | * 22 | * @author Korovin Anatoliy 23 | */ 24 | @ExtendWith(TraceSqlExtension.class) 25 | @ExtendWith(SpringExtension.class) 26 | @SpringBootTest 27 | @Import(TransactionalTestConfig.class) 28 | class TraceSqlExtensionTest { 29 | 30 | @Autowired 31 | private TransactionalTestConfig.FooRepository fooRepository; 32 | 33 | @BeforeEach 34 | void setUp() { 35 | fooRepository.deleteAll(); 36 | AssertSqlQueryCount.reset(); 37 | } 38 | 39 | @Test 40 | void testInsert() { 41 | // Act 42 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 43 | // Assert 44 | AssertSqlQueryCount.assertCount(QueryType.INSERT, 1); 45 | } 46 | 47 | @Test 48 | void testSelect() { 49 | // Act 50 | fooRepository.findAll(); 51 | // Asserts 52 | AssertSqlQueryCount.assertCount(QueryType.SELECT, 1); 53 | } 54 | 55 | @Test 56 | void testUpdate() { 57 | // Arrange 58 | TransactionalTestConfig.Foo foo = 59 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 60 | 61 | foo.setField("up"); 62 | // Act 63 | fooRepository.save(foo); 64 | // Asserts 65 | AssertSqlQueryCount.assertCount(QueryType.UPDATE, 1); 66 | } 67 | 68 | @Test 69 | void testDelete() { 70 | // Arrange 71 | fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 72 | // Act 73 | fooRepository.deleteAll(); 74 | // Asserts 75 | AssertSqlQueryCount.assertCount(QueryType.DELETE,1); 76 | } 77 | 78 | @Test 79 | void testCall() { 80 | // Act 81 | fooRepository.rand(); 82 | // Asserts 83 | AssertSqlQueryCount.assertCount(QueryType.CALL, 1); 84 | } 85 | 86 | @Test 87 | void testCallSeq() { 88 | // Arrange 89 | Set rands = new HashSet<>(); 90 | // Act 91 | for (int i = 0; i < 10; i++) { 92 | rands.add(fooRepository.rand()); 93 | } 94 | // Asserts 95 | assertThat(rands.size() > 3).isTrue(); 96 | AssertSqlQueryCount.assertCount(QueryType.CALL, 10); 97 | } 98 | 99 | @Test 100 | void testReset() { 101 | // Arrange 102 | TransactionalTestConfig.Foo foo = fooRepository.save(new TransactionalTestConfig.Foo(1L, "any data")); 103 | foo.setField("up"); 104 | fooRepository.save(foo); 105 | fooRepository.findAll(); 106 | fooRepository.deleteAll(); 107 | fooRepository.rand(); 108 | // Act 109 | AssertSqlQueryCount.reset(); 110 | // Asserts 111 | AssertSqlQueryCount.assertCount(QueryType.CALL, 0); 112 | AssertSqlQueryCount.assertCount(QueryType.DELETE, 0); 113 | AssertSqlQueryCount.assertCount(QueryType.UPDATE, 0); 114 | AssertSqlQueryCount.assertCount(QueryType.SELECT, 0); 115 | AssertSqlQueryCount.assertCount(QueryType.INSERT, 0); 116 | } 117 | 118 | @Test 119 | void testThrows() { 120 | // Arrange 121 | // Act 122 | Assertions.assertThrows(Exception.class, 123 | () -> AssertSqlQueryCount.assertCount(QueryType.SELECT, 1)); 124 | // Asserts 125 | } 126 | } -------------------------------------------------------------------------------- /spring-test-core/src/main/java/com/jupiter/tools/spring/test/core/expected/list/messages/AssertReceivedMessages.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.core.expected.list.messages; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import com.jupitertools.datasetroll.DataSet; 11 | import com.jupitertools.datasetroll.expect.MatchDataSets; 12 | import com.jupitertools.datasetroll.importdata.ImportFile; 13 | import com.jupitertools.datasetroll.importdata.JsonImport; 14 | 15 | /** 16 | * Created on 27.03.2019. 17 | * 18 | * Compare an expected data set with received from broker messages, 19 | * trying to receive messages from the broker and will wait until timeout reached. 20 | * 21 | * @author Korovin Anatoliy 22 | */ 23 | public class AssertReceivedMessages { 24 | 25 | private final ExpectedMessagesOptions expectedMessagesOptions; 26 | private final MessageBroker messageBroker; 27 | 28 | public AssertReceivedMessages(ExpectedMessagesOptions expectedMessagesOptions, 29 | MessageBroker messageBroker) { 30 | this.expectedMessagesOptions = expectedMessagesOptions; 31 | this.messageBroker = messageBroker; 32 | } 33 | 34 | /** 35 | * Try to receive messages from broker 36 | * and match them with expected data set. 37 | */ 38 | public void doAssert() { 39 | 40 | if (expectedMessagesOptions == null) { 41 | return; 42 | } 43 | 44 | DataSet expectedDataSet = new JsonImport(new ImportFile(expectedMessagesOptions.getMessagesFile())); 45 | if (expectedMessagesOptions.getExpectedDataSetPreProcessor() != null) { 46 | expectedDataSet = expectedMessagesOptions.getExpectedDataSetPreProcessor().run(expectedDataSet); 47 | } 48 | 49 | if (isEmptyDataSet(expectedDataSet)) { 50 | processingEmptyDataSet(expectedMessagesOptions); 51 | return; 52 | } 53 | 54 | processingDataSet(expectedMessagesOptions, expectedDataSet); 55 | } 56 | 57 | /** 58 | * Waits for messages and throws an exception if receive something during the waiting timeout interval. 59 | */ 60 | public void doAssertSilence() { 61 | 62 | for (String queue : expectedMessagesOptions.getAllQueues()) { 63 | Object message = messageBroker.receive(queue, expectedMessagesOptions.getTimeout()); 64 | 65 | if (message != null) { 66 | new Fail("not expected but found:").withObject(message).fire(); 67 | } 68 | } 69 | } 70 | 71 | 72 | private boolean isEmptyDataSet(DataSet dataSet) { 73 | Map>> readDataSet = dataSet.read(); 74 | return readDataSet.isEmpty() || readDataSet.entrySet() 75 | .stream() 76 | .allMatch(e -> e.getValue().isEmpty()); 77 | } 78 | 79 | private void processingEmptyDataSet(ExpectedMessagesOptions expectedMessagesOptions) { 80 | 81 | Object message = messageBroker.receive(expectedMessagesOptions.getQueue(), 82 | expectedMessagesOptions.getTimeout()); 83 | 84 | if (message != null) { 85 | new Fail("not expected but found:").withObject(message).fire(); 86 | } 87 | } 88 | 89 | private void processingDataSet(ExpectedMessagesOptions expectedMessagesOptions, 90 | DataSet expectedDataSet){ 91 | 92 | List receivedMessages = new ArrayList<>(); 93 | long startTime = System.currentTimeMillis(); 94 | while (true) { 95 | 96 | Object message = messageBroker.receive(expectedMessagesOptions.getQueue(), 97 | expectedMessagesOptions.getTimeout()); 98 | 99 | if (message == null) { 100 | new Fail("expected but not found:").withObject(expectedDataSet.read()).fire(); 101 | } 102 | 103 | receivedMessages.add(message); 104 | DataSet actualDataSet = new MessagesDataSet(receivedMessages); 105 | 106 | if(isWaitingMoreMessages(startTime, actualDataSet, expectedDataSet)){ 107 | continue; 108 | } 109 | 110 | if (expectedMessagesOptions.getActualDataSetPreProcessor() != null) { 111 | actualDataSet = expectedMessagesOptions.getActualDataSetPreProcessor() 112 | .run(actualDataSet); 113 | } 114 | 115 | new MatchDataSets(actualDataSet, expectedDataSet).check(); 116 | return; 117 | } 118 | } 119 | 120 | private boolean isWaitingMoreMessages(long startTime, DataSet actual, DataSet expected) { 121 | 122 | if (timeLimit(startTime, expectedMessagesOptions.getTimeout())) { 123 | System.out.println("Timeout was reached."); 124 | return false; 125 | } 126 | 127 | return getMessageCount(actual) < getMessageCount(expected); 128 | } 129 | 130 | private int getMessageCount(DataSet dataSet) { 131 | return dataSet.read() 132 | .entrySet() 133 | .stream() 134 | .mapToInt(e -> e.getValue().size()) 135 | .sum(); 136 | } 137 | 138 | private boolean timeLimit(long startTime, long timeout) { 139 | return (System.currentTimeMillis() - startTime > timeout); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /spring-test-rabbitmq/src/test/java/com/jupiter/tools/spring/test/rabbitmq/extension/ExpectedMessagesExtensionTest.java: -------------------------------------------------------------------------------- 1 | package com.jupiter.tools.spring.test.rabbitmq.extension; 2 | 3 | import java.util.Date; 4 | 5 | import com.jupiter.tools.spring.test.rabbitmq.annotation.EnableRabbitMqTestContainers; 6 | import com.jupiter.tools.spring.test.rabbitmq.annotation.ExpectedMessages; 7 | import com.jupiter.tools.spring.test.rabbitmq.extension.expected.list.messages.RabbitMqExpectedListOfMessagesExtension; 8 | import com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Bar; 9 | import com.jupiter.tools.spring.test.rabbitmq.extension.pojo.Foo; 10 | import com.jupiter.tools.spring.test.rabbitmq.extension.pojo.FooWithBar; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | 14 | import org.springframework.amqp.core.AmqpTemplate; 15 | import org.springframework.amqp.core.Queue; 16 | import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; 17 | import org.springframework.amqp.support.converter.MessageConverter; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | import org.springframework.boot.test.context.TestConfiguration; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.test.context.junit.jupiter.SpringExtension; 23 | 24 | /** 25 | * Created on 25.03.2019. 26 | * 27 | * @author Korovin Anatoliy 28 | */ 29 | @SpringBootTest 30 | @ExtendWith(SpringExtension.class) 31 | @EnableRabbitMqTestContainers 32 | @ExtendWith(RabbitMqExpectedListOfMessagesExtension.class) 33 | class ExpectedMessagesExtensionTest { 34 | 35 | @Autowired 36 | private AmqpTemplate amqpTemplate; 37 | 38 | @Test 39 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages.json") 40 | void testSend() { 41 | amqpTemplate.convertAndSend("test-queue", new Foo("123")); 42 | amqpTemplate.convertAndSend("test-queue", new Foo("456")); 43 | amqpTemplate.convertAndSend("test-queue", new Foo("789")); 44 | } 45 | 46 | @Test 47 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_multiple_types.json") 48 | void sendMultipleTypes() { 49 | // first type: 50 | amqpTemplate.convertAndSend("test-queue", new Foo("123")); 51 | // second type: 52 | amqpTemplate.convertAndSend("test-queue", new Bar("AAA", 1)); 53 | amqpTemplate.convertAndSend("test-queue", new Bar("BBB", 2)); 54 | amqpTemplate.convertAndSend("test-queue", new Bar("CCC", 3)); 55 | } 56 | 57 | @Test 58 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_nested_objects.json") 59 | void testSendObjectWithNested() { 60 | 61 | Foo childFoo = new Foo("child foo"); 62 | Bar childBar = new Bar("child bar", 1); 63 | FooWithBar child = FooWithBar.builder() 64 | .foo(childFoo) 65 | .bar(childBar) 66 | .build(); 67 | 68 | Foo foo = new Foo("parent foo"); 69 | Bar bar = new Bar("parent bar", 2); 70 | FooWithBar fooWithBar = FooWithBar.builder() 71 | .foo(foo) 72 | .bar(bar) 73 | .child(child) 74 | .build(); 75 | 76 | amqpTemplate.convertAndSend("test-queue", fooWithBar); 77 | } 78 | 79 | @Test 80 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_partial.json") 81 | void testExpectedPartialFields() { 82 | 83 | Foo childFoo = new Foo("child foo"); 84 | Bar childBar = new Bar("child bar", 1); 85 | FooWithBar child = FooWithBar.builder() 86 | .foo(childFoo) 87 | .bar(childBar) 88 | .build(); 89 | 90 | Foo foo = new Foo("parent foo"); 91 | Bar bar = new Bar("parent bar", 2); 92 | FooWithBar fooWithBar = FooWithBar.builder() 93 | .foo(foo) 94 | .bar(bar) 95 | .child(child) 96 | .build(); 97 | 98 | amqpTemplate.convertAndSend("test-queue", fooWithBar); 99 | } 100 | 101 | @Test 102 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_js.json") 103 | void testExpectedDataSetWithJavaScript() { 104 | amqpTemplate.convertAndSend("test-queue", new Foo( String.valueOf(1+2+3+4+5))); 105 | } 106 | 107 | @Test 108 | @ExpectedMessages(queue = "test-queue", messagesFile = "/datasets/expected_messages_with_date.json") 109 | void testExpectedWithDate() { 110 | // Arrange 111 | FooWithBar fooWithBar = FooWithBar.builder() 112 | // NOW 113 | .time(new Date()) 114 | .build(); 115 | // Act 116 | amqpTemplate.convertAndSend("test-queue", fooWithBar); 117 | } 118 | 119 | @TestConfiguration 120 | public static class TestConfig { 121 | @Bean 122 | public Queue testQueue() { 123 | return new Queue("test-queue"); 124 | } 125 | 126 | @Bean 127 | public MessageConverter jackson2JsonMessageConverter() { 128 | return new Jackson2JsonMessageConverter(); 129 | } 130 | } 131 | 132 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jupiter-tools 7 | spring-boot-extensions-parent 8 | 0.4 9 | pom 10 | 11 | spring-boot-extensions-parent 12 | JUnit5 Extensions Suite 13 | 14 | https://github.com/jupiter-tools/spring-boot-extensions 15 | 16 | https://github.com/jupiter-tools/spring-boot-extensions 17 | scm:git:git://github.com/jupiter-tools/spring-boot-extensions.git 18 | scm:git:ssh://git@github.com/jupiter-tools/spring-boot-extensions.git 19 | HEAD 20 | 21 | 22 | 23 | https://github.com/jupiter-tools/spring-boot-extensions/issues 24 | 25 | 26 | 27 | 28 | The Apache Software License, Version 2.0 29 | http://www.apache.org/licenses/LICENSE-2.0.txt 30 | repo 31 | 32 | 33 | 34 | 35 | UTF-8 36 | UTF-8 37 | 3.7.0 38 | 1.8 39 | 5.5.0 40 | 5.5.0 41 | 1.5.0 42 | 43 | 44 | 45 | 46 | antkorwin 47 | Anatoliy Korovin 48 | antkorwin@gmail.com 49 | antkorwin.com 50 | 51 | architect 52 | developer 53 | 54 | 55 | 56 | 57 | 58 | 59 | ossrh 60 | https://oss.sonatype.org/content/repositories/snapshots 61 | 62 | 63 | ossrh 64 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 65 | 66 | 67 | 68 | 69 | 70 | jitpack.io 71 | https://jitpack.io 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-starter-parent 78 | [2.0.0.RELEASE,2.3.0.RELEASE] 79 | 80 | 81 | 82 | 83 | spring-test-core 84 | spring-test-rabbitmq 85 | spring-test-activemq 86 | spring-test-jpa 87 | spring-test-mysql 88 | spring-test-postgres 89 | spring-test-web 90 | 91 | 92 | 93 | 94 | 95 | org.springframework.boot 96 | spring-boot-starter-test 97 | compile 98 | 99 | 100 | junit 101 | junit 102 | 103 | 104 | 105 | 106 | org.junit.jupiter 107 | junit-jupiter-api 108 | ${junit-jupiter.version} 109 | 110 | 111 | org.junit.jupiter 112 | junit-jupiter-engine 113 | ${junit-jupiter.version} 114 | 115 | 116 | org.junit.platform 117 | junit-platform-engine 118 | ${junit-platform.version} 119 | 120 | 121 | org.junit.platform 122 | junit-platform-launcher 123 | ${junit-platform.version} 124 | 125 | 126 | org.junit.vintage 127 | junit-vintage-engine 128 | ${junit.vintage.version} 129 | 130 | 131 | org.junit.jupiter 132 | junit-jupiter-params 133 | ${junit-jupiter.version} 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | central 142 | 143 | 144 | 145 | org.apache.maven.plugins 146 | maven-gpg-plugin 147 | 1.5 148 | 149 | 150 | sign-artifacts 151 | verify 152 | 153 | sign 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | org.sonatype.plugins 167 | nexus-staging-maven-plugin 168 | 1.6.7 169 | true 170 | 171 | ossrh 172 | https://oss.sonatype.org/ 173 | true 174 | 175 | 176 | 177 | org.apache.maven.plugins 178 | maven-compiler-plugin 179 | ${maven-compiler-plugin.version} 180 | 181 | ${java.version} 182 | ${java.version} 183 | 184 | 185 | 186 | org.codehaus.mojo 187 | cobertura-maven-plugin 188 | 2.7 189 | 190 | 191 | html 192 | xml 193 | 194 | 195 | 196 | 197 | 198 | 199 | org.apache.maven.plugins 200 | maven-source-plugin 201 | 2.2.1 202 | 203 | 204 | attach-sources 205 | 206 | jar-no-fork 207 | 208 | 209 | 210 | 211 | 212 | org.apache.maven.plugins 213 | maven-javadoc-plugin 214 | 2.10.4 215 | 216 | -Xdoclint:none 217 | 1.8 218 | 219 | 220 | 221 | attach-javadocs 222 | 223 | jar 224 | 225 | 226 | 227 | 228 | 229 | 230 | org.apache.maven.plugins 231 | maven-surefire-plugin 232 | 2.22.2 233 | 234 | plain 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | --------------------------------------------------------------------------------