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
c68e5f12
Commit
c68e5f12
authored
Mar 25, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
faba7a95
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
78 additions
and
65 deletions
+78
-65
Neo4jRepositoriesAutoConfiguration.java
...figure/data/neo4j/Neo4jRepositoriesAutoConfiguration.java
+2
-1
Neo4jRepositoriesAutoConfigureRegistrar.java
...e/data/neo4j/Neo4jRepositoriesAutoConfigureRegistrar.java
+2
-2
Neo4jAutoConfiguration.java
...work/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java
+9
-8
Neo4jProperties.java
...ngframework/boot/autoconfigure/neo4j/Neo4jProperties.java
+6
-4
CityNeo4jRepository.java
...oot/autoconfigure/data/alt/neo4j/CityNeo4jRepository.java
+1
-0
MixedNeo4jRepositoriesAutoConfigurationTests.java
...a/neo4j/MixedNeo4jRepositoriesAutoConfigurationTests.java
+14
-11
Neo4jDataAutoConfigurationTests.java
...configure/data/neo4j/Neo4jDataAutoConfigurationTests.java
+1
-2
Neo4jRepositoriesAutoConfigurationTests.java
...e/data/neo4j/Neo4jRepositoriesAutoConfigurationTests.java
+2
-1
Neo4jAutoConfigurationTests.java
...boot/autoconfigure/neo4j/Neo4jAutoConfigurationTests.java
+14
-9
Neo4jPropertiesTests.java
...mework/boot/autoconfigure/neo4j/Neo4jPropertiesTests.java
+23
-27
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+4
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jRepositoriesAutoConfiguration.java
View file @
c68e5f12
...
@@ -55,7 +55,8 @@ import org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryB
...
@@ -55,7 +55,8 @@ import org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryB
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
Neo4jSession
.
class
,
GraphRepository
.
class
})
@ConditionalOnClass
({
Neo4jSession
.
class
,
GraphRepository
.
class
})
@ConditionalOnMissingBean
({
GraphRepositoryFactoryBean
.
class
,
Neo4jRepositoryConfigurationExtension
.
class
})
@ConditionalOnMissingBean
({
GraphRepositoryFactoryBean
.
class
,
Neo4jRepositoryConfigurationExtension
.
class
})
@ConditionalOnProperty
(
prefix
=
"spring.data.neo4j.repositories"
,
name
=
"enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"spring.data.neo4j.repositories"
,
name
=
"enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
@Import
(
Neo4jRepositoriesAutoConfigureRegistrar
.
class
)
@Import
(
Neo4jRepositoriesAutoConfigureRegistrar
.
class
)
@AutoConfigureAfter
(
Neo4jAutoConfiguration
.
class
)
@AutoConfigureAfter
(
Neo4jAutoConfiguration
.
class
)
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jRepositoriesAutoConfigureRegistrar.java
View file @
c68e5f12
...
@@ -30,8 +30,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
...
@@ -30,8 +30,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
*
*
* @author Michael Hunger
* @author Michael Hunger
*/
*/
class
Neo4jRepositoriesAutoConfigureRegistrar
extends
class
Neo4jRepositoriesAutoConfigureRegistrar
AbstractRepositoryConfigurationSourceSupport
{
extends
AbstractRepositoryConfigurationSourceSupport
{
@Override
@Override
protected
Class
<?
extends
Annotation
>
getAnnotation
()
{
protected
Class
<?
extends
Annotation
>
getAnnotation
()
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java
View file @
c68e5f12
...
@@ -45,8 +45,7 @@ import org.springframework.data.neo4j.template.Neo4jTemplate;
...
@@ -45,8 +45,7 @@ import org.springframework.data.neo4j.template.Neo4jTemplate;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Neo4j support.
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Neo4j support.
* <p>
* <p>
* Registers a {@link Neo4jTemplate} bean if no other bean of
* Registers a {@link Neo4jTemplate} bean if no other bean of the same type is configured.
* the same type is configured.
*
*
* @author Michael Hunger
* @author Michael Hunger
* @author Josh Long
* @author Josh Long
...
@@ -55,7 +54,7 @@ import org.springframework.data.neo4j.template.Neo4jTemplate;
...
@@ -55,7 +54,7 @@ import org.springframework.data.neo4j.template.Neo4jTemplate;
* @since 1.4.0
* @since 1.4.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
Neo4jSession
.
class
,
Neo4jOperations
.
class
})
@ConditionalOnClass
({
Neo4jSession
.
class
,
Neo4jOperations
.
class
})
@ConditionalOnMissingBean
(
Neo4jOperations
.
class
)
@ConditionalOnMissingBean
(
Neo4jOperations
.
class
)
@EnableConfigurationProperties
(
Neo4jProperties
.
class
)
@EnableConfigurationProperties
(
Neo4jProperties
.
class
)
public
class
Neo4jAutoConfiguration
{
public
class
Neo4jAutoConfiguration
{
...
@@ -66,7 +65,8 @@ public class Neo4jAutoConfiguration {
...
@@ -66,7 +65,8 @@ public class Neo4jAutoConfiguration {
private
final
ObjectProvider
<
SessionFactoryProvider
>
sessionFactoryProvider
;
private
final
ObjectProvider
<
SessionFactoryProvider
>
sessionFactoryProvider
;
public
SpringBootNeo4jConfiguration
(
ObjectProvider
<
SessionFactoryProvider
>
sessionFactoryProvider
)
{
public
SpringBootNeo4jConfiguration
(
ObjectProvider
<
SessionFactoryProvider
>
sessionFactoryProvider
)
{
this
.
sessionFactoryProvider
=
sessionFactoryProvider
;
this
.
sessionFactoryProvider
=
sessionFactoryProvider
;
}
}
...
@@ -77,8 +77,7 @@ public class Neo4jAutoConfiguration {
...
@@ -77,8 +77,7 @@ public class Neo4jAutoConfiguration {
}
}
@Bean
@Bean
@Scope
(
scopeName
=
"${spring.data.neo4j.session.scope:singleton}"
,
@Scope
(
scopeName
=
"${spring.data.neo4j.session.scope:singleton}"
,
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
proxyMode
=
ScopedProxyMode
.
TARGET_CLASS
)
@Override
@Override
public
Session
getSession
()
throws
Exception
{
public
Session
getSession
()
throws
Exception
{
return
getSessionFactory
().
openSession
();
return
getSessionFactory
().
openSession
();
...
@@ -94,7 +93,8 @@ public class Neo4jAutoConfiguration {
...
@@ -94,7 +93,8 @@ public class Neo4jAutoConfiguration {
private
ConfigurableListableBeanFactory
beanFactory
;
private
ConfigurableListableBeanFactory
beanFactory
;
SessionFactoryProviderConfiguration
(
org
.
neo4j
.
ogm
.
config
.
Configuration
configuration
)
{
SessionFactoryProviderConfiguration
(
org
.
neo4j
.
ogm
.
config
.
Configuration
configuration
)
{
this
.
configuration
=
configuration
;
this
.
configuration
=
configuration
;
}
}
...
@@ -114,7 +114,8 @@ public class Neo4jAutoConfiguration {
...
@@ -114,7 +114,8 @@ public class Neo4jAutoConfiguration {
protected
String
[]
getPackagesToScan
()
{
protected
String
[]
getPackagesToScan
()
{
if
(
AutoConfigurationPackages
.
has
(
this
.
beanFactory
))
{
if
(
AutoConfigurationPackages
.
has
(
this
.
beanFactory
))
{
List
<
String
>
basePackages
=
AutoConfigurationPackages
.
get
(
this
.
beanFactory
);
List
<
String
>
basePackages
=
AutoConfigurationPackages
.
get
(
this
.
beanFactory
);
return
basePackages
.
toArray
(
new
String
[
basePackages
.
size
()]);
return
basePackages
.
toArray
(
new
String
[
basePackages
.
size
()]);
}
}
return
new
String
[
0
];
return
new
String
[
0
];
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jProperties.java
View file @
c68e5f12
...
@@ -131,7 +131,8 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -131,7 +131,8 @@ public class Neo4jProperties implements ApplicationContextAware {
}
}
if
(
this
.
username
!=
null
&&
this
.
password
!=
null
)
{
if
(
this
.
username
!=
null
&&
this
.
password
!=
null
)
{
configuration
.
driverConfiguration
().
setCredentials
(
this
.
username
,
this
.
password
);
configuration
.
driverConfiguration
().
setCredentials
(
this
.
username
,
this
.
password
);
}
}
if
(
this
.
compiler
!=
null
)
{
if
(
this
.
compiler
!=
null
)
{
configuration
.
compilerConfiguration
().
setCompilerClassName
(
this
.
compiler
);
configuration
.
compilerConfiguration
().
setCompilerClassName
(
this
.
compiler
);
...
@@ -150,15 +151,16 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -150,15 +151,16 @@ public class Neo4jProperties implements ApplicationContextAware {
return
HTTP_DRIVER
;
return
HTTP_DRIVER
;
}
}
else
{
else
{
throw
new
IllegalArgumentException
(
"Could not deduce driver to use based on URI '"
+
uri
+
"'"
);
throw
new
IllegalArgumentException
(
"Could not deduce driver to use based on URI '"
+
uri
+
"'"
);
}
}
}
}
catch
(
URISyntaxException
ex
)
{
catch
(
URISyntaxException
ex
)
{
throw
new
IllegalArgumentException
(
"Invalid URI for spring.data.neo4j.uri '"
+
this
.
uri
+
"'"
,
ex
);
throw
new
IllegalArgumentException
(
"Invalid URI for spring.data.neo4j.uri '"
+
this
.
uri
+
"'"
,
ex
);
}
}
}
}
public
static
class
Embedded
{
public
static
class
Embedded
{
/**
/**
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/alt/neo4j/CityNeo4jRepository.java
View file @
c68e5f12
...
@@ -20,4 +20,5 @@ import org.springframework.boot.autoconfigure.data.neo4j.city.City;
...
@@ -20,4 +20,5 @@ import org.springframework.boot.autoconfigure.data.neo4j.city.City;
import
org.springframework.data.neo4j.repository.GraphRepository
;
import
org.springframework.data.neo4j.repository.GraphRepository
;
public
interface
CityNeo4jRepository
extends
GraphRepository
<
City
>
{
public
interface
CityNeo4jRepository
extends
GraphRepository
<
City
>
{
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/MixedNeo4jRepositoriesAutoConfigurationTests.java
View file @
c68e5f12
...
@@ -56,8 +56,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -56,8 +56,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
*/
public
class
MixedNeo4jRepositoriesAutoConfigurationTests
{
public
class
MixedNeo4jRepositoriesAutoConfigurationTests
{
private
AnnotationConfigApplicationContext
context
=
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
new
AnnotationConfigApplicationContext
();
@After
@After
public
void
close
()
{
public
void
close
()
{
...
@@ -66,7 +65,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
...
@@ -66,7 +65,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test
@Test
public
void
testDefaultRepositoryConfiguration
()
throws
Exception
{
public
void
testDefaultRepositoryConfiguration
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
this
.
context
.
register
(
TestConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBean
(
CountryRepository
.
class
)).
isNotNull
();
assertThat
(
this
.
context
.
getBean
(
CountryRepository
.
class
)).
isNotNull
();
...
@@ -74,7 +74,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
...
@@ -74,7 +74,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test
@Test
public
void
testMixedRepositoryConfiguration
()
throws
Exception
{
public
void
testMixedRepositoryConfiguration
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
this
.
context
.
register
(
MixedConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
register
(
MixedConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBean
(
CountryRepository
.
class
)).
isNotNull
();
assertThat
(
this
.
context
.
getBean
(
CountryRepository
.
class
)).
isNotNull
();
...
@@ -83,7 +84,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
...
@@ -83,7 +84,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test
@Test
public
void
testJpaRepositoryConfigurationWithNeo4jTemplate
()
throws
Exception
{
public
void
testJpaRepositoryConfigurationWithNeo4jTemplate
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
this
.
context
.
register
(
JpaConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
register
(
JpaConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
...
@@ -92,14 +94,16 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
...
@@ -92,14 +94,16 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test
@Test
@Ignore
@Ignore
public
void
testJpaRepositoryConfigurationWithNeo4jOverlap
()
throws
Exception
{
public
void
testJpaRepositoryConfigurationWithNeo4jOverlap
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
);
this
.
context
.
register
(
OverlapConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
register
(
OverlapConfiguration
.
class
,
BaseConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
}
}
@Test
@Test
public
void
testJpaRepositoryConfigurationWithNeo4jOverlapDisabled
()
throws
Exception
{
public
void
testJpaRepositoryConfigurationWithNeo4jOverlapDisabled
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.initialize:false"
,
"spring.datasource.initialize:false"
,
"spring.data.neo4j.repositories.enabled:false"
);
"spring.data.neo4j.repositories.enabled:false"
);
...
@@ -153,11 +157,10 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
...
@@ -153,11 +157,10 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Override
@Override
public
String
[]
selectImports
(
AnnotationMetadata
importingClassMetadata
)
{
public
String
[]
selectImports
(
AnnotationMetadata
importingClassMetadata
)
{
List
<
String
>
names
=
new
ArrayList
<
String
>();
List
<
String
>
names
=
new
ArrayList
<
String
>();
for
(
Class
<?>
type
:
new
Class
<?>[]
{
DataSourceAutoConfiguration
.
class
,
for
(
Class
<?>
type
:
new
Class
<?>[]
{
DataSourceAutoConfiguration
.
class
,
HibernateJpaAutoConfiguration
.
class
,
HibernateJpaAutoConfiguration
.
class
,
JpaRepositoriesAutoConfiguration
.
class
,
JpaRepositoriesAutoConfiguration
.
class
,
Neo4jAutoConfiguration
.
class
,
Neo4jAutoConfiguration
.
class
,
Neo4jRepositoriesAutoConfiguration
.
class
})
{
Neo4jRepositoriesAutoConfiguration
.
class
})
{
names
.
add
(
type
.
getName
());
names
.
add
(
type
.
getName
());
}
}
return
names
.
toArray
(
new
String
[
names
.
size
()]);
return
names
.
toArray
(
new
String
[
names
.
size
()]);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java
View file @
c68e5f12
...
@@ -57,8 +57,7 @@ public class Neo4jDataAutoConfigurationTests {
...
@@ -57,8 +57,7 @@ public class Neo4jDataAutoConfigurationTests {
City
.
class
);
City
.
class
);
}
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
private
static
void
assertDomainTypesDiscovered
(
Neo4jMappingContext
mappingContext
,
private
static
void
assertDomainTypesDiscovered
(
Neo4jMappingContext
mappingContext
,
Class
<?>...
types
)
{
Class
<?>...
types
)
{
for
(
Class
<?>
type
:
types
)
{
for
(
Class
<?>
type
:
types
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jRepositoriesAutoConfigurationTests.java
View file @
c68e5f12
...
@@ -59,7 +59,8 @@ public class Neo4jRepositoriesAutoConfigurationTests {
...
@@ -59,7 +59,8 @@ public class Neo4jRepositoriesAutoConfigurationTests {
prepareApplicationContext
(
TestConfiguration
.
class
);
prepareApplicationContext
(
TestConfiguration
.
class
);
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
Neo4jMappingContext
mappingContext
=
this
.
context
.
getBean
(
Neo4jMappingContext
.
class
);
Neo4jMappingContext
mappingContext
=
this
.
context
.
getBean
(
Neo4jMappingContext
.
class
);
assertThat
(
mappingContext
.
getPersistentEntity
(
City
.
class
)).
isNotNull
();
assertThat
(
mappingContext
.
getPersistentEntity
(
City
.
class
)).
isNotNull
();
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfigurationTests.java
View file @
c68e5f12
...
@@ -33,8 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -33,8 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
/**
* Tests for {@link Neo4jAutoConfiguration}. Tests can't use the embedded driver
* Tests for {@link Neo4jAutoConfiguration}. Tests can't use the embedded driver
as we use
*
as we use
lucene 4 and Neo4j still requires 3.
* lucene 4 and Neo4j still requires 3.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Michael Hunger
* @author Michael Hunger
...
@@ -55,16 +55,19 @@ public class Neo4jAutoConfigurationTests {
...
@@ -55,16 +55,19 @@ public class Neo4jAutoConfigurationTests {
public
void
defaultConfiguration
()
{
public
void
defaultConfiguration
()
{
load
(
null
,
"spring.data.neo4j.uri=http://localhost:8989"
);
load
(
null
,
"spring.data.neo4j.uri=http://localhost:8989"
);
assertThat
(
this
.
context
.
getBeansOfType
(
Neo4jOperations
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
Neo4jOperations
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
))
.
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
SessionFactory
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
SessionFactory
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeanDefinition
(
"scopedTarget.getSession"
).
getScope
()).
isEqualTo
(
"singleton"
);
assertThat
(
this
.
context
.
getBeanDefinition
(
"scopedTarget.getSession"
).
getScope
())
.
isEqualTo
(
"singleton"
);
}
}
@Test
@Test
public
void
customScope
()
{
public
void
customScope
()
{
load
(
null
,
"spring.data.neo4j.uri=http://localhost:8989"
,
load
(
null
,
"spring.data.neo4j.uri=http://localhost:8989"
,
"spring.data.neo4j.session.scope=prototype"
);
"spring.data.neo4j.session.scope=prototype"
);
assertThat
(
this
.
context
.
getBeanDefinition
(
"scopedTarget.getSession"
).
getScope
()).
isEqualTo
(
"prototype"
);
assertThat
(
this
.
context
.
getBeanDefinition
(
"scopedTarget.getSession"
).
getScope
())
.
isEqualTo
(
"prototype"
);
}
}
@Test
@Test
...
@@ -72,7 +75,8 @@ public class Neo4jAutoConfigurationTests {
...
@@ -72,7 +75,8 @@ public class Neo4jAutoConfigurationTests {
load
(
CustomNeo4jOperations
.
class
);
load
(
CustomNeo4jOperations
.
class
);
assertThat
(
this
.
context
.
getBean
(
Neo4jOperations
.
class
))
assertThat
(
this
.
context
.
getBean
(
Neo4jOperations
.
class
))
.
isSameAs
(
this
.
context
.
getBean
(
"myNeo4jOperations"
));
.
isSameAs
(
this
.
context
.
getBean
(
"myNeo4jOperations"
));
assertThat
(
this
.
context
.
getBeansOfType
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)).
hasSize
(
0
);
assertThat
(
this
.
context
.
getBeansOfType
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
))
.
hasSize
(
0
);
assertThat
(
this
.
context
.
getBeansOfType
(
SessionFactory
.
class
)).
hasSize
(
0
);
assertThat
(
this
.
context
.
getBeansOfType
(
SessionFactory
.
class
)).
hasSize
(
0
);
assertThat
(
this
.
context
.
getBeansOfType
(
Session
.
class
)).
hasSize
(
0
);
assertThat
(
this
.
context
.
getBeansOfType
(
Session
.
class
)).
hasSize
(
0
);
}
}
...
@@ -83,7 +87,8 @@ public class Neo4jAutoConfigurationTests {
...
@@ -83,7 +87,8 @@ public class Neo4jAutoConfigurationTests {
assertThat
(
this
.
context
.
getBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
))
assertThat
(
this
.
context
.
getBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
))
.
isSameAs
(
this
.
context
.
getBean
(
"myConfiguration"
));
.
isSameAs
(
this
.
context
.
getBean
(
"myConfiguration"
));
assertThat
(
this
.
context
.
getBeansOfType
(
Neo4jOperations
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
Neo4jOperations
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
))
.
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
SessionFactory
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
SessionFactory
.
class
)).
hasSize
(
1
);
}
}
...
@@ -109,14 +114,14 @@ public class Neo4jAutoConfigurationTests {
...
@@ -109,14 +114,14 @@ public class Neo4jAutoConfigurationTests {
}
}
@Configuration
@Configuration
static
class
CustomConfiguration
{
static
class
CustomConfiguration
{
@Bean
@Bean
public
org
.
neo4j
.
ogm
.
config
.
Configuration
myConfiguration
()
{
public
org
.
neo4j
.
ogm
.
config
.
Configuration
myConfiguration
()
{
org
.
neo4j
.
ogm
.
config
.
Configuration
configuration
=
new
org
.
neo4j
.
ogm
.
config
.
Configuration
();
org
.
neo4j
.
ogm
.
config
.
Configuration
configuration
=
new
org
.
neo4j
.
ogm
.
config
.
Configuration
();
configuration
.
driverConfiguration
().
setDriverClassName
(
HttpDriver
.
class
.
getName
());
configuration
.
driverConfiguration
()
.
setDriverClassName
(
HttpDriver
.
class
.
getName
());
return
configuration
;
return
configuration
;
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jPropertiesTests.java
View file @
c68e5f12
...
@@ -68,8 +68,7 @@ public class Neo4jPropertiesTests {
...
@@ -68,8 +68,7 @@ public class Neo4jPropertiesTests {
Neo4jProperties
properties
=
load
(
true
,
Neo4jProperties
properties
=
load
(
true
,
"spring.data.neo4j.uri=http://localhost:7474"
);
"spring.data.neo4j.uri=http://localhost:7474"
);
Configuration
configuration
=
properties
.
createConfiguration
();
Configuration
configuration
=
properties
.
createConfiguration
();
assertDriver
(
configuration
,
Neo4jProperties
.
HTTP_DRIVER
,
assertDriver
(
configuration
,
Neo4jProperties
.
HTTP_DRIVER
,
"http://localhost:7474"
);
"http://localhost:7474"
);
}
}
@Test
@Test
...
@@ -85,11 +84,9 @@ public class Neo4jPropertiesTests {
...
@@ -85,11 +84,9 @@ public class Neo4jPropertiesTests {
public
void
credentialsAreSet
()
{
public
void
credentialsAreSet
()
{
Neo4jProperties
properties
=
load
(
true
,
Neo4jProperties
properties
=
load
(
true
,
"spring.data.neo4j.uri=http://localhost:7474"
,
"spring.data.neo4j.uri=http://localhost:7474"
,
"spring.data.neo4j.username=user"
,
"spring.data.neo4j.username=user"
,
"spring.data.neo4j.password=secret"
);
"spring.data.neo4j.password=secret"
);
Configuration
configuration
=
properties
.
createConfiguration
();
Configuration
configuration
=
properties
.
createConfiguration
();
assertDriver
(
configuration
,
Neo4jProperties
.
HTTP_DRIVER
,
assertDriver
(
configuration
,
Neo4jProperties
.
HTTP_DRIVER
,
"http://localhost:7474"
);
"http://localhost:7474"
);
assertCredentials
(
configuration
,
"user"
,
"secret"
);
assertCredentials
(
configuration
,
"user"
,
"secret"
);
}
}
...
@@ -121,15 +118,15 @@ public class Neo4jPropertiesTests {
...
@@ -121,15 +118,15 @@ public class Neo4jPropertiesTests {
"target/neo4j/my.db"
);
"target/neo4j/my.db"
);
}
}
private
static
void
assertDriver
(
Configuration
actual
,
String
driver
,
private
static
void
assertDriver
(
Configuration
actual
,
String
driver
,
String
uri
)
{
String
uri
)
{
assertThat
(
actual
).
isNotNull
();
assertThat
(
actual
).
isNotNull
();
DriverConfiguration
driverConfig
=
actual
.
driverConfiguration
();
DriverConfiguration
driverConfig
=
actual
.
driverConfiguration
();
assertThat
(
driverConfig
.
getDriverClassName
()).
isEqualTo
(
driver
);
assertThat
(
driverConfig
.
getDriverClassName
()).
isEqualTo
(
driver
);
assertThat
(
driverConfig
.
getURI
()).
isEqualTo
(
uri
);
assertThat
(
driverConfig
.
getURI
()).
isEqualTo
(
uri
);
}
}
private
static
void
assertCredentials
(
Configuration
actual
,
String
username
,
String
password
)
{
private
static
void
assertCredentials
(
Configuration
actual
,
String
username
,
String
password
)
{
Credentials
credentials
=
actual
.
driverConfiguration
().
getCredentials
();
Credentials
credentials
=
actual
.
driverConfiguration
().
getCredentials
();
if
(
username
==
null
&
password
==
null
)
{
if
(
username
==
null
&
password
==
null
)
{
assertThat
(
credentials
).
isNull
();
assertThat
(
credentials
).
isNull
();
...
@@ -138,8 +135,8 @@ public class Neo4jPropertiesTests {
...
@@ -138,8 +135,8 @@ public class Neo4jPropertiesTests {
assertThat
(
credentials
).
isNotNull
();
assertThat
(
credentials
).
isNotNull
();
Object
content
=
credentials
.
credentials
();
Object
content
=
credentials
.
credentials
();
assertThat
(
content
).
isInstanceOf
(
String
.
class
);
assertThat
(
content
).
isInstanceOf
(
String
.
class
);
String
[]
auth
=
new
String
(
Base64
.
decode
(((
String
)
content
)
String
[]
auth
=
new
String
(
Base64
.
decode
(((
String
)
content
)
.
getBytes
()))
.
getBytes
())).
split
(
":"
);
.
split
(
":"
);
assertThat
(
auth
[
0
]).
isEqualTo
(
username
);
assertThat
(
auth
[
0
]).
isEqualTo
(
username
);
assertThat
(
auth
[
1
]).
isEqualTo
(
password
);
assertThat
(
auth
[
1
]).
isEqualTo
(
password
);
assertThat
(
auth
).
hasSize
(
2
);
assertThat
(
auth
).
hasSize
(
2
);
...
@@ -148,24 +145,23 @@ public class Neo4jPropertiesTests {
...
@@ -148,24 +145,23 @@ public class Neo4jPropertiesTests {
public
Neo4jProperties
load
(
final
boolean
embeddedAvailable
,
String
...
environment
)
{
public
Neo4jProperties
load
(
final
boolean
embeddedAvailable
,
String
...
environment
)
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
setClassLoader
(
ctx
.
setClassLoader
(
new
URLClassLoader
(
new
URL
[
0
],
getClass
().
getClassLoader
())
{
new
URLClassLoader
(
new
URL
[
0
],
getClass
().
getClassLoader
())
{
@Override
@Override
protected
Class
<?>
loadClass
(
String
name
,
boolean
resolve
)
protected
Class
<?>
loadClass
(
String
name
,
boolean
resolve
)
throws
ClassNotFoundException
{
throws
ClassNotFoundException
{
if
(
name
.
equals
(
Neo4jProperties
.
EMBEDDED_DRIVER
))
{
if
(
name
.
equals
(
Neo4jProperties
.
EMBEDDED_DRIVER
))
{
if
(
embeddedAvailable
)
{
if
(
embeddedAvailable
)
{
return
TestEmbeddedDriver
.
class
;
return
TestEmbeddedDriver
.
class
;
}
}
else
{
else
{
throw
new
ClassNotFoundException
();
throw
new
ClassNotFoundException
();
}
}
return
super
.
loadClass
(
name
,
resolve
);
}
}
}
return
super
.
loadClass
(
name
,
resolve
);
}
});
});
EnvironmentTestUtils
.
addEnvironment
(
ctx
,
environment
);
EnvironmentTestUtils
.
addEnvironment
(
ctx
,
environment
);
ctx
.
register
(
TestConfiguration
.
class
);
ctx
.
register
(
TestConfiguration
.
class
);
ctx
.
refresh
();
ctx
.
refresh
();
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
c68e5f12
...
@@ -3055,6 +3055,8 @@ properties:
...
@@ -3055,6 +3055,8 @@ properties:
spring.data.neo4j.password=secret
spring.data.neo4j.password=secret
----
----
[[boot-features-connecting-to-neo4j-embedded]]
[[boot-features-connecting-to-neo4j-embedded]]
==== Using the embedded mode
==== Using the embedded mode
...
@@ -3071,6 +3073,8 @@ persistence for the embedded mode:
...
@@ -3071,6 +3073,8 @@ persistence for the embedded mode:
spring.data.neo4j.uri=file://var/tmp/graph.db
spring.data.neo4j.uri=file://var/tmp/graph.db
----
----
[[boot-features-neo4j-ogm-session]]
[[boot-features-neo4j-ogm-session]]
==== Neo4jSession
==== Neo4jSession
...
...
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