Java Reference
In-Depth Information
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class,
"ticket-agency-test.war")
.addPackage(SeatProducer.class.getPackage())
.addPackage(Seat.class.getPackage())
.addPackage(TicketService.class.getPackage())
.addPackage(DataManager.class.getPackage())
.addAsResource("META-INF/
persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE,
"beans.xml");
}
The fluent API provided by the ShrinkWrap project ( http://www.jboss.org/shrink-
wrap ) makes this technique possible using the create method, which accepts the
type of deployment unit ( WebArchive ) as the argument the deployment name (in
our case, we will name it ticket-agency-test.war ) and all the resources are in-
cluded in this archive. In our case, instead of including all the single classes, we are
using the addPackage utility method that adds all the classes that are contained in
a class package (for example, by adding the Seat.class.getPackage() meth-
od, we will include all the classes that are in the same package as the Seat class):
Finally, we add one test method to it:
@javax.inject.Inject
TicketService ticketService;
@Inject
Search WWH ::




Custom Search