Пытаюсь использовать тесты Junit для создания документации с использованием Spring Rest Docs, но я получаю эти ошибки, которые я не могу определить, откуда они берутся.Я младший разработчик, поэтому неопытность может быть частью этого.
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:47)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ALC012Client' defined in URL [jar:file:/C:/ProgramData/Maven/.m2/repository/com/jbhunt/order/lib_ordermanagement_alc012/2.0.2/lib_ordermanagement_alc012-2.0.2.jar!/com/jbhunt/ordermanagement/order/alc012/client/ALC012Client.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servicePortConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servicePortConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
Caused by: java.lang.IllegalArgumentException
at com.sun.xml.ws.client.RequestContext.setEndPointAddressString(RequestContext.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jvnet.ws.message.BasePropertySet$MethodAccessor.set(BasePropertySet.java:249)
at org.jvnet.ws.message.BasePropertySet$MapView.put(BasePropertySet.java:325)
at org.jvnet.ws.message.BasePropertySet$MapView.put(BasePropertySet.java:280)
at org.jvnet.ws.message.BaseDistributedPropertySet$DistributedMapView.put(BaseDistributedPropertySet.java:250)
at org.jvnet.ws.message.BaseDistributedPropertySet$DistributedMapView.put(BaseDistributedPropertySet.java:212)
at com.jbhunt.ordermanagement.order.alc012.configuration.ServicePortConfiguration.oec170Port(ServicePortConfiguration.java:45)
at com.jbhunt.ordermanagement.order.alc012.configuration.ServicePortConfigurationinitServicePortConfiguration(ServicePortConfiguration.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
... 182 more
Я не могу показать слишком много кода, потому что это балансовая единица, но вот аннотации и немного кода.В основном я просто пытаюсь определить, откуда может возникнуть проблема.
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@Transactional
public class DocumentControllerTest {
@Autowired
PIDCredentials pidCredentials;
@MockBean
EOIClient eooiClient;
@MockBean
private DocumentService documentService;
@Autowired
private WebApplicationContext webApplicationContext;
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");
@Autowired
private ObjectMapper objectMapper = new ObjectMapper();
private MockMvc mockMvc;
private RestDocumentationResultHandler documentResultHandler;
@Test
public void testfindallDocumentClasses() throws Exception {
Map<String, String> documentListDTO = null;
Mockito.when(documentService.findAllDocumentClasses()).thenReturn(documentListDTO);
this.mockMvc.perform(get("/search/findalldocumentclasses")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("find-all-document-classes"));
}
}