fix: add embedded properties to tests (#12714)

This commit is contained in:
lucaCambi77 2022-09-11 11:54:49 +02:00 committed by GitHub
parent 66944937b5
commit eebbdf82d9
8 changed files with 18 additions and 8 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@SpringBootApplication(exclude = EmbeddedMongoAutoConfiguration.class) @SpringBootApplication
@PropertySource("classpath:boot.collection.name/app.properties") @PropertySource("classpath:boot.collection.name/app.properties")
@EnableMongoRepositories(basePackages = { "com.baeldung.boot.collection.name" }) @EnableMongoRepositories(basePackages = { "com.baeldung.boot.collection.name" })
public class SpringBootCollectionNameApplication { public class SpringBootCollectionNameApplication {

View File

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@SpringBootApplication(exclude = EmbeddedMongoAutoConfiguration.class) @SpringBootApplication
@EnableMongoRepositories(basePackages = { "com.baeldung.boot.composite.key" }) @EnableMongoRepositories(basePackages = { "com.baeldung.boot.composite.key" })
public class SpringBootCompositeKeyApplication { public class SpringBootCompositeKeyApplication {
public static void main(String... args) { public static void main(String... args) {

View File

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@SpringBootApplication(exclude = EmbeddedMongoAutoConfiguration.class) @SpringBootApplication
@EnableMongoRepositories(basePackages = { "com.baeldung.boot.count" }) @EnableMongoRepositories(basePackages = { "com.baeldung.boot.count" })
public class SpringBootCountApplication { public class SpringBootCountApplication {
public static void main(String... args) { public static void main(String... args) {

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoCo
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@SpringBootApplication(exclude = EmbeddedMongoAutoConfiguration.class) @SpringBootApplication
@PropertySource("classpath:boot.unique.field/app.properties") @PropertySource("classpath:boot.unique.field/app.properties")
@EnableMongoRepositories(basePackages = { "com.baeldung.boot.unique.field" }) @EnableMongoRepositories(basePackages = { "com.baeldung.boot.unique.field" })
public class SpringBootUniqueFieldApplication { public class SpringBootUniqueFieldApplication {

View File

@ -10,16 +10,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.boot.collection.name.SpringBootCollectionNameApplication;
import com.baeldung.boot.collection.name.data.Compilation; import com.baeldung.boot.collection.name.data.Compilation;
import com.baeldung.boot.collection.name.data.MusicAlbum; import com.baeldung.boot.collection.name.data.MusicAlbum;
import com.baeldung.boot.collection.name.data.MusicTrack; import com.baeldung.boot.collection.name.data.MusicTrack;
import com.baeldung.boot.collection.name.data.Store; import com.baeldung.boot.collection.name.data.Store;
@SpringBootTest @SpringBootTest(classes = SpringBootCollectionNameApplication.class)
@DirtiesContext @DirtiesContext
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@TestPropertySource("/embedded.properties")
public class MusicStoreServiceIntegrationTest { public class MusicStoreServiceIntegrationTest {
@Autowired @Autowired
private MusicStoreService service; private MusicStoreService service;

View File

@ -12,15 +12,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.boot.composite.key.data.Ticket; import com.baeldung.boot.composite.key.data.Ticket;
import com.baeldung.boot.composite.key.data.TicketId; import com.baeldung.boot.composite.key.data.TicketId;
import com.baeldung.boot.composite.key.service.CustomerService; import com.baeldung.boot.composite.key.service.CustomerService;
@SpringBootTest @SpringBootTest(classes = SpringBootCompositeKeyApplication.class)
@DirtiesContext @DirtiesContext
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@TestPropertySource("/embedded.properties")
public class CustomerServiceIntegrationTest { public class CustomerServiceIntegrationTest {
@Autowired @Autowired
private CustomerService service; private CustomerService service;

View File

@ -10,13 +10,16 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.boot.count.SpringBootCountApplication;
import com.baeldung.boot.count.data.Car; import com.baeldung.boot.count.data.Car;
@SpringBootTest @SpringBootTest(classes = SpringBootCountApplication.class)
@DirtiesContext @DirtiesContext
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@TestPropertySource("/embedded.properties")
public class CountCarServiceIntegrationTest { public class CountCarServiceIntegrationTest {
@Autowired @Autowired
private CountCarService service; private CountCarService service;

View File

@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.boot.unique.field.dao.AssetRepository; import com.baeldung.boot.unique.field.dao.AssetRepository;
@ -20,9 +21,10 @@ import com.baeldung.boot.unique.field.data.Customer;
import com.baeldung.boot.unique.field.data.Sale; import com.baeldung.boot.unique.field.data.Sale;
import com.baeldung.boot.unique.field.data.SaleId; import com.baeldung.boot.unique.field.data.SaleId;
@SpringBootTest @SpringBootTest(classes = SpringBootUniqueFieldApplication.class)
@DirtiesContext @DirtiesContext
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@TestPropertySource("/embedded.properties")
public class UniqueFieldIntegrationTest { public class UniqueFieldIntegrationTest {
@Autowired @Autowired
private SaleRepository saleRepo; private SaleRepository saleRepo;