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
026682d7
Commit
026682d7
authored
May 31, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish jOOQ auto-configuration
parent
efdf451e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
29 deletions
+25
-29
JooqProperties.java
...ringframework/boot/autoconfigure/jooq/JooqProperties.java
+1
-2
JooqAutoConfigurationTests.java
...k/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java
+23
-26
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqProperties.java
View file @
026682d7
...
...
@@ -33,8 +33,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public
class
JooqProperties
{
/**
* SQLDialect JOOQ used when communicating with the configured datasource, for
* instance "POSTGRES".
* Sql dialect to use, auto-detected by default.
*/
private
SQLDialect
sqlDialect
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java
View file @
026682d7
...
...
@@ -32,12 +32,10 @@ import org.jooq.TransactionalRunnable;
import
org.jooq.VisitListener
;
import
org.jooq.VisitListenerProvider
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
...
@@ -46,6 +44,7 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.util.ObjectUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
junit
.
Assert
.
fail
;
...
...
@@ -56,6 +55,7 @@ import static org.junit.Assert.fail;
* @author Andreas Ahlenstorf
* @author Phillip Webb
* @author Andy Wilkinson
* @author Stephane Nicoll
*/
public
class
JooqAutoConfigurationTests
{
...
...
@@ -64,12 +64,7 @@ public class JooqAutoConfigurationTests {
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
@Before
public
void
init
()
{
TestPropertyValues
.
of
(
"spring.datasource.name:jooqtest"
).
applyTo
(
this
.
context
);
}
private
AnnotationConfigApplicationContext
context
;
@After
public
void
close
()
{
...
...
@@ -80,16 +75,14 @@ public class JooqAutoConfigurationTests {
@Test
public
void
noDataSource
()
throws
Exception
{
registerAndRefresh
(
JooqAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
load
();
assertThat
(
this
.
context
.
getBeanNamesForType
(
DSLContext
.
class
).
length
)
.
isEqualTo
(
0
);
}
@Test
public
void
jooqWithoutTx
()
throws
Exception
{
registerAndRefresh
(
JooqDataSourceConfiguration
.
class
,
JooqAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
load
(
JooqDataSourceConfiguration
.
class
);
assertThat
(
getBeanNames
(
PlatformTransactionManager
.
class
)).
isEqualTo
(
NO_BEANS
);
assertThat
(
getBeanNames
(
SpringTransactionProvider
.
class
)).
isEqualTo
(
NO_BEANS
);
DSLContext
dsl
=
this
.
context
.
getBean
(
DSLContext
.
class
);
...
...
@@ -115,9 +108,7 @@ public class JooqAutoConfigurationTests {
@Test
public
void
jooqWithTx
()
throws
Exception
{
registerAndRefresh
(
JooqDataSourceConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
TxManagerConfiguration
.
class
,
JooqAutoConfiguration
.
class
);
load
(
JooqDataSourceConfiguration
.
class
,
TxManagerConfiguration
.
class
);
this
.
context
.
getBean
(
PlatformTransactionManager
.
class
);
DSLContext
dsl
=
this
.
context
.
getBean
(
DSLContext
.
class
);
assertThat
(
dsl
.
configuration
().
dialect
()).
isEqualTo
(
SQLDialect
.
HSQLDB
);
...
...
@@ -143,11 +134,9 @@ public class JooqAutoConfigurationTests {
@Test
public
void
customProvidersArePickedUp
()
{
registerAndRefresh
(
JooqDataSourceConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
TxManagerConfiguration
.
class
,
load
(
JooqDataSourceConfiguration
.
class
,
TxManagerConfiguration
.
class
,
TestRecordMapperProvider
.
class
,
TestRecordListenerProvider
.
class
,
TestExecuteListenerProvider
.
class
,
TestVisitListenerProvider
.
class
,
JooqAutoConfiguration
.
class
);
TestExecuteListenerProvider
.
class
,
TestVisitListenerProvider
.
class
);
DSLContext
dsl
=
this
.
context
.
getBean
(
DSLContext
.
class
);
assertThat
(
dsl
.
configuration
().
recordMapperProvider
().
getClass
())
.
isEqualTo
(
TestRecordMapperProvider
.
class
);
...
...
@@ -158,17 +147,25 @@ public class JooqAutoConfigurationTests {
@Test
public
void
relaxedBindingOfSqlDialect
()
{
TestPropertyValues
.
of
(
"spring.jooq.sql-dialect:PoSTGrES"
).
applyTo
(
this
.
context
);
registerAndRefresh
(
JooqDataSourceConfiguration
.
class
,
JooqAutoConfiguration
.
class
);
load
(
new
Class
<?>[]
{
JooqDataSourceConfiguration
.
class
},
"spring.jooq.sql-dialect:PoSTGrES"
);
assertThat
(
this
.
context
.
getBean
(
org
.
jooq
.
Configuration
.
class
).
dialect
())
.
isEqualTo
(
SQLDialect
.
POSTGRES
);
}
private
void
registerAndRefresh
(
Class
<?>...
annotatedClasses
)
{
this
.
context
.
register
(
annotatedClasses
);
this
.
context
.
refresh
();
private
void
load
(
Class
<?>...
configs
)
{
load
(
configs
,
new
String
[
0
]);
}
private
void
load
(
Class
<?>[]
configs
,
String
...
environment
)
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
TestPropertyValues
.
of
(
"spring.datasource.name:jooqtest"
).
applyTo
(
ctx
);
TestPropertyValues
.
of
(
environment
).
applyTo
(
ctx
);
if
(!
ObjectUtils
.
isEmpty
(
configs
))
{
ctx
.
register
(
configs
);
}
ctx
.
register
(
JooqAutoConfiguration
.
class
);
ctx
.
refresh
();
this
.
context
=
ctx
;
}
private
String
[]
getBeanNames
(
Class
<?>
type
)
{
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
026682d7
...
...
@@ -708,7 +708,7 @@ content into your application; rather pick only the properties that you need.
spring.h2.console.settings.web-allow-others=false # Enable remote access.
# JOOQ ({sc-spring-boot-autoconfigure}/jooq/JooqAutoConfiguration.{sc-ext}[JooqAutoConfiguration])
spring.jooq.sql-dialect= # S
QLDialect JOOQ used when communicating with the configured datasource. For instance `POSTGRES`
spring.jooq.sql-dialect= # S
ql dialect to use, auto-detected by default.
# JPA ({sc-spring-boot-autoconfigure}/orm/jpa/JpaBaseConfiguration.{sc-ext}[JpaBaseConfiguration], {sc-spring-boot-autoconfigure}/orm/jpa/HibernateJpaAutoConfiguration.{sc-ext}[HibernateJpaAutoConfiguration])
spring.data.jpa.repositories.enabled=true # Enable JPA repositories.
...
...
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