Skip to content

Commit

Permalink
228: Added dependencies and test
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatzioura committed Jan 15, 2023
1 parent d332945 commit fba5111
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
14 changes: 14 additions & 0 deletions java/sqlcommenter-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
@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();
}
}

0 comments on commit fba5111

Please sign in to comment.