File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
main/java/org/springframework/r2dbc/core
test/java/org/springframework/r2dbc/core Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 55
55
*/
56
56
public interface DatabaseClient extends ConnectionAccessor {
57
57
58
+ /**
59
+ * Return the {@link ConnectionFactory} that this client uses.
60
+ * @return the connection factory
61
+ */
62
+ ConnectionFactory getConnectionFactory ();
63
+
58
64
/**
59
65
* Specify a static {@code sql} statement to run. Contract for specifying a
60
66
* SQL call along with options leading to the execution. The SQL string can
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ class DefaultDatabaseClient implements DatabaseClient {
85
85
}
86
86
87
87
88
+ @ Override
89
+ public ConnectionFactory getConnectionFactory () {
90
+ return this .connectionFactory ;
91
+ }
92
+
88
93
@ Override
89
94
public GenericExecuteSpec sql (String sql ) {
90
95
Assert .hasText (sql , "SQL must not be null or empty" );
Original file line number Diff line number Diff line change 46
46
import org .springframework .r2dbc .core .binding .BindMarkersFactory ;
47
47
import org .springframework .r2dbc .core .binding .BindTarget ;
48
48
49
+ import static org .assertj .core .api .Assertions .assertThat ;
49
50
import static org .mockito .ArgumentMatchers .anyString ;
50
51
import static org .mockito .ArgumentMatchers .eq ;
51
52
import static org .mockito .BDDMockito .doReturn ;
@@ -85,6 +86,15 @@ void before() {
85
86
connectionFactory ).bindMarkers (BindMarkersFactory .indexed ("$" , 1 ));
86
87
}
87
88
89
+ @ Test
90
+ void connectionFactoryIsExposed () {
91
+ ConnectionFactory connectionFactory = mock (ConnectionFactory .class );
92
+ DatabaseClient databaseClient = DatabaseClient .builder ()
93
+ .connectionFactory (connectionFactory )
94
+ .bindMarkers (BindMarkersFactory .anonymous ("?" )).build ();
95
+ assertThat (databaseClient .getConnectionFactory ()).isSameAs (connectionFactory );
96
+ }
97
+
88
98
@ Test
89
99
void shouldCloseConnectionOnlyOnce () {
90
100
DefaultDatabaseClient databaseClient = (DefaultDatabaseClient ) databaseClientBuilder .build ();
You can’t perform that action at this time.
0 commit comments