1 package org.jacorb.test.notification; 2 3 import junit.framework.Test; 4 5 import org.jacorb.notification.filter.EvaluationContext; 6 import org.jacorb.notification.filter.etcl.AbstractTCLNode; 7 import org.jacorb.notification.filter.etcl.ETCLComponentName; 8 import org.jacorb.notification.filter.etcl.TCLCleanUp; 9 import org.jacorb.notification.filter.etcl.TCLParser; 10 import org.jacorb.notification.impl.DefaultMessageFactory; 11 import org.jacorb.notification.interfaces.Message; 12 13 16 17 public class MessageUtilsTest extends NotificationTestCase 18 { 19 EvaluationContext context_; 20 21 NotificationTestUtils testUtils_; 22 23 DefaultMessageFactory messageFactory_; 24 25 public MessageUtilsTest( String name, NotificationTestCaseSetup setup ) 26 { 27 super( name, setup ); 28 } 29 30 public void setUpTest() throws Exception 31 { 32 testUtils_ = new NotificationTestUtils(getORB()); 33 34 context_ = new EvaluationContext(getEvaluator()); 35 36 messageFactory_ = new DefaultMessageFactory(getConfiguration()); 37 } 38 39 40 public void testEvaluateCachesResult() throws Exception 41 { 42 AbstractTCLNode _root = TCLParser.parse( "$.first_name" ); 43 _root.acceptPreOrder( new TCLCleanUp() ); 44 45 Message _event = messageFactory_.newMessage(testUtils_.getTestPersonAny()); 46 _event.extractValue( context_, ( ETCLComponentName ) _root ); 47 48 assertNotNull( context_.lookupResult( "$.first_name" ) ); 49 50 _event.extractValue(context_, ( ETCLComponentName ) _root ); 51 52 assertEquals( "firstname", context_.lookupResult( "$.first_name" ).getString() ); 53 } 54 55 56 public void testEvaluateCachesAny() throws Exception 57 { 58 AbstractTCLNode _root = TCLParser.parse( "$.home_address.street" ); 59 _root.acceptPreOrder( new TCLCleanUp() ); 60 61 Message _event = messageFactory_.newMessage(testUtils_.getTestPersonAny()); 62 63 _event.extractValue(context_, ( ETCLComponentName ) _root ); 64 65 assertNotNull( context_.lookupAny( "$.home_address" ) ); 66 assertNotNull( context_.lookupAny( "$.home_address.street" ) ); 67 68 _event.extractValue( context_, ( ETCLComponentName ) _root ); 69 70 context_.eraseResult( "$.home_address.street" ); 71 72 _event.extractValue( context_, ( ETCLComponentName ) _root ); 73 } 74 75 76 public static Test suite() throws Exception 77 { 78 return NotificationTestCase.suite(MessageUtilsTest.class); 79 } 80 } 81 | Popular Tags |