Soap集成测试仅加载测试的端点,而不是所有端点

问题描述 投票:0回答:1

我有一个问题:什么是正确的配置,以仅加载我要在该集成测试中测试的Enpoint类,而不加载整个应用程序上下文(不是所有Enpoint类)?现在我有:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {WebServiceConfigTest.class}, properties = {"application.address=http://hostname:port/context"})
public class MyEndpointTest {

@Autowired
private ApplicationContext applicationContext;

private MockWebServiceClient mockClient;


@Before
public void init() {
    mockClient = MockWebServiceClient.createClient(applicationContext);
    MockitoAnnotations.initMocks(this);
}
@Test
public void test1(){}
....
}

在WebServiceConfigTest中为:

@ComponentScan("mypackages.soap")
@ContextConfiguration(classes = SoapApplication.class)
@MockBean(classes = {MyService.class})
public class WebServiceConfigTest {
}

SoapApplication是:

@ComponentScan({"mypackages"})
@SpringBootApplication
public class SoapApplication extends SpringBootServletInitializer implements WebApplicationInitializer {

 public static void main(String[] args) {
     SpringApplication.run(SoapApplication.class, args);
 }
}

原因是在Soap模块中,我有一个Service模块的依赖项,而Service模块也有其他依赖项,依此类推。如果我加载整个ApplicaitonContext,则:

  • 或者我都需要模拟我在Soap模块中使用的服务的完整列表
  • 或模拟服务模块的底层依赖关系,例如数据源,队列等。>
  • 如果第二步,将使Soap模块意识到它不应该知道的事情。如果我先这样做,则必须模拟并在config测试文件中维护使用的服务的完整列表,该列表可能很长。

这里有什么建议吗?

我有一个疑问:什么是正确的配置,它仅加载要在该集成测试中测试的Enpoint类,而不是整个应用程序上下文(不是所有Enpoint类)? ...

java spring-boot soap spring-test spring-ws
1个回答
0
投票

什么是正确的配置,它仅加载我要在该集成测试中测试的Endpoint类,而不加载整个Application上下文,所以>

© www.soinside.com 2019 - 2024. All rights reserved.