Coverage Report - org.mule.tck.functional.FunctionalTestNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
FunctionalTestNotification
0%
0/14
N/A
1
 
 1  
 /*
 2  
  * $Id: FunctionalTestNotification.java 12017 2008-06-12 09:04:04Z rossmason $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  
             throws TransformerException
 55  
     {
 56  0
         super(message, action);
 57  0
         this.replyMessage = null;
 58  0
         this.eventContext = RequestContext.getEventContext();
 59  0
         resourceIdentifier = eventContext.getService().getName();
 60  
 
 61  0
     }
 62  
 
 63  
     public FunctionalTestNotification(MuleEventContext context, Object replyMessage, int action)
 64  
             throws TransformerException
 65  
     {
 66  0
         super(context.transformMessage(), action);
 67  0
         resourceIdentifier = context.getService().getName();
 68  0
         this.replyMessage = replyMessage;
 69  0
         this.eventContext = context;
 70  0
     }
 71  
 
 72  
     public Object getReplyMessage()
 73  
     {
 74  0
         return replyMessage;
 75  
     }
 76  
 
 77  
     public MuleEventContext getEventContext()
 78  
     {
 79  0
         return eventContext;
 80  
     }
 81  
 }