Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
38cd1b49
Commit
38cd1b49
authored
Jan 18, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #24862 from izeye
* pr/24862: Polish contribution Polish Closes gh-24862
parents
bcc1331f
dcc0ca0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
11 deletions
+38
-11
JooqAutoConfiguration.java
...mework/boot/autoconfigure/jooq/JooqAutoConfiguration.java
+4
-4
JooqAutoConfigurationTests.java
...k/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java
+34
-7
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java
View file @
38cd1b49
...
...
@@ -95,22 +95,23 @@ public class JooqAutoConfiguration {
@Bean
@ConditionalOnMissingBean
(
org
.
jooq
.
Configuration
.
class
)
public
DefaultConfiguration
jooqConfiguration
(
JooqProperties
properties
,
ConnectionProvider
connectionProvider
,
DataSource
dataSource
,
ObjectProvider
<
DefaultConfigurationCustomizer
>
configurationCustomizers
)
{
DataSource
dataSource
,
ObjectProvider
<
ExecuteListenerProvider
>
executeListenerProviders
,
ObjectProvider
<
DefaultConfigurationCustomizer
>
configurationCustomizers
)
{
DefaultConfiguration
configuration
=
new
DefaultConfiguration
();
configuration
.
set
(
properties
.
determineSqlDialect
(
dataSource
));
configuration
.
set
(
connectionProvider
);
configuration
.
set
(
executeListenerProviders
.
orderedStream
().
toArray
(
ExecuteListenerProvider
[]::
new
));
configurationCustomizers
.
orderedStream
().
forEach
((
customizer
)
->
customizer
.
customize
(
configuration
));
return
configuration
;
}
@Bean
@Deprecated
public
DefaultConfigurationCustomizer
joo
QProvider
DefaultConfigurationCustomizer
(
public
DefaultConfigurationCustomizer
joo
qProviders
DefaultConfigurationCustomizer
(
ObjectProvider
<
TransactionProvider
>
transactionProvider
,
ObjectProvider
<
RecordMapperProvider
>
recordMapperProvider
,
ObjectProvider
<
RecordUnmapperProvider
>
recordUnmapperProvider
,
ObjectProvider
<
Settings
>
settings
,
ObjectProvider
<
RecordListenerProvider
>
recordListenerProviders
,
ObjectProvider
<
ExecuteListenerProvider
>
executeListenerProviders
,
ObjectProvider
<
VisitListenerProvider
>
visitListenerProviders
,
ObjectProvider
<
TransactionListenerProvider
>
transactionListenerProviders
,
ObjectProvider
<
ExecutorProvider
>
executorProvider
)
{
...
...
@@ -121,7 +122,6 @@ public class JooqAutoConfiguration {
settings
.
ifAvailable
(
configuration:
:
set
);
executorProvider
.
ifAvailable
(
configuration:
:
set
);
configuration
.
set
(
recordListenerProviders
.
orderedStream
().
toArray
(
RecordListenerProvider
[]::
new
));
configuration
.
set
(
executeListenerProviders
.
orderedStream
().
toArray
(
ExecuteListenerProvider
[]::
new
));
configuration
.
set
(
visitListenerProviders
.
orderedStream
().
toArray
(
VisitListenerProvider
[]::
new
));
configuration
.
setTransactionListenerProvider
(
transactionListenerProviders
.
orderedStream
().
toArray
(
TransactionListenerProvider
[]::
new
));
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java
View file @
38cd1b49
...
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jooq;
import
javax.sql.DataSource
;
import
org.jooq.CharsetProvider
;
import
org.jooq.ConnectionProvider
;
import
org.jooq.ConverterProvider
;
import
org.jooq.DSLContext
;
import
org.jooq.ExecuteListener
;
...
...
@@ -31,6 +32,7 @@ import org.jooq.SQLDialect;
import
org.jooq.TransactionListenerProvider
;
import
org.jooq.TransactionalRunnable
;
import
org.jooq.VisitListenerProvider
;
import
org.jooq.impl.DataSourceConnectionProvider
;
import
org.jooq.impl.DefaultExecuteListenerProvider
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -42,6 +44,7 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.core.annotation.Order
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -101,7 +104,37 @@ class JooqAutoConfigurationTests {
"insert into jooqtest (name) values ('foo');"
)));
dsl
.
transaction
(
new
AssertFetch
(
dsl
,
"select count(*) as total from jooqtest_tx;"
,
"1"
));
});
}
@Test
void
jooqWithDefaultConnectionProvider
()
{
this
.
contextRunner
.
withUserConfiguration
(
JooqDataSourceConfiguration
.
class
).
run
((
context
)
->
{
DSLContext
dsl
=
context
.
getBean
(
DSLContext
.
class
);
ConnectionProvider
connectionProvider
=
dsl
.
configuration
().
connectionProvider
();
assertThat
(
connectionProvider
).
isInstanceOf
(
DataSourceConnectionProvider
.
class
);
DataSource
connectionProviderDataSource
=
((
DataSourceConnectionProvider
)
connectionProvider
).
dataSource
();
assertThat
(
connectionProviderDataSource
).
isInstanceOf
(
TransactionAwareDataSourceProxy
.
class
);
});
}
@Test
void
jooqWithDefaultExecuteListenerProvider
()
{
this
.
contextRunner
.
withUserConfiguration
(
JooqDataSourceConfiguration
.
class
).
run
((
context
)
->
{
DSLContext
dsl
=
context
.
getBean
(
DSLContext
.
class
);
assertThat
(
dsl
.
configuration
().
executeListenerProviders
()).
hasSize
(
1
);
});
}
@Test
void
jooqWithSeveralExecuteListenerProviders
()
{
this
.
contextRunner
.
withUserConfiguration
(
JooqDataSourceConfiguration
.
class
,
TestExecuteListenerProvider
.
class
)
.
run
((
context
)
->
{
DSLContext
dsl
=
context
.
getBean
(
DSLContext
.
class
);
ExecuteListenerProvider
[]
executeListenerProviders
=
dsl
.
configuration
().
executeListenerProviders
();
assertThat
(
executeListenerProviders
).
hasSize
(
2
);
assertThat
(
executeListenerProviders
[
0
]).
isInstanceOf
(
DefaultExecuteListenerProvider
.
class
);
assertThat
(
executeListenerProviders
[
1
]).
isInstanceOf
(
TestExecuteListenerProvider
.
class
);
});
}
@Test
...
...
@@ -129,9 +162,7 @@ class JooqAutoConfigurationTests {
VisitListenerProvider
visitListenerProvider
=
mock
(
VisitListenerProvider
.
class
);
TransactionListenerProvider
transactionListenerProvider
=
mock
(
TransactionListenerProvider
.
class
);
ExecutorProvider
executorProvider
=
mock
(
ExecutorProvider
.
class
);
this
.
contextRunner
.
withUserConfiguration
(
JooqDataSourceConfiguration
.
class
,
TxManagerConfiguration
.
class
,
TestExecuteListenerProvider
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
JooqDataSourceConfiguration
.
class
,
TxManagerConfiguration
.
class
)
.
withBean
(
RecordMapperProvider
.
class
,
()
->
recordMapperProvider
)
.
withBean
(
RecordUnmapperProvider
.
class
,
()
->
recordUnmapperProvider
)
.
withBean
(
RecordListenerProvider
.
class
,
()
->
recordListenerProvider
)
...
...
@@ -143,10 +174,6 @@ class JooqAutoConfigurationTests {
assertThat
(
dsl
.
configuration
().
recordUnmapperProvider
()).
isSameAs
(
recordUnmapperProvider
);
assertThat
(
dsl
.
configuration
().
executorProvider
()).
isSameAs
(
executorProvider
);
assertThat
(
dsl
.
configuration
().
recordListenerProviders
()).
containsExactly
(
recordListenerProvider
);
ExecuteListenerProvider
[]
executeListenerProviders
=
dsl
.
configuration
().
executeListenerProviders
();
assertThat
(
executeListenerProviders
).
hasSize
(
2
);
assertThat
(
executeListenerProviders
[
0
]).
isInstanceOf
(
DefaultExecuteListenerProvider
.
class
);
assertThat
(
executeListenerProviders
[
1
]).
isInstanceOf
(
TestExecuteListenerProvider
.
class
);
assertThat
(
dsl
.
configuration
().
visitListenerProviders
()).
containsExactly
(
visitListenerProvider
);
assertThat
(
dsl
.
configuration
().
transactionListenerProviders
())
.
containsExactly
(
transactionListenerProvider
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment