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
779733c3
Commit
779733c3
authored
Apr 07, 2017
by
Aurélien Leboulanger
Committed by
Stephane Nicoll
Apr 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support of Neo4j auto-index configuration
See gh-8843
parent
1dc256eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
Neo4jProperties.java
...mework/boot/autoconfigure/data/neo4j/Neo4jProperties.java
+17
-0
Neo4jDataAutoConfigurationTests.java
...configure/data/neo4j/Neo4jDataAutoConfigurationTests.java
+37
-0
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jProperties.java
View file @
779733c3
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
neo4j
;
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
neo4j
;
import
org.neo4j.ogm.config.AutoIndexMode
;
import
org.neo4j.ogm.config.Configuration
;
import
org.neo4j.ogm.config.Configuration
;
import
org.neo4j.ogm.config.Configuration.Builder
;
import
org.neo4j.ogm.config.Configuration.Builder
;
...
@@ -31,6 +32,7 @@ import org.springframework.util.ClassUtils;
...
@@ -31,6 +32,7 @@ import org.springframework.util.ClassUtils;
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Michael Hunger
* @author Michael Hunger
* @author Vince Bickers
* @author Vince Bickers
* @author Aurélien Leboulanger
* @since 1.4.0
* @since 1.4.0
*/
*/
@ConfigurationProperties
(
prefix
=
"spring.data.neo4j"
)
@ConfigurationProperties
(
prefix
=
"spring.data.neo4j"
)
...
@@ -61,6 +63,11 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -61,6 +63,11 @@ public class Neo4jProperties implements ApplicationContextAware {
private
final
Embedded
embedded
=
new
Embedded
();
private
final
Embedded
embedded
=
new
Embedded
();
/**
* Index generation behaviour. {@link AutoIndexMode#NONE} by default.
*/
private
AutoIndexMode
autoIndex
=
AutoIndexMode
.
NONE
;
private
ClassLoader
classLoader
=
Neo4jProperties
.
class
.
getClassLoader
();
private
ClassLoader
classLoader
=
Neo4jProperties
.
class
.
getClassLoader
();
public
String
getUri
()
{
public
String
getUri
()
{
...
@@ -91,6 +98,14 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -91,6 +98,14 @@ public class Neo4jProperties implements ApplicationContextAware {
return
this
.
embedded
;
return
this
.
embedded
;
}
}
public
AutoIndexMode
getAutoIndex
()
{
return
this
.
autoIndex
;
}
public
void
setAutoIndex
(
AutoIndexMode
autoIndex
)
{
this
.
autoIndex
=
autoIndex
;
}
@Override
@Override
public
void
setApplicationContext
(
ApplicationContext
ctx
)
throws
BeansException
{
public
void
setApplicationContext
(
ApplicationContext
ctx
)
throws
BeansException
{
this
.
classLoader
=
ctx
.
getClassLoader
();
this
.
classLoader
=
ctx
.
getClassLoader
();
...
@@ -116,6 +131,8 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -116,6 +131,8 @@ public class Neo4jProperties implements ApplicationContextAware {
if
(
this
.
username
!=
null
&&
this
.
password
!=
null
)
{
if
(
this
.
username
!=
null
&&
this
.
password
!=
null
)
{
builder
.
credentials
(
this
.
username
,
this
.
password
);
builder
.
credentials
(
this
.
username
,
this
.
password
);
}
}
builder
.
autoIndex
(
this
.
getAutoIndex
().
name
());
}
}
private
void
configureUriWithDefaults
(
Builder
builder
)
{
private
void
configureUriWithDefaults
(
Builder
builder
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java
View file @
779733c3
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.data.neo4j;
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.data.neo4j;
import
org.assertj.core.api.Assertions
;
import
org.assertj.core.api.Assertions
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.neo4j.ogm.config.AutoIndexMode
;
import
org.neo4j.ogm.session.Session
;
import
org.neo4j.ogm.session.Session
;
import
org.neo4j.ogm.session.SessionFactory
;
import
org.neo4j.ogm.session.SessionFactory
;
import
org.neo4j.ogm.session.event.Event
;
import
org.neo4j.ogm.session.event.Event
;
...
@@ -32,6 +33,7 @@ import org.springframework.boot.autoconfigure.data.neo4j.city.City;
...
@@ -32,6 +33,7 @@ import org.springframework.boot.autoconfigure.data.neo4j.city.City;
import
org.springframework.boot.autoconfigure.data.neo4j.country.Country
;
import
org.springframework.boot.autoconfigure.data.neo4j.country.Country
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
;
import
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
@@ -56,6 +58,7 @@ import static org.mockito.Mockito.verify;
...
@@ -56,6 +58,7 @@ import static org.mockito.Mockito.verify;
* @author Vince Bickers
* @author Vince Bickers
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Kazuki Shimizu
* @author Kazuki Shimizu
* @author Aurélien Leboulanger
*/
*/
public
class
Neo4jDataAutoConfigurationTests
{
public
class
Neo4jDataAutoConfigurationTests
{
...
@@ -139,6 +142,25 @@ public class Neo4jDataAutoConfigurationTests {
...
@@ -139,6 +142,25 @@ public class Neo4jDataAutoConfigurationTests {
.
onPreSave
(
any
(
Event
.
class
));
.
onPreSave
(
any
(
Event
.
class
));
}
}
@Test
public
void
autoIndexConfiguration
()
{
load
(
CustomConfigurationFactory
.
class
);
assertThat
(
this
.
context
.
getBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)
.
getAutoIndex
()).
isEqualTo
(
AutoIndexMode
.
NONE
);
load
(
CustomConfigurationFactory
.
class
,
"spring.data.neo4j.auto-index=assert"
);
assertThat
(
this
.
context
.
getBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)
.
getAutoIndex
()).
isEqualTo
(
AutoIndexMode
.
ASSERT
);
load
(
CustomConfigurationFactory
.
class
,
"spring.data.neo4j.auto-index=dump"
);
assertThat
(
this
.
context
.
getBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)
.
getAutoIndex
()).
isEqualTo
(
AutoIndexMode
.
DUMP
);
load
(
CustomConfigurationFactory
.
class
,
"spring.data.neo4j.auto-index=validate"
);
assertThat
(
this
.
context
.
getBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)
.
getAutoIndex
()).
isEqualTo
(
AutoIndexMode
.
VALIDATE
);
}
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
AnnotationConfigWebApplicationContext
ctx
=
new
AnnotationConfigWebApplicationContext
();
AnnotationConfigWebApplicationContext
ctx
=
new
AnnotationConfigWebApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
ctx
,
environment
);
EnvironmentTestUtils
.
addEnvironment
(
ctx
,
environment
);
...
@@ -174,6 +196,21 @@ public class Neo4jDataAutoConfigurationTests {
...
@@ -174,6 +196,21 @@ public class Neo4jDataAutoConfigurationTests {
}
}
@Configuration
@EnableConfigurationProperties
(
Neo4jProperties
.
class
)
static
class
CustomConfigurationFactory
{
@Bean
public
org
.
neo4j
.
ogm
.
config
.
Configuration
configuration
(
Neo4jProperties
properties
)
{
return
properties
.
createConfiguration
();
}
@Bean
public
SessionFactory
customSessionFactory
()
{
return
mock
(
SessionFactory
.
class
);
}
}
@Configuration
@Configuration
static
class
CustomConfiguration
{
static
class
CustomConfiguration
{
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
779733c3
...
@@ -619,6 +619,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -619,6 +619,7 @@ content into your application; rather pick only the properties that you need.
spring.data.neo4j.repositories.enabled=true # Enable Neo4j repositories.
spring.data.neo4j.repositories.enabled=true # Enable Neo4j repositories.
spring.data.neo4j.uri= # URI used by the driver. Auto-detected by default.
spring.data.neo4j.uri= # URI used by the driver. Auto-detected by default.
spring.data.neo4j.username= # Login user of the server.
spring.data.neo4j.username= # Login user of the server.
spring.data.neo4j.indexes.auto=none # Configure auto indexing. Disable by default.
# DATA REST ({sc-spring-boot-autoconfigure}/data/rest/RepositoryRestProperties.{sc-ext}[RepositoryRestProperties])
# DATA REST ({sc-spring-boot-autoconfigure}/data/rest/RepositoryRestProperties.{sc-ext}[RepositoryRestProperties])
spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources.
spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources.
...
...
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