Start building against Spring Data Kay snapshots
See gh-7461
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import java.util.Collections;
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -161,7 +162,7 @@ public class MongoDataAutoConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DB getDb() throws DataAccessException {
|
||||
public MongoDatabase getDb() throws DataAccessException {
|
||||
String gridFsDatabase = this.properties.getGridFsDatabase();
|
||||
if (StringUtils.hasText(gridFsDatabase)) {
|
||||
return this.mongoDbFactory.getDb(gridFsDatabase);
|
||||
@@ -170,7 +171,7 @@ public class MongoDataAutoConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DB getDb(String dbName) throws DataAccessException {
|
||||
public MongoDatabase getDb(String dbName) throws DataAccessException {
|
||||
return this.mongoDbFactory.getDb(dbName);
|
||||
}
|
||||
|
||||
@@ -179,6 +180,11 @@ public class MongoDataAutoConfiguration {
|
||||
return this.mongoDbFactory.getExceptionTranslator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DB getLegacyDb() {
|
||||
return this.mongoDbFactory.getLegacyDb();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.boot.autoconfigure.mongo.embedded;
|
||||
import java.io.File;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import com.mongodb.CommandResult;
|
||||
import com.mongodb.MongoClient;
|
||||
import de.flapdoodle.embed.mongo.config.IMongodConfig;
|
||||
import de.flapdoodle.embed.mongo.config.Storage;
|
||||
import de.flapdoodle.embed.mongo.distribution.Feature;
|
||||
import org.bson.Document;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -82,8 +82,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
load();
|
||||
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
||||
MongoClient client = this.context.getBean(MongoClient.class);
|
||||
Integer mongoPort = Integer.valueOf(
|
||||
this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||
Integer mongoPort = Integer
|
||||
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
load("spring.data.mongodb.port=0");
|
||||
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
||||
MongoClient client = this.context.getBean(MongoClient.class);
|
||||
Integer mongoPort = Integer.valueOf(
|
||||
this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||
Integer mongoPort = Integer
|
||||
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
public void randomlyAllocatedPortIsAvailableWhenCreatingMongoClient() {
|
||||
load(MongoClientConfiguration.class);
|
||||
MongoClient client = this.context.getBean(MongoClient.class);
|
||||
Integer mongoPort = Integer.valueOf(
|
||||
this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||
Integer mongoPort = Integer
|
||||
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
|
||||
CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");
|
||||
Document buildInfo = mongo.executeCommand("{ buildInfo: 1 }");
|
||||
|
||||
assertThat(buildInfo.getString("version")).isEqualTo(expectedVersion);
|
||||
}
|
||||
@@ -187,8 +187,7 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
ctx.register(config);
|
||||
}
|
||||
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
||||
ctx.register(EmbeddedMongoAutoConfiguration.class,
|
||||
MongoAutoConfiguration.class,
|
||||
ctx.register(EmbeddedMongoAutoConfiguration.class, MongoAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
ctx.refresh();
|
||||
this.context = ctx;
|
||||
|
||||
Reference in New Issue
Block a user