Java Reference
In-Depth Information
Enhancing your Arquillian test
You might have noticed that we, on purpose, created just a part of the integration tests we
needed. We did not reach the last mile, that is, creating seats and reserving one. As a matter
of fact, if you remember, our ticket application uses ConversationScope to track the
user's navigation. Thus, we need to bind ConversationScope into our test as well.
Luckily, the Weld container provides all that you need with
org.jboss.weld.context.bound.BoundConversationContext , which
needs to be injected into your test class:
@Inject BoundConversationContext conversationContext;
public void init() {
new MutableBoundRequest(new HashMap<String, Object>(),
new HashMap<String,
Note that the @Before annotation is invoked before each test method and after injections
have occurred. In our case, it is used to associate conversationContext with Mut-
ableBoundRequest before being activated by conversationCon-
text.activate . This is needed to mimic the conversation behavior from within the Ar-
quillian test bed.
Just for completeness, you must be aware that BoundRequest interfaces are defined in
the Weld API to hold a conversation that spans multiple requests, but are shorter than a ses-
So here's the full TicketTest class, which contains a theatre creation and booking seat
reservation in the testTicketAgency method:
public class TicketTest {
Search WWH ::

Custom Search