Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FunctionalTestNotification |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: FunctionalTestNotification.java 19191 2010-08-25 21:05:23Z tcarlson $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.tck.functional; | |
12 | ||
13 | import org.mule.RequestContext; | |
14 | import org.mule.api.MuleEventContext; | |
15 | import org.mule.api.transformer.TransformerException; | |
16 | import org.mule.context.notification.CustomNotification; | |
17 | ||
18 | /** | |
19 | * A <code>FunctionlTestNotification</code> is fired by the {@link org.mule.tck.functional.FunctionalTestComponent} | |
20 | * when it receives an event. Test cases can register a {@link org.mule.tck.functional.FunctionalTestNotificationListener} | |
21 | * with Mule to receive these notifications and make assertions about the number of messages received or the content | |
22 | * of the message. | |
23 | * <p/> | |
24 | * This Notification contains the current MuleEventContext and reply message. The resource Identifier for this event | |
25 | * is the service name that received the message. This means you can register to listen to Notifications from a | |
26 | * selected {@link org.mule.tck.functional.FunctionalTestComponent}. i.e. | |
27 | * <code> | |
28 | * muleContext.registerListener(this, "*JmsTestCompoennt"); | |
29 | * </code> | |
30 | * <p/> | |
31 | * This registration would only receive {@link org.mule.tck.functional.FunctionalTestNotification} objects | |
32 | * from components called 'MyJmsTestComponent' and 'YourJmsTestComponent' but not 'HerFileTestComponent'. | |
33 | * | |
34 | * @see org.mule.tck.functional.FunctionalTestComponent | |
35 | * @see org.mule.tck.functional.FunctionalTestNotificationListener | |
36 | * @see org.mule.api.MuleContext | |
37 | */ | |
38 | public class FunctionalTestNotification extends CustomNotification | |
39 | { | |
40 | /** Serial version */ | |
41 | private static final long serialVersionUID = -3435373745940904597L; | |
42 | ||
43 | public static final int EVENT_RECEIVED = -999999; | |
44 | ||
45 | static | |
46 | { | |
47 | 0 | registerAction("event received", EVENT_RECEIVED); |
48 | 0 | } |
49 | ||
50 | private final Object replyMessage; | |
51 | private final MuleEventContext eventContext; | |
52 | ||
53 | public FunctionalTestNotification(Object message, int action) | |
54 | { | |
55 | 0 | super(message, action); |
56 | 0 | this.replyMessage = null; |
57 | 0 | this.eventContext = RequestContext.getEventContext(); |
58 | 0 | resourceIdentifier = eventContext.getFlowConstruct().getName(); |
59 | ||
60 | 0 | } |
61 | ||
62 | public FunctionalTestNotification(MuleEventContext context, Object replyMessage, int action) | |
63 | throws TransformerException | |
64 | { | |
65 | 0 | super(context.getMessage().getPayload(), action); |
66 | 0 | resourceIdentifier = context.getFlowConstruct().getName(); |
67 | 0 | this.replyMessage = replyMessage; |
68 | 0 | this.eventContext = context; |
69 | 0 | } |
70 | ||
71 | public Object getReplyMessage() | |
72 | { | |
73 | 0 | return replyMessage; |
74 | } | |
75 | ||
76 | public MuleEventContext getEventContext() | |
77 | { | |
78 | 0 | return eventContext; |
79 | } | |
80 | } |