我进行了集成测试,我使用Arquillian和ShrinkWrap解析器在Wildfly中部署了2个Web服务。这两种服务都是独立的,因此在任何Maven依赖性意义上都不依赖于另一种服务。服务2对服务1进行HTTP调用。这纯粹是一种B2B方案,其中一个组件调用另一个组件。 那就是说,这是我的考验。问题是,Arquillian无法部署服务1.由于ShrinkWrap错误消息是无用的(实际上没有消息),我试图弄清楚我做错了什么。我已经验证了服务1的工件确实存在于我当地的Maven仓库中。
@Deployment(name = AVAILABILITY_SERVICE_NAME, order = 1)
public static WebArchive createAvailabilityServiceDeployment() {
WebArchive availabilityService = Maven.configureResolver()
.workOffline().withMavenCentralRepo(false)
.withClassPathResolution(true)
.resolve(AVAILABILITY_SERVICE_MVN_COORD).withoutTransitivity()
.asSingle(WebArchive.class);
System.out.println(availabilityService.toString(true));
return availabilityService;
}
@Deployment(name = APPOINTMENT_SERVICE_NAME, order = 2)
public static WebArchive createAppointmentServiceDeployment()
throws FileNotFoundException {
WebArchive appointmentService = create(WebArchive.class,
APPOINTMENT_SERVICE_NAME + ".war").addPackages(true,
Filters.exclude(".*Test.*"), AppointmentApp.class.getPackage())
.addAsWebInfResource(EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
System.out.println(appointmentService.toString(true));
return appointmentService;
}
java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive name.abhijitsarkar.microservices.appointment.AppointmentResourceIT.createAvailabilityServiceDeployment()
at org.jboss.shrinkwrap.resolver.spi.format.FormatProcessors.find(FormatProcessors.java:53)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenFormatStageImpl.as(MavenFormatStageImpl.java:82)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenFormatStageImpl.asSingle(MavenFormatStageImpl.java:100)
at name.abhijitsarkar.microservices.appointment.AppointmentResourceIT.createAvailabilityServiceDeployment(AppointmentResourceIT.java:50)
答案 0 :(得分:0)
显然,需要分2步完成。希望它可以帮助别人。
private static WebArchive createDependentServiceDeployment(String name) {
String mvnCoordinate = join(":", DEPENDENT_SERVICE_GROUP, name,
DEPENDENT_SERVICE_PACKAGING, DEPENDENT_SERVICE_VERSION);
File service = Maven.configureResolver().workOffline()
.withMavenCentralRepo(false).withClassPathResolution(true)
.resolve(mvnCoordinate).withoutTransitivity().asSingleFile();
return ShrinkWrap.create(ZipImporter.class,
join(".", name, DEPENDENT_SERVICE_PACKAGING))
.importFrom(service).as(WebArchive.class);
}