Polish "Support of Neo4j auto-index configuration"
Closes gh-8843
This commit is contained in:
parent
779733c379
commit
144868a3ce
|
|
@ -61,13 +61,13 @@ public class Neo4jProperties implements ApplicationContextAware {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
private final Embedded embedded = new Embedded();
|
||||
|
||||
/**
|
||||
* Index generation behaviour. {@link AutoIndexMode#NONE} by default.
|
||||
* Auto index mode.
|
||||
*/
|
||||
private AutoIndexMode autoIndex = AutoIndexMode.NONE;
|
||||
|
||||
private final Embedded embedded = new Embedded();
|
||||
|
||||
private ClassLoader classLoader = Neo4jProperties.class.getClassLoader();
|
||||
|
||||
public String getUri() {
|
||||
|
|
@ -94,10 +94,6 @@ public class Neo4jProperties implements ApplicationContextAware {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public Embedded getEmbedded() {
|
||||
return this.embedded;
|
||||
}
|
||||
|
||||
public AutoIndexMode getAutoIndex() {
|
||||
return this.autoIndex;
|
||||
}
|
||||
|
|
@ -106,6 +102,10 @@ public class Neo4jProperties implements ApplicationContextAware {
|
|||
this.autoIndex = autoIndex;
|
||||
}
|
||||
|
||||
public Embedded getEmbedded() {
|
||||
return this.embedded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
|
||||
this.classLoader = ctx.getClassLoader();
|
||||
|
|
@ -131,8 +131,7 @@ public class Neo4jProperties implements ApplicationContextAware {
|
|||
if (this.username != null && this.password != null) {
|
||||
builder.credentials(this.username, this.password);
|
||||
}
|
||||
|
||||
builder.autoIndex(this.getAutoIndex().name());
|
||||
builder.autoIndex(this.getAutoIndex().getName());
|
||||
}
|
||||
|
||||
private void configureUriWithDefaults(Builder builder) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.data.neo4j;
|
|||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.neo4j.ogm.config.AutoIndexMode;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
import org.neo4j.ogm.session.event.Event;
|
||||
|
|
@ -33,7 +32,6 @@ import org.springframework.boot.autoconfigure.data.neo4j.city.City;
|
|||
import org.springframework.boot.autoconfigure.data.neo4j.country.Country;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
@ -58,7 +56,6 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Vince Bickers
|
||||
* @author Andy Wilkinson
|
||||
* @author Kazuki Shimizu
|
||||
* @author Aurélien Leboulanger
|
||||
*/
|
||||
public class Neo4jDataAutoConfigurationTests {
|
||||
|
||||
|
|
@ -142,25 +139,6 @@ public class Neo4jDataAutoConfigurationTests {
|
|||
.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) {
|
||||
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
||||
|
|
@ -196,21 +174,6 @@ 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
|
||||
static class CustomConfiguration {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.net.URLClassLoader;
|
|||
import com.hazelcast.util.Base64;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.neo4j.ogm.config.AutoIndexMode;
|
||||
import org.neo4j.ogm.config.Configuration;
|
||||
import org.neo4j.ogm.config.Credentials;
|
||||
|
||||
|
|
@ -106,6 +107,20 @@ public class Neo4jPropertiesTests {
|
|||
assertCredentials(configuration, "user", "secret");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoIndexNoneByDefault() {
|
||||
Neo4jProperties properties = load(true);
|
||||
Configuration configuration = properties.createConfiguration();
|
||||
assertThat(configuration.getAutoIndex()).isEqualTo(AutoIndexMode.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoIndexCanBeConfigured() {
|
||||
Neo4jProperties properties = load(true, "spring.data.neo4j.auto-index=validate");
|
||||
Configuration configuration = properties.createConfiguration();
|
||||
assertThat(configuration.getAutoIndex()).isEqualTo(AutoIndexMode.VALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void embeddedModeDisabledUseBoltUri() {
|
||||
Neo4jProperties properties = load(true,
|
||||
|
|
|
|||
|
|
@ -613,13 +613,13 @@ content into your application; rather pick only the properties that you need.
|
|||
spring.data.redis.repositories.enabled=true # Enable Redis repositories.
|
||||
|
||||
# NEO4J ({sc-spring-boot-autoconfigure}/neo4j/Neo4jProperties.{sc-ext}[Neo4jProperties])
|
||||
spring.data.neo4j.auto-index=none # Auto index mode.
|
||||
spring.data.neo4j.embedded.enabled=true # Enable embedded mode if the embedded driver is available.
|
||||
spring.data.neo4j.open-in-view=false # Register OpenSessionInViewInterceptor. Binds a Neo4j Session to the thread for the entire processing of the request.
|
||||
spring.data.neo4j.password= # Login password of the server.
|
||||
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.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])
|
||||
spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources.
|
||||
|
|
|
|||
Loading…
Reference in New Issue