本文整理匯總了Java中org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration類的典型用法代碼示例。如果您正苦於以下問題:Java MongoAutoConfiguration類的具體用法?Java MongoAutoConfiguration怎麽用?Java MongoAutoConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MongoAutoConfiguration類屬於org.springframework.boot.autoconfigure.mongo包,在下文中一共展示了MongoAutoConfiguration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: gridFsTemplateExists
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void gridFsTemplateExists() {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.mongodb.gridFsDatabase:grid");
this.context.register(PropertyPlaceholderAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBeanNamesForType(GridFsTemplate.class).length)
.isEqualTo(1);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:MongoDataAutoConfigurationTests.java
示例2: assertVersionConfiguration
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
private void assertVersionConfiguration(String configuredVersion,
String expectedVersion) {
this.context = new AnnotationConfigApplicationContext();
int mongoPort = SocketUtils.findAvailableTcpPort();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.mongodb.port=" + mongoPort);
if (configuredVersion != null) {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mongodb.embedded.version=" + configuredVersion);
}
this.context.register(MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
this.context.refresh();
MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");
assertThat(buildInfo.getString("version")).isEqualTo(expectedVersion);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:19,代碼來源:EmbeddedMongoAutoConfigurationTests.java
示例3: testFieldNamingStrategy
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
public void testFieldNamingStrategy(String strategy,
Class<? extends FieldNamingStrategy> expectedType) {
this.context = new AnnotationConfigApplicationContext();
if (strategy != null) {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.mongodb.field-naming-strategy:" + strategy);
}
this.context.register(PropertyPlaceholderAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
this.context.refresh();
MongoMappingContext mappingContext = this.context
.getBean(MongoMappingContext.class);
FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils
.getField(mappingContext, "fieldNamingStrategy");
assertThat(fieldNamingStrategy.getClass()).isEqualTo(expectedType);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:MongoDataAutoConfigurationTests.java
示例4: assertVersionConfiguration
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
private void assertVersionConfiguration(String configuredVersion,
String expectedVersion) {
this.context = new AnnotationConfigApplicationContext();
int mongoPort = SocketUtils.findAvailableTcpPort();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.mongodb.port=" + mongoPort);
if (configuredVersion != null) {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mongodb.embedded.version=" + configuredVersion);
}
this.context.register(MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
this.context.refresh();
MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");
assertThat(buildInfo.getString("version"), equalTo(expectedVersion));
}
示例5: testFieldNamingStrategy
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
public void testFieldNamingStrategy(String strategy,
Class<? extends FieldNamingStrategy> expectedType) {
this.context = new AnnotationConfigApplicationContext();
if (strategy != null) {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.mongodb.field-naming-strategy:" + strategy);
}
this.context.register(PropertyPlaceholderAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
this.context.refresh();
MongoMappingContext mappingContext = this.context
.getBean(MongoMappingContext.class);
FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils
.getField(mappingContext, "fieldNamingStrategy");
assertEquals(expectedType, fieldNamingStrategy.getClass());
}
示例6: mongoHealthIndicator
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void mongoHealthIndicator() {
this.context.register(MongoAutoConfiguration.class,
ManagementServerProperties.class, MongoDataAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
this.context.refresh();
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertThat(beans).hasSize(1);
assertThat(beans.values().iterator().next().getClass())
.isEqualTo(MongoHealthIndicator.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:15,代碼來源:HealthIndicatorAutoConfigurationTests.java
示例7: notMongoHealthIndicator
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void notMongoHealthIndicator() {
this.context.register(MongoAutoConfiguration.class,
ManagementServerProperties.class, MongoDataAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.mongo.enabled:false",
"management.health.diskspace.enabled:false");
this.context.refresh();
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertThat(beans).hasSize(1);
assertThat(beans.values().iterator().next().getClass())
.isEqualTo(ApplicationHealthIndicator.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:16,代碼來源:HealthIndicatorAutoConfigurationTests.java
示例8: combinedHealthIndicator
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void combinedHealthIndicator() {
this.context.register(MongoAutoConfiguration.class, RedisAutoConfiguration.class,
MongoDataAutoConfiguration.class, SolrAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class);
this.context.refresh();
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertThat(beans).hasSize(4);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:HealthIndicatorAutoConfigurationTests.java
示例9: indicatorExists
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void indicatorExists() {
this.context = new AnnotationConfigApplicationContext(
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class, EndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class);
assertThat(this.context.getBeanNamesForType(MongoTemplate.class).length)
.isEqualTo(1);
MongoHealthIndicator healthIndicator = this.context
.getBean(MongoHealthIndicator.class);
assertThat(healthIndicator).isNotNull();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:MongoHealthIndicatorTests.java
示例10: mongoSessionStore
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void mongoSessionStore() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
"spring.session.store-type=mongo", "spring.data.mongodb.port=0");
validateSessionRepository(MongoOperationsSessionRepository.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:SessionAutoConfigurationTests.java
示例11: mongoSessionStoreWithCustomizations
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void mongoSessionStoreWithCustomizations() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
"spring.session.store-type=mongo", "spring.data.mongodb.port=0",
"spring.session.mongo.collection-name=foobar");
MongoOperationsSessionRepository repository = validateSessionRepository(
MongoOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("collectionName"))
.isEqualTo("foobar");
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:SessionAutoConfigurationTests.java
示例12: selectImports
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
List<String> names = new ArrayList<String>();
for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class,
MongoRepositoriesAutoConfiguration.class }) {
names.add(type.getName());
}
return names.toArray(new String[0]);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:MixedMongoRepositoriesAutoConfigurationTests.java
示例13: templateExists
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void templateExists() {
this.context = new AnnotationConfigApplicationContext(
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class);
assertThat(this.context.getBeanNamesForType(MongoTemplate.class).length)
.isEqualTo(1);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:9,代碼來源:MongoDataAutoConfigurationTests.java
示例14: customConversions
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void customConversions() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(CustomConversionsConfig.class);
this.context.register(PropertyPlaceholderAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
this.context.refresh();
MongoTemplate template = this.context.getBean(MongoTemplate.class);
assertThat(template.getConverter().getConversionService().canConvert(Mongo.class,
Boolean.class)).isTrue();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:MongoDataAutoConfigurationTests.java
示例15: usesAutoConfigurationPackageToPickUpDocumentTypes
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; //導入依賴的package包/類
@Test
public void usesAutoConfigurationPackageToPickUpDocumentTypes() {
this.context = new AnnotationConfigApplicationContext();
String cityPackage = City.class.getPackage().getName();
AutoConfigurationPackages.register(this.context, cityPackage);
this.context.register(MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class);
this.context.refresh();
assertDomainTypesDiscovered(this.context.getBean(MongoMappingContext.class),
City.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:MongoDataAutoConfigurationTests.java