Ссылка на репозиторий GitHub
ТЕСТ Junit
@DataMongoTest
@RunWith(SpringRunner.class)
public class ItemReactiveRepositoryTest {
@Autowired
ItemReactiveRepository itemReactiveRepository;
...
}
Интерфейс репозитория
public interface ItemReactiveRepository extends ReactiveMongoRepository<Item,String> {
}
Класс элемента
@Document
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Item {
@Id
private String id;
private String description;
private Double price;
public Item(String id, String description, double price) {
this.id = id;
this.description = description;
this.price = price;
}
}
Когда я запускаю тест, пн go Сервер отключается с ошибкой - java .io.IOException: Не удается запустить процесс: EOF
Я знаю, что во время выполнения тестов пружина использует встроенный пн go , Таким образом, когда не работает ни один сервер mon go, тесты проходят успешно. Но когда работает настоящий сервер, я получаю вышеуказанную ошибку при выполнении тестов. При нормальном запуске приложения ошибки не возникает.
Caused by: java.io.IOException: Could not start process: <EOF>
at de.flapdoodle.embed.mongo.AbstractMongoProcess.onAfterProcessStart(AbstractMongoProcess.java:79)
at de.flapdoodle.embed.process.runtime.AbstractProcess.<init>(AbstractProcess.java:116)
at de.flapdoodle.embed.mongo.AbstractMongoProcess.<init>(AbstractMongoProcess.java:53)
at de.flapdoodle.embed.mongo.MongodProcess.<init>(MongodProcess.java:50)
at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:44)
at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:34)
at de.flapdoodle.embed.process.runtime.Executable.start(Executable.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1922)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1864)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
... 65 more
com.learnreactivespring.repository.ItemReactiveRepositoryTest > findAllTest FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1796
Caused by: java.io.IOException at AbstractMongoProcess.java:79
2020-03-23 13:56:06.848 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.848+0530 I - [conn2] end connection 127.0.0.1:52130 (2 connections now open)
2020-03-23 13:56:06.849 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.849+0530 I NETWORK [thread1] connection accepted from 127.0.0.1:52167 #3 (2 connections now open)
2020-03-23 13:56:06.849 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.849+0530 I COMMAND [conn3] terminating, shutdown command received
2020-03-23 13:56:06.849 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.849+0530 I NETWORK [conn3] shutdown: going to close listening sockets...
2020-03-23 13:56:06.849 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.849+0530 I NETWORK [conn3] closing listening socket: 772
2020-03-23 13:56:06.849 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.849+0530 I NETWORK [conn3] shutdown: going to flush diaglog...
2020-03-23 13:56:06.849 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.849+0530 I FTDC [conn3] Shutting down full-time diagnostic data capture
2020-03-23 13:56:06.882 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:06.882+0530 I STORAGE [conn3] WiredTigerKVEngine shutting down
2020-03-23 13:56:07.303 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:07.304+0530 I STORAGE [conn3] shutdown: removing fs lock...
2020-03-23 13:56:07.303 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:07.304+0530 I CONTROL [conn3] now exiting
2020-03-23 13:56:07.304 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:07.304+0530 I CONTROL [conn3] shutting down with code:0
2020-03-23 13:56:07.304 INFO 19960 --- [ Thread-8] o.s.b.a.mongo.embedded.EmbeddedMongo : 2020-03-23T13:56:07.304+0530 I CONTROL [initandlisten] shutting down with code:0
1 test completed, 1 failed
> Task :test FAILED
FAILURE: Build failed with an exception.
2020-03-23 13:55:58.780 INFO 19960 --- [ Test worker] d.f.e.process.runtime.AbstractProcess : construct de.flapdoodle.embed.mongo.config.MongodConfigBuilder$ImmutableMongodConfig@538dc7f7
2020-03-23 13:55:59.545 WARN 19960 --- [ Test worker] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedMongoServer' defined in class path resource [org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.class]: Invocation of init method failed; nested exception is java.io.IOException: Could not start process: <EOF>