From 8628aaa2bd4df98cd7c64b9582d95f421a908ff5 Mon Sep 17 00:00:00 2001 From: gkatzioura Date: Sun, 15 Jan 2023 23:01:13 +0000 Subject: [PATCH] 228: Added dependencies and test --- java/sqlcommenter-java/build.gradle | 14 ++++++ .../SpringSQLCommenterWebFilterTest.java | 47 +++++++++---------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/java/sqlcommenter-java/build.gradle b/java/sqlcommenter-java/build.gradle index c965bcf4..e2deba08 100644 --- a/java/sqlcommenter-java/build.gradle +++ b/java/sqlcommenter-java/build.gradle @@ -61,6 +61,20 @@ dependencies { compile (group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.5.RELEASE') { exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' } + + compile (group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.7.7') { + exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' + } + + compile (group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '2.7.7') { + exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' + } + + testImplementation 'io.projectreactor:reactor-test:3.5.2' + + compile 'io.r2dbc:r2dbc-proxy:1.1.0.RELEASE' + compile 'io.r2dbc:r2dbc-spi:1.0.0.RELEASE' + compile 'org.apache.logging.log4j:log4j-to-slf4j:2.16.0' compile 'org.hibernate:hibernate-core:5.4.3.Final' diff --git a/java/sqlcommenter-java/src/test/java/com/google/cloud/sqlcommenter/filter/SpringSQLCommenterWebFilterTest.java b/java/sqlcommenter-java/src/test/java/com/google/cloud/sqlcommenter/filter/SpringSQLCommenterWebFilterTest.java index 916a0de6..9fa78036 100644 --- a/java/sqlcommenter-java/src/test/java/com/google/cloud/sqlcommenter/filter/SpringSQLCommenterWebFilterTest.java +++ b/java/sqlcommenter-java/src/test/java/com/google/cloud/sqlcommenter/filter/SpringSQLCommenterWebFilterTest.java @@ -8,33 +8,32 @@ import org.springframework.web.reactive.result.method.RequestMappingInfo; import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.server.WebFilterChain; - import reactor.core.publisher.Mono; import reactor.test.StepVerifier; - @RunWith(JUnit4.class) public class SpringSQLCommenterWebFilterTest { - @Test - public void testPreHandlePlacesStateInContextView() throws NoSuchMethodException { - RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping(); - RequestMappingInfo info = RequestMappingInfo.paths("/test").build(); - requestMappingHandlerMapping.registerMapping(info, this, SpringSQLCommenterWebFilterTest.class.getMethod("testPreHandlePlacesStateInContextView")); - - SpringSQLCommenterWebFilter springSQLCommenterWebFilter = new SpringSQLCommenterWebFilter(requestMappingHandlerMapping); - - WebFilterChain filterChain = filterExchange -> Mono.empty(); - - MockServerWebExchange exchange = MockServerWebExchange.from( - MockServerHttpRequest - .get("/test")); - - StepVerifier.create(springSQLCommenterWebFilter.filter(exchange, filterChain)) - .expectAccessibleContext() - .hasKey("state") - .then() - .verifyComplete(); - } - -} \ No newline at end of file + @Test + public void testPreHandlePlacesStateInContextView() throws NoSuchMethodException { + RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping(); + RequestMappingInfo info = RequestMappingInfo.paths("/test").build(); + requestMappingHandlerMapping.registerMapping( + info, + this, + SpringSQLCommenterWebFilterTest.class.getMethod("testPreHandlePlacesStateInContextView")); + + SpringSQLCommenterWebFilter springSQLCommenterWebFilter = + new SpringSQLCommenterWebFilter(requestMappingHandlerMapping); + + WebFilterChain filterChain = filterExchange -> Mono.empty(); + + MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test")); + + StepVerifier.create(springSQLCommenterWebFilter.filter(exchange, filterChain)) + .expectAccessibleContext() + .hasKey("state") + .then() + .verifyComplete(); + } +}