001    // jademx - JADE management using JMX
002    // Copyright 2004-2005 Caboodle Networks, Inc.
003    //
004    // This library is free software; you can redistribute it and/or
005    // modify it under the terms of the GNU Lesser General Public
006    // License as published by the Free Software Foundation; either
007    // version 2.1 of the License, or (at your option) any later version.
008    //
009    // This library is distributed in the hope that it will be useful,
010    // but WITHOUT ANY WARRANTY; without even the implied warranty of
011    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012    // Lesser General Public License for more details.
013    //
014    // You should have received a copy of the GNU Lesser General Public
015    // License along with this library; if not, write to the Free Software
016    // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
017    
018    package jade.jademx.util;
019    
020    import junit.framework.Test;
021    import junit.framework.TestCase;
022    import junit.framework.TestSuite;
023    
024    import java.util.Date;
025    import jade.core.AID;
026    import jade.jademx.JadeMXSuiteTest;
027    import jade.lang.acl.ACLCodec;
028    import jade.lang.acl.ACLMessage;
029    import jade.lang.acl.ACLCodec.CodecException;
030    
031    import java.util.List;
032    import java.util.Properties;
033    
034    /**
035     * test jade.jademx.util.AclMsgCmp
036     * <br/>
037     * TODO: ADD TEST CASES FOR PERMISSIVE HAP COMPARISON IN AID
038     * <br/>
039     * @author David Bernstein, <a href="http://www.caboodlenetworks.com"
040     *  >Caboodle Networks, Inc.</a>
041     */
042    public class AclMsgCmpTest extends TestCase {
043        
044        
045        // a string version of an acl-message to use...
046        
047        String proxyMsg = 
048            " (PROXY " +
049            "   :sender  " +
050            "     (agent-identifier " +
051            "       :name gateway@picturebook:1098/JADE) " +
052            "   :receiver  " +
053            "     (set " +
054            "       (agent-identifier " +
055            "         :name Recruiter@picturebook:1098/JADE)) " +
056            "   :content    " +
057            "    \" ((iota ?x " +
058            "         (Registered " +
059            "           (df-agent-description   " +
060            "             :name ?x   " +
061            "             :services " +
062            "               (set     " +
063            "                 (service-description " +
064            "                   :name caboodle-agent-user)))))   " +
065            "       (action " +
066            "         (agent-identifier " +
067            "           :name Recruiter@picturebook:1098/JADE)     " +
068            "         (REQUEST           " +
069            "           :reply-to " +
070            "             (set " +
071            "               (agent-identifier " +
072            "                 :name gateway@picturebook:1098/JADE))              " +
073            "           :language http-get       " +
074            "           :protocol fipa-request           " +
075            "           :content           \\\"process?cmd=mainMenu\\\")))\"" +
076            "   :reply-with  gateway.gateway.1088558123602  " +
077            "   :in-reply-to  noValue  " +
078            "   :language  fipa-sl  " +
079            "   :ontology  caboodle-brokerage-ontology  " +
080            "   :protocol  fipa-recruiting " +
081            "   :conversation-id  servlet164804312961_0)"
082            ;
083        
084        
085        /**
086         * test initialization and setting/getting flags
087         */
088        public void testFlags() {
089            AclMsgCmp amc = new AclMsgCmp();
090            
091            assertTrue( amc.isCmpSender() );
092            amc.setCmpSender( false );
093            assertFalse( amc.isCmpSender() );
094            
095            assertTrue( amc.isCmpReceiver() );
096            amc.setCmpReceiver( false );
097            assertFalse( amc.isCmpReceiver() );
098            
099            assertTrue( amc.isCmpReplyTo() );
100            amc.setCmpReplyTo( false );
101            assertFalse( amc.isCmpReplyTo() );  
102    
103            assertTrue( amc.isCmpPerformative() );
104            amc.setCmpPerformative( false );
105            assertFalse( amc.isCmpPerformative() );  
106    
107            assertTrue( amc.isCmpContent() );
108            amc.setCmpContent( false );
109            assertFalse( amc.isCmpContent() );         
110    
111            assertTrue( amc.isIgnoreContentAIDAddresses() );
112            amc.setIgnoreContentAIDAddresses( false );
113            assertFalse( amc.isIgnoreContentAIDAddresses() );    
114    
115            assertTrue( amc.isNewlinesNormalized() );
116            amc.setNewlinesNormalized( false );
117            assertFalse( amc.isNewlinesNormalized() );    
118    
119            assertTrue( amc.isCmpLanguage() );
120            amc.setCmpLanguage( false );
121            assertFalse( amc.isCmpLanguage() );         
122    
123            assertTrue( amc.isCmpEncoding() );
124            amc.setCmpEncoding( false );
125            assertFalse( amc.isCmpEncoding() ); 
126    
127            assertTrue( amc.isCmpOntology() );
128            amc.setCmpOntology( false );
129            assertFalse( amc.isCmpOntology() );
130            
131            assertTrue( amc.isCmpProtocol() );
132            amc.setCmpProtocol( false );
133            assertFalse( amc.isCmpProtocol() );
134    
135            assertTrue( amc.isCmpConversationId() );
136            amc.setCmpConversationId( false );
137            assertFalse( amc.isCmpConversationId() );
138            
139            assertTrue( amc.isCmpInReplyTo() );
140            amc.setCmpInReplyTo( false );
141            assertFalse( amc.isCmpInReplyTo() );
142            
143            assertTrue( amc.isCmpReplyWith() );
144            amc.setCmpReplyWith( false );
145            assertFalse( amc.isCmpReplyWith() );
146            
147            assertTrue( amc.isCmpReplyBy() );
148            amc.setCmpReplyBy( false );
149            assertFalse( amc.isCmpReplyBy() );
150            
151            assertTrue( amc.isCmpUserProperties() );
152            amc.setCmpUserProperties( false );
153            assertFalse( amc.isCmpUserProperties() );
154            
155            // envelope is only field by default not compared
156            
157            assertFalse( amc.isCmpEnvelope() );
158            amc.setCmpEnvelope( true );
159            assertTrue( amc.isCmpEnvelope() );
160            
161        }
162        
163        /**
164         * test passing null to strToVarStrList
165         */
166        public void testNullStrToVarStrList() {
167            NullStrToVarListAclMsgCmp m = new NullStrToVarListAclMsgCmp();
168            m.testNullStrToVarStrList();
169        }
170        
171        /** 
172         * test class for testNullStrToVarStrList
173         */
174        private class NullStrToVarListAclMsgCmp extends AclMsgCmp {
175            /** implementation for testNullStrToVarStrList */
176            public void testNullStrToVarStrList() {
177                List l = strToVarStrList( null, null );
178                assertEquals( 0, l.size() );
179            }
180        }
181        
182        
183        // test comparison of identical messages
184        
185        /**
186         * Test that equal messages are returned as equal.
187         * @throws jade.lang.ACLCodec.CodecException converting string to message
188         */
189        public void testEqualMessages() throws ACLCodec.CodecException {
190            AclMsgCmp amc = new AclMsgCmp();
191            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
192            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
193            String diffMsg = amc.compare( msg1, msg2 );
194            assertNull( "erroneously found difference:"+diffMsg, diffMsg );
195        }
196    
197        // test internal method compareAidSet()
198        
199        /**
200         * test <code>compareAidSet</code> cardinality functionality
201         * @throws ACLCodec.CodecException  converting string to message
202         */
203        public void testCompareAidSetCardinality() throws ACLCodec.CodecException {
204            AclMsgCmp amc = new AclMsgCmp();
205            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
206            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
207            String diffMsg;
208            
209            // test both empty
210            msg1.clearAllReplyTo();
211            msg2.clearAllReplyTo();
212            diffMsg = amc.compareAidSet( msg1.getAllReplyTo(),
213                                                             msg2.getAllReplyTo(),
214                                                             "reply-to" );
215            assertNull( "erroneously found difference 2 empty AID sets:"+diffMsg,
216                        diffMsg );
217    
218            // test first existing, second empty
219            msg1.clearAllReplyTo();
220            msg2.clearAllReplyTo();
221            msg1.addReplyTo( new AID( "b@x:1098/JADE", AID.ISGUID ) );
222            diffMsg = amc.compareAidSet( msg1.getAllReplyTo(),
223                                                                             msg2.getAllReplyTo(),
224                                                                     "reply-to" );
225            assertNotNull( "didn't find mismatch 1st existing 2nd empty:"+diffMsg,
226                               diffMsg );
227            
228            // test first empty, second existing
229            msg1.clearAllReplyTo();
230            msg2.clearAllReplyTo();
231            msg2.addReplyTo( new AID( "b@x:1098/JADE", AID.ISGUID ) );
232            diffMsg = amc.compareAidSet( msg1.getAllReplyTo(),
233                                                             msg2.getAllReplyTo(),
234                                                                     "reply-to" );
235            assertNotNull( "didn't find mismatch 1st empty 2nd existing:"+diffMsg,
236                               diffMsg );
237            
238            // test both with one (identical) item
239            msg1.clearAllReplyTo();
240            msg2.clearAllReplyTo();
241            msg1.addReplyTo( new AID( "b@x:1098/JADE", AID.ISGUID ) );
242            msg2.addReplyTo( new AID( "b@x:1098/JADE", AID.ISGUID ) );
243            diffMsg = amc.compareAidSet( msg1.getAllReplyTo(),
244                                                             msg2.getAllReplyTo(),
245                                                                     "reply-to" );
246            assertNull( "erroneously difference 2 AID sets of same item:"+diffMsg,
247                        diffMsg );
248    
249        }
250       
251        // test sender
252        
253        /**
254         * Test case-insensitivity of sender comparison.
255         * Differing case should not matter.
256         * @throws jade.lang.ACLCodec.CodecException converting string to message
257         */
258        public void testSenderCase() throws ACLCodec.CodecException {
259            AclMsgCmp amc = new AclMsgCmp();
260            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
261            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
262            msg1.setSender( new AID( "foo@bar:1098/JADE", AID.ISGUID ) );
263            msg2.setSender( new AID( "FOO@BAR:1098/jade", AID.ISGUID ) );
264            String diffMsg = amc.compare( msg1, msg2 );
265            assertNull( "messages with same sender specified with different" +
266                    " case returned as different:"+diffMsg, 
267                    diffMsg );
268        }
269        
270        /**
271         * Test sender local name comparison.
272         * Different local name should matter.
273         * @throws jade.lang.ACLCodec.CodecException converting string to message
274         */
275        public void testSenderLocalName() throws ACLCodec.CodecException {
276            AclMsgCmp amc = new AclMsgCmp();
277            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
278            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
279            msg1.setSender( new AID( "foo@bar:1098/JADE", AID.ISGUID ) );
280            msg2.setSender( new AID( "baz@bar:1098/JADE", AID.ISGUID ) );
281            String diffMsg = amc.compare( msg1, msg2 );
282            assertNotNull( 
283                    "messages with sender different local names returned as equal",
284                    diffMsg );
285        }
286        
287        /**
288         * Test sender HAP comparison.
289         * If compare "a@x"/"a@y", then it should match,<br/>
290         * followed by "b@x"/"b@y" should match,<br/>
291         * followed by "c@x"/"c@z" should not match.
292         * @throws jade.lang.ACLCodec.CodecException converting string to message
293         */
294        public void testSenderHAP() throws ACLCodec.CodecException {
295            AclMsgCmp amc = new AclMsgCmp();
296            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
297            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
298            
299            String diffMsg;
300            
301            msg1.setSender( new AID( "a@x:1098/JADE", AID.ISGUID ) );
302            msg2.setSender( new AID( "a@y:1099/cougaar", AID.ISGUID ) );
303            diffMsg = amc.compare( msg1, msg2 );
304            assertNull( "messages with sender same local name and different HAP" +
305                    " returned as different:"+diffMsg,
306                    diffMsg );
307            
308            msg1.setSender( new AID( "b@x:1098/JADE", AID.ISGUID ) );
309            msg2.setSender( new AID( "b@y:1099/cougaar", AID.ISGUID ) );
310            diffMsg = amc.compare( msg1, msg2 );
311            assertNull( "messages with sender same local name and HAPs matching" +
312                    " previous comparison returned as different"+diffMsg,
313                    diffMsg );
314            
315            
316            msg1.setSender( new AID( "c@x:1098/JADE", AID.ISGUID ) );
317            msg2.setSender( new AID( "c@z:1099/cougaar", AID.ISGUID ) );
318            diffMsg = amc.compare( msg1, msg2 );
319            assertNotNull( "messages with sender same local name and HAPs not" + 
320                    " matching previous comparison returned as same",
321                    diffMsg );
322            
323        }
324        
325        /**
326         * test nulls in sender slot
327         * @throws ACLCodec.CodecException
328         */
329        public void testSenderNulls()throws ACLCodec.CodecException {
330            AclMsgCmp amc = new AclMsgCmp();
331    
332            ACLMessage msg1;
333            ACLMessage msg2;
334            String diffMsg;
335            
336            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
337            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
338            msg1.setSender( null );
339            msg2.setSender( null );
340            diffMsg = amc.compare( msg1, msg2 );
341            assertNull( diffMsg );
342            
343            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
344            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
345            msg1.setSender( null );
346            diffMsg = amc.compare( msg1, msg2 );
347            assertNotNull( diffMsg );
348            
349            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
350            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
351            msg2.setSender( null );
352            diffMsg = amc.compare( msg1, msg2 );
353            assertNotNull( diffMsg );
354            
355        }
356            
357        
358        /**
359         * test nulls in content slot
360         * @throws ACLCodec.CodecException
361         */
362        public void testContentNulls()throws ACLCodec.CodecException {
363            AclMsgCmp amc = new AclMsgCmp();
364    
365            ACLMessage msg1;
366            ACLMessage msg2;
367            String diffMsg;
368            
369            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
370            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
371            msg1.setContent( null );
372            msg2.setContent( null );
373            diffMsg = amc.compare( msg1, msg2 );
374            assertNull( diffMsg );
375            
376            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
377            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
378            msg1.setContent( null );
379            diffMsg = amc.compare( msg1, msg2 );
380            assertNotNull( diffMsg );
381            
382            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
383            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
384            msg2.setContent( null );
385            diffMsg = amc.compare( msg1, msg2 );
386            assertNotNull( diffMsg );
387            
388        }
389        
390        /**
391         * test nulls in a case-insensitive string slot
392         * @throws ACLCodec.CodecException
393         */
394        public void testCaseInsStrNulls()throws ACLCodec.CodecException {
395            AclMsgCmp amc = new AclMsgCmp();
396    
397            ACLMessage msg1;
398            ACLMessage msg2;
399            String diffMsg;
400            
401            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
402            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
403            msg1.setReplyWith( null );
404            msg2.setReplyWith( null );
405            diffMsg = amc.compare( msg1, msg2 );
406            assertNull( diffMsg );
407            
408            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
409            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
410            msg1.setReplyWith( null );
411            diffMsg = amc.compare( msg1, msg2 );
412            assertNotNull( diffMsg );
413            
414            msg1 = AclMsgCmp.stringToMessage( proxyMsg );
415            msg2 = AclMsgCmp.stringToMessage( proxyMsg );
416            msg2.setReplyWith( null );
417            diffMsg = amc.compare( msg1, msg2 );
418            assertNotNull( diffMsg );
419            
420        }
421            
422        
423        
424        // test receivers
425        
426        /**
427         * Test comparison of messages with different-cased singleton receivers.
428         * @throws jade.lang.ACLCodec.CodecException converting string to message
429         */
430        public void testReceiverSingletonCase() throws ACLCodec.CodecException {
431            AclMsgCmp amc = new AclMsgCmp();
432            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
433            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
434            msg1.clearAllReceiver();
435            msg2.clearAllReceiver();
436            msg1.addReceiver( new AID( "b@x:1098/JADE", AID.ISGUID ) );
437            msg2.addReceiver( new AID( "B@y:1099/JADE", AID.ISGUID ) );
438            String diffMsg = amc.compare( msg1, msg2 );
439            assertNull( 
440                    "messages with different-cased singleton receivers " +
441                    "returned as different:"+diffMsg, 
442                    diffMsg );
443        }
444        
445        
446        /**
447         * Test comparison of messages with different singleton receivers.
448         * @throws jade.lang.ACLCodec.CodecException converting string to message
449         */
450        public void testReceiverSingleton() throws ACLCodec.CodecException {
451            AclMsgCmp amc = new AclMsgCmp();
452            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
453            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
454            msg1.clearAllReceiver();
455            msg2.clearAllReceiver();
456            msg1.addReceiver( new AID( "b@x:1098/JADE", AID.ISGUID ) );
457            msg2.addReceiver( new AID( "c@y:1099/JADE", AID.ISGUID ) );
458            String diffMsg = amc.compare( msg1, msg2 );
459            assertNotNull( 
460                    "messages with different singleton receivers returned as equal", 
461                    diffMsg );
462        }
463        
464        
465        // test reply-to
466        
467        /**
468         * Test comparison of messages with different-cased singleton reply-tos.
469         * @throws jade.lang.ACLCodec.CodecException converting string to message
470         */
471        public void testReplyToSingletonCase() throws ACLCodec.CodecException {
472            AclMsgCmp amc = new AclMsgCmp();
473            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
474            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
475            msg1.clearAllReplyTo();
476            msg2.clearAllReplyTo();
477            msg1.addReplyTo( new AID( "b@x:1098/JADE", AID.ISGUID ) );
478            msg2.addReplyTo( new AID( "B@y:1099/JADE", AID.ISGUID ) );
479            String diffMsg = amc.compare( msg1, msg2 );
480            assertNull( 
481                    "messages with different-cased singleton reply-tos " + 
482                    "returned as different:"+diffMsg, 
483                    diffMsg );
484        }
485        
486        
487        /**
488         * Test comparison of messages with different singleton reply-tos.
489         * @throws jade.lang.ACLCodec.CodecException converting string to message
490         */
491        public void testReplyToSingleton() throws ACLCodec.CodecException {
492            AclMsgCmp amc = new AclMsgCmp();
493            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
494            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
495            msg1.clearAllReplyTo();
496            msg2.clearAllReplyTo();
497            msg1.addReplyTo( new AID( "b@x:1098/JADE", AID.ISGUID ) );
498            msg2.addReplyTo( new AID( "c@y:1099/JADE", AID.ISGUID ) );
499            String diffMsg = amc.compare( msg1, msg2 );
500            assertNotNull( 
501                    "messages with different singleton reply-tos returned as equal", 
502                    diffMsg );
503        }
504        
505        // test performative
506        
507        /**
508         * Test comparison of messages with different performatives.
509         * @throws jade.lang.ACLCodec.CodecException converting string to message
510         */
511        public void testPerformative() throws ACLCodec.CodecException {
512            AclMsgCmp amc = new AclMsgCmp();
513            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
514            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
515            msg2.setPerformative( ACLMessage.ACCEPT_PROPOSAL );
516            String diffMsg = amc.compare( msg1, msg2 );
517            assertNotNull( 
518                    "messages with different performatives returned as equal", 
519                    diffMsg );
520        }
521        
522        // test language
523        
524        /**
525         * Test comparison of messages with different languages.
526         * @throws jade.lang.ACLCodec.CodecException converting string to message
527         */
528        public void testLanguage() throws ACLCodec.CodecException {
529            AclMsgCmp amc = new AclMsgCmp();
530            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
531            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
532            msg2.setLanguage( "XMLCodec" );
533            String diffMsg = amc.compare( msg1, msg2 );
534            assertNotNull( "messages with different languages returned as equal", 
535                    diffMsg );
536        }
537        
538        /**
539         * Test case-insensitivity of language comparison.
540         * @throws jade.lang.ACLCodec.CodecException converting string to message
541         */
542        public void testLanguageCase() throws ACLCodec.CodecException {
543            AclMsgCmp amc = new AclMsgCmp();
544            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
545            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
546            msg1.setLanguage( "xmlcODEC" );
547            msg2.setLanguage( "XMLCodec" );
548            String diffMsg = amc.compare( msg1, msg2 );
549            assertNull( "messages with same language specified with different" +
550                    " case returned as different:"+diffMsg, 
551                    diffMsg );
552        }
553        
554        // test encoding
555        
556        /**
557         * Test comparison of messages with different encodings.
558         * @throws jade.lang.ACLCodec.CodecException converting string to message
559         */
560        public void testEncoding() throws ACLCodec.CodecException {
561            AclMsgCmp amc = new AclMsgCmp();
562            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
563            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
564            msg2.setOntology( "Base64" );
565            String diffMsg = amc.compare( msg1, msg2 );
566            assertNotNull( "messages with different encodings returned as equal", 
567                    diffMsg );
568        }
569        
570        /**
571         * Test case-insensitivity of encoding comparison.
572         * @throws jade.lang.ACLCodec.CodecException converting string to message
573         */
574        public void testEncodingCase() throws ACLCodec.CodecException {
575            AclMsgCmp amc = new AclMsgCmp();
576            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
577            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
578            msg1.setOntology( "base64" );
579            msg2.setOntology( "Base64" );
580            String diffMsg = amc.compare( msg1, msg2 );
581            assertNull( "messages with same ontology specified with" +
582                    " different case returned as different:"+diffMsg,
583                    diffMsg );
584        }
585        
586        // test ontology
587        
588        /**
589         * Test comparison of messages with different ontologies.
590         * @throws jade.lang.ACLCodec.CodecException converting string to message
591         */
592        public void testOntology() throws ACLCodec.CodecException {
593            AclMsgCmp amc = new AclMsgCmp();
594            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
595            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
596            msg2.setOntology( "FIPA-Agent-Management" );
597            String diffMsg = amc.compare( msg1, msg2 );
598            assertNotNull( "messages with different languages returned as equal", 
599                    diffMsg );
600        }
601        
602        /**
603         * Test case-insensitivity of ontology comparison.
604         * @throws jade.lang.ACLCodec.CodecException converting string to message
605         */
606        public void testOntologyCase() throws ACLCodec.CodecException {
607            AclMsgCmp amc = new AclMsgCmp();
608            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
609            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
610            msg1.setOntology( "fipa-agent-management" );
611            msg2.setOntology( "FIPA-Agent-Management" );
612            String diffMsg = amc.compare( msg1, msg2 );
613            assertNull( "messages with same ontology specified with" +
614                    "different case returned as different:"+diffMsg, 
615                    diffMsg );
616        }
617        
618        // test protocol
619        
620        /**
621         * Test comparison of messages with different protocols.
622         * @throws jade.lang.ACLCodec.CodecException converting string to message
623         */
624        public void testProtocol() throws ACLCodec.CodecException {
625            AclMsgCmp amc = new AclMsgCmp();
626            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
627            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
628            msg2.setProtocol( "fipa-request" );
629            String diffMsg = amc.compare( msg1, msg2 );
630            assertNotNull( "messages with different protocols returned as equal", 
631                    diffMsg );
632        }
633        
634        /**
635         * Test case-insensitivity of protocol comparison.
636         * @throws jade.lang.ACLCodec.CodecException converting string to message
637         */
638        public void testProtocolCase() throws ACLCodec.CodecException {
639            AclMsgCmp amc = new AclMsgCmp();
640            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
641            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
642            msg1.setProtocol( "FIPA-request" );
643            msg2.setProtocol( "fipa-request" );
644            String diffMsg = amc.compare( msg1, msg2 );
645            assertNull( "messages with same protocol specified with" +
646                    " different case returned as different:"+diffMsg, 
647                    diffMsg );
648        }
649        
650        // test conversation-id
651        
652        /**
653         * Test comparison of messages with consistent conversation-ids.
654         * @throws jade.lang.ACLCodec.CodecException converting string to message
655         */
656        public void testConversationIdConsistent() throws ACLCodec.CodecException {
657            AclMsgCmp amc = new AclMsgCmp();
658            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
659            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
660            msg1.setConversationId( "conversation1" );
661            msg2.setConversationId( "conversation2" );
662            String diffMsg;
663            diffMsg = amc.compare( msg1, msg2 );
664            assertNull( "first comparison of messages returned difference" +
665                    " in conversation-id slot:"+diffMsg, diffMsg );
666            diffMsg = amc.compare( msg1, msg2 );
667            assertNull( "second comparison of messages returned difference" +
668                    " in conversation-id slot:"+diffMsg, diffMsg );
669        }
670        
671        /**
672         * Test comparison of messages with case-varying conversation-ids.
673         * @throws jade.lang.ACLCodec.CodecException converting string to message
674         */
675        public void testConversationIdCase() throws ACLCodec.CodecException {
676            AclMsgCmp amc = new AclMsgCmp();
677            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
678            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
679            msg1.setConversationId( "conversation1" );
680            msg2.setConversationId( "conversation2" );
681            String diffMsg;
682            diffMsg = amc.compare( msg1, msg2 );
683            assertNull( "first comparison of messages returned difference" +
684                    " in conversation-id slot:"+diffMsg, diffMsg );
685            msg2.setConversationId( "CONVERSATION2" );
686            diffMsg = amc.compare( msg1, msg2 );
687            assertNull( "second comparison of messages returned difference" +
688                    " in conversation-id slot:"+diffMsg, diffMsg );
689        }
690        
691        /**
692         * Test comparison of messages with inconsistent conversation-ids.
693         * @throws jade.lang.ACLCodec.CodecException converting string to message
694         */
695        public void testConversationIdInconsistent() 
696          throws ACLCodec.CodecException {
697            AclMsgCmp amc = new AclMsgCmp();
698            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
699            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
700            msg1.setConversationId( "conversation1" );
701            msg2.setConversationId( "conversation2" );
702            String diffMsg;
703            diffMsg = amc.compare( msg1, msg2 );
704            assertNull( "first comparison of messages returned difference" +
705                    " in conversation-id slot:"+diffMsg, diffMsg );
706            msg2.setConversationId( "conversation3" );
707            diffMsg = amc.compare( msg1, msg2 );
708            assertNotNull( "comparison of messages with inconsistency" +
709                    " in conversation-id slot failed to find difference:", 
710                    diffMsg );
711        }
712        
713        // test in-reply-to
714        
715        /**
716         * Test comparison of messages with consistent in-reply-tos.
717         * @throws jade.lang.ACLCodec.CodecException converting string to message
718         */
719        public void testInReplyToConsistent() throws ACLCodec.CodecException {
720            AclMsgCmp amc = new AclMsgCmp();
721            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
722            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
723            msg1.setInReplyTo( "reply.id1" );
724            msg2.setInReplyTo( "reply.id2" );
725            String diffMsg;
726            diffMsg = amc.compare( msg1, msg2 );
727            assertNull( "first comparison of messages returned difference" +
728                    " in in-reply-to slot:"+diffMsg, diffMsg );
729            diffMsg = amc.compare( msg1, msg2 );
730            assertNull( "second comparison of messages returned difference" +
731                    " in in-reply-to slot:"+diffMsg, diffMsg );
732        }
733        
734        /**
735         * Test comparison of messages with case-varying in-reply-tos.
736         * @throws jade.lang.ACLCodec.CodecException converting string to message
737         */
738        public void testInReplyToCase() throws ACLCodec.CodecException {
739            AclMsgCmp amc = new AclMsgCmp();
740            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
741            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
742            msg1.setInReplyTo( "reply.id1" );
743            msg2.setInReplyTo( "reply.id2" );
744            String diffMsg;
745            diffMsg = amc.compare( msg1, msg2 );
746            assertNull( "first comparison of messages returned difference" +
747                    " in in-reply-to slot:"+diffMsg, diffMsg );
748            msg2.setInReplyTo( "REPLY.ID2" );
749            diffMsg = amc.compare( msg1, msg2 );
750            assertNull( "second comparison of messages returned difference" +
751                    " in in-reply-to slot:"+diffMsg, diffMsg );
752        }
753        
754        /**
755         * Test comparison of messages with inconsistent in-reply-tos.
756         * @throws jade.lang.ACLCodec.CodecException converting string to message
757         */
758        public void testInReplyToInconsistent() throws ACLCodec.CodecException {
759            AclMsgCmp amc = new AclMsgCmp();
760            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
761            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
762            msg1.setInReplyTo( "reply.id1" );
763            msg2.setInReplyTo( "reply.id2" );
764            String diffMsg;
765            diffMsg = amc.compare( msg1, msg2 );
766            assertNull( "first comparison of messages returned difference" +
767                    " in in-reply-to slot:"+diffMsg, diffMsg );
768            msg2.setInReplyTo( "reply.id3" );
769            diffMsg = amc.compare( msg1, msg2 );
770            assertNotNull( "comparison of messages with inconsistency" +
771                    " in in-reply-to slot failed to find difference:", diffMsg );
772        }
773        
774        
775        // test reply-with
776        
777        /**
778         * Test comparison of messages with consistent reply-withs.
779         * @throws jade.lang.ACLCodec.CodecException converting string to message
780         */
781        public void testReplyWithConsistent() throws ACLCodec.CodecException {
782            AclMsgCmp amc = new AclMsgCmp();
783            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
784            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
785            msg1.setReplyWith( "reply.id1" );
786            msg2.setReplyWith( "reply.id2" );
787            String diffMsg;
788            diffMsg = amc.compare( msg1, msg2 );
789            assertNull( "first comparison of messages returned difference" +
790                    " in reply-with slot:"+diffMsg, diffMsg );
791            diffMsg = amc.compare( msg1, msg2 );
792            assertNull( "second comparison of messages returned difference" +
793                    " in reply-with slot:"+diffMsg, diffMsg );
794        }
795        
796        /**
797         * Test comparison of messages with case-varying reply-withs.
798         * @throws jade.lang.ACLCodec.CodecException converting string to message
799         */
800        public void testReplyWithCase() throws ACLCodec.CodecException {
801            AclMsgCmp amc = new AclMsgCmp();
802            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
803            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
804            msg1.setReplyWith( "reply.id1" );
805            msg2.setReplyWith( "reply.id2" );
806            String diffMsg;
807            diffMsg = amc.compare( msg1, msg2 );
808            assertNull( "first comparison of messages returned difference" +
809                    " in reply-with slot:"+diffMsg, diffMsg );
810            msg2.setReplyWith( "REPLY.ID2" );
811            diffMsg = amc.compare( msg1, msg2 );
812            assertNull( "second comparison of messages returned difference" +
813                    " in reply-with slot:"+diffMsg, diffMsg );
814        }
815        
816        /**
817         * Test comparison of messages with inconsistent reply-withs.
818         * @throws jade.lang.ACLCodec.CodecException converting string to message
819         */
820        public void testReplyWithInconsistent() throws ACLCodec.CodecException {
821            AclMsgCmp amc = new AclMsgCmp();
822            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
823            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
824            msg1.setReplyWith( "reply.id1" );
825            msg2.setReplyWith( "reply.id2" );
826            String diffMsg;
827            diffMsg = amc.compare( msg1, msg2 );
828            assertNull( "first comparison of messages returned difference" +
829                    " in reply-with slot:"+diffMsg, diffMsg );
830            msg2.setReplyWith( "reply.id3" );
831            diffMsg = amc.compare( msg1, msg2 );
832            assertNotNull( "comparison of messages with inconsistency" +
833                    " in reply-with slot failed to find difference:", diffMsg );
834        }
835        
836        // test reply-by
837        
838        /**
839         * Test comparison of messages with different reply-by timestamps.
840         * @throws jade.lang.ACLCodec.CodecException converting string to message
841         */
842        public void testReplyBy() throws ACLCodec.CodecException {
843            AclMsgCmp amc = new AclMsgCmp();
844            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
845            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
846            Date now = new Date();
847            msg1.setReplyByDate( now );
848            msg2.setReplyByDate( new Date( now.getTime()-1 ) );
849            String diffMsg = amc.compare( msg1, msg2 );
850            assertNotNull( 
851                    "messages with different reply-by timestamps returned as equal", 
852                    diffMsg );
853        }
854        
855        // test user properties
856        
857        /**
858         * Test comparison of messages with same user properties.
859         * @throws jade.lang.ACLCodec.CodecException converting string to message
860         */
861        public void testUserPropsEqual() throws ACLCodec.CodecException {
862            AclMsgCmp amc = new AclMsgCmp();
863            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
864            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
865            msg1.addUserDefinedParameter( "a", "x" );
866            msg1.addUserDefinedParameter( "b", "y" );
867            msg1.addUserDefinedParameter( "c", "z" );
868            msg2.addUserDefinedParameter( "a", "x" );
869            msg2.addUserDefinedParameter( "b", "y" );
870            msg2.addUserDefinedParameter( "c", "z" );
871            String diffMsg = amc.compare( msg1, msg2 );
872            assertNull( 
873                    "comparison of messages with equal user defined properties" +
874                    " returned difference:"+diffMsg, diffMsg );
875        }
876        
877        /**
878         * Test comparison of messages with a user property changed.
879         * @throws jade.lang.ACLCodec.CodecException converting string to message
880         */
881        public void testUserPropsChanged() throws ACLCodec.CodecException {
882            AclMsgCmp amc = new AclMsgCmp();
883            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
884            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
885            msg1.addUserDefinedParameter( "a", "x" );
886            msg1.addUserDefinedParameter( "b", "y" );
887            msg1.addUserDefinedParameter( "c", "z" );
888            msg2.addUserDefinedParameter( "a", "x" );
889            msg2.addUserDefinedParameter( "b", "y" );
890            msg2.addUserDefinedParameter( "c", "z" );
891            String diffMsg;
892            diffMsg = amc.compare( msg1, msg2 );
893            assertNull( 
894                    "comparison of messages with equal user defined properties" +
895                    " returned difference:"+diffMsg, diffMsg );
896            msg2.removeUserDefinedParameter( "c" );
897            msg2.addUserDefinedParameter( "c", "w" );
898            diffMsg = amc.compare( msg1, msg2 );
899            assertNotNull( "message with a changed user property returned as equal", 
900                    diffMsg );
901        }
902        
903        /**
904         * Test comparison of messages with a user property added.
905         * @throws jade.lang.ACLCodec.CodecException converting string to message
906         */
907        public void testUserPropsAdded() throws ACLCodec.CodecException {
908            AclMsgCmp amc = new AclMsgCmp();
909            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
910            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
911            msg1.addUserDefinedParameter( "a", "x" );
912            msg1.addUserDefinedParameter( "b", "y" );
913            msg1.addUserDefinedParameter( "c", "z" );
914            msg2.addUserDefinedParameter( "a", "x" );
915            msg2.addUserDefinedParameter( "b", "y" );
916            msg2.addUserDefinedParameter( "c", "z" );
917            String diffMsg;
918            diffMsg = amc.compare( msg1, msg2 );
919            assertNull( 
920                    "comparison of messages with equal user defined properties" +
921                    " returned difference:"+diffMsg, diffMsg );
922            msg1.addUserDefinedParameter( "d", "w" );
923            diffMsg = amc.compare( msg1, msg2 );
924            assertNotNull( "message with an added user property returned as equal", 
925                    diffMsg );
926        }
927        
928        /**
929         * Test comparison of messages with a user property removed.
930         * @throws jade.lang.ACLCodec.CodecException converting string to message
931         */
932        public void testUserPropsRemoved() throws ACLCodec.CodecException {
933            AclMsgCmp amc = new AclMsgCmp();
934            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
935            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
936            msg1.addUserDefinedParameter( "a", "x" );
937            msg1.addUserDefinedParameter( "b", "y" );
938            msg1.addUserDefinedParameter( "c", "z" );
939            msg2.addUserDefinedParameter( "a", "x" );
940            msg2.addUserDefinedParameter( "b", "y" );
941            msg2.addUserDefinedParameter( "c", "z" );
942            String diffMsg;
943            diffMsg = amc.compare( msg1, msg2 );
944            assertNull( 
945                    "comparison of messages with equal user defined properties" +
946                    " returned difference:"+diffMsg, diffMsg );
947            msg2.removeUserDefinedParameter( "c" );
948            diffMsg = amc.compare( msg1, msg2 );
949            assertNotNull( "message with an added user property returned as equal", 
950                    diffMsg );
951        }
952        
953        
954        // test consistency of AID HAP mapping across slots
955        
956        /**
957         * Test comparison of messages with AID HAP crossing slots.
958         * Slots using AID mapping for comparison are 
959         * <code>:sender</code>,
960         * <code>:receiver</code>, and
961         * <code>:reply-to</code>.
962         * @throws jade.lang.ACLCodec.CodecException converting string to message
963         */
964        public void testAidHapCrossSlot() throws ACLCodec.CodecException {
965            AclMsgCmp amc = new AclMsgCmp();
966            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
967            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
968            String diffMsg;
969            
970            // set up AID groups
971            msg1.clearAllReceiver();
972            msg2.clearAllReceiver();
973            msg1.clearAllReplyTo();
974            msg2.clearAllReplyTo();
975            msg1.setSender(   new AID( "a@foo:1098/JADE", AID.ISGUID ) );
976            msg1.addReceiver( new AID( "b@foo:1098/JADE", AID.ISGUID ) );
977            msg1.addReceiver( new AID( "c@baz:1098/JADE", AID.ISGUID ) );
978            msg1.addReplyTo(  new AID( "d@baz:1098/JADE", AID.ISGUID ) );
979            msg1.addReplyTo(  new AID( "e@foo:1098/JADE", AID.ISGUID ) );
980            msg2.setSender(   new AID( "a@bar:1099/JADE", AID.ISGUID ) );
981            msg2.addReceiver( new AID( "c@qux:1099/JADE", AID.ISGUID ) );
982            msg2.addReceiver( new AID( "b@bar:1099/JADE", AID.ISGUID ) );
983            msg2.addReplyTo(  new AID( "e@bar:1099/JADE", AID.ISGUID ) );
984            msg2.addReplyTo(  new AID( "d@qux:1099/JADE", AID.ISGUID ) );
985            diffMsg = amc.compare( msg1, msg2 );
986            assertNull( 
987                    "messages with same local AID but different HAP returned" +
988                    " as different in cross-slot testing:"+diffMsg,
989                    diffMsg );
990            
991            // set up a pair where AIDs are consistent with previous comparison
992            msg1.clearAllReceiver();
993            msg2.clearAllReceiver();
994            msg1.clearAllReplyTo();
995            msg2.clearAllReplyTo();
996            msg1.setSender(   new AID( "f@foo:1098/JADE", AID.ISGUID ) );
997            msg1.addReceiver( new AID( "g@foo:1098/JADE", AID.ISGUID ) );
998            msg1.addReplyTo(  new AID( "h@baz:1098/JADE", AID.ISGUID ) );
999            msg1.addReplyTo(  new AID( "i@baz:1098/JADE", AID.ISGUID ) );
1000            msg2.setSender(   new AID( "f@bar:1099/JADE", AID.ISGUID ) );
1001            msg2.addReceiver( new AID( "g@bar:1099/JADE", AID.ISGUID ) );
1002            msg2.addReplyTo(  new AID( "h@qux:1099/JADE", AID.ISGUID ) );
1003            msg2.addReplyTo(  new AID( "i@qux:1099/JADE", AID.ISGUID ) );
1004            diffMsg = amc.compare( msg1, msg2 );
1005            assertNull( "second messages in comparison series has consistent AIDs" +
1006                    " but failed comparison:"+diffMsg,
1007                    diffMsg );
1008            
1009            // set up a pair where AIDs are consistent with previous comparison
1010            msg1.clearAllReceiver();
1011            msg2.clearAllReceiver();
1012            msg1.clearAllReplyTo();
1013            msg2.clearAllReplyTo();
1014            msg1.setSender(   new AID( "f@foo:1098/JADE", AID.ISGUID ) );
1015            msg1.addReceiver( new AID( "g@foo:1098/JADE", AID.ISGUID ) );
1016            msg1.addReplyTo(  new AID( "h@baz:1098/JADE", AID.ISGUID ) );
1017            msg1.addReplyTo(  new AID( "i@baz:1098/JADE", AID.ISGUID ) );
1018            msg2.setSender(   new AID( "f@bar:1099/JADE", AID.ISGUID ) );
1019            msg2.addReceiver( new AID( "g@bar:1099/JADE", AID.ISGUID ) );
1020            msg2.addReplyTo(  new AID( "h@qux:1099/JADE", AID.ISGUID ) );
1021            msg2.addReplyTo(  new AID( "j@qux:1099/JADE", AID.ISGUID ) );
1022            diffMsg = amc.compare( msg1, msg2 );
1023            assertNotNull( "third messages in comparison series have inconsistent" +
1024                    " local names but were returned as equal:",
1025                    diffMsg );
1026            
1027            // set up a pair where AIDs are consistent with previous comparison
1028            msg1.clearAllReceiver();
1029            msg2.clearAllReceiver();
1030            msg1.clearAllReplyTo();
1031            msg2.clearAllReplyTo();
1032            msg1.setSender(   new AID( "f@foo:1098/JADE", AID.ISGUID ) );
1033            msg1.addReceiver( new AID( "g@foo:1098/JADE", AID.ISGUID ) );
1034            msg1.addReplyTo(  new AID( "h@baz:1098/JADE", AID.ISGUID ) );
1035            msg1.addReplyTo(  new AID( "i@baz:1098/JADE", AID.ISGUID ) );
1036            msg2.setSender(   new AID( "f@qux:1099/JADE", AID.ISGUID ) );
1037            msg2.addReceiver( new AID( "g@bar:1099/JADE", AID.ISGUID ) );
1038            msg2.addReplyTo(  new AID( "h@qux:1099/JADE", AID.ISGUID ) );
1039            msg2.addReplyTo(  new AID( "i@qux:1099/JADE", AID.ISGUID ) );
1040            diffMsg = amc.compare( msg1, msg2 );
1041            assertNotNull( 
1042                    "fourth messages in comparison series have inconsistent" +
1043                    " HAP but were returned as equal:",
1044                    diffMsg );
1045            
1046        }
1047        
1048        // test consistency of reply-id mapping across slots
1049        
1050        /**
1051         * Test comparison of messages with reply-id crossing slots.
1052         * Slots using reply-id mapping for comparison are 
1053         * <code>:reply-with</code>, and
1054         * <code>:in-reply-to</code>.
1055         * @throws jade.lang.ACLCodec.CodecException converting string to message
1056         */
1057        public void testReplyIdCrossSlot() throws ACLCodec.CodecException {
1058            AclMsgCmp amc = new AclMsgCmp();
1059            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1060            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1061            String diffMsg;
1062            
1063            // set up reply-id's
1064            msg1.setReplyWith( "abc" );
1065            msg2.setReplyWith( "def" );
1066            msg1.setInReplyTo( "ghi" );
1067            msg2.setInReplyTo( "jkl" );
1068            diffMsg = amc.compare( msg1, msg2 );
1069            assertNull( "messages returned reply-id different in initial" +
1070                    " reply-id cross-slot comparison:"+diffMsg,
1071                    diffMsg );
1072            
1073            // compare with consistent reply-id's
1074            msg1.setReplyWith( "def" );
1075            msg2.setReplyWith( "abc" );
1076            msg1.setInReplyTo( "jkl" );
1077            msg2.setInReplyTo( "ghi" );
1078            diffMsg = amc.compare( msg1, msg2 );
1079            assertNull( "messages returned reply-id different in consistent" +
1080                    " reply-id cross-slot comparison:"+diffMsg,
1081                    diffMsg );
1082            
1083            // compare with inconsistent reply-id's
1084            msg1.setReplyWith( "abc" );
1085            msg2.setReplyWith( "mno" );
1086            msg1.setInReplyTo( "pqr" );
1087            msg2.setInReplyTo( "jkl" );
1088            diffMsg = amc.compare( msg1, msg2 );
1089            assertNotNull( "messages returned reply-id equal in inconsistent" +
1090                    " reply-id cross-slot comparison",
1091                    diffMsg );
1092            
1093        }
1094        
1095        // test protected methods for content comparison
1096        
1097        /** a private class so can test protected AclMsgCmp methods. */
1098        private class AclMsgCmpForTest extends AclMsgCmp {
1099            /**
1100             * @param s string to convert
1101             * @param props mapping from variable string names to variable groups
1102             * @return List of String and Variable objects representing input string
1103             */
1104            public List strToVarStrList( String s, Properties props ) {
1105                List l = super.strToVarStrList( s, props );
1106                // make each variable manipulatable
1107                int listSize = l.size();
1108                for ( int i = 0; i < listSize; i++ ) {
1109                    Variable v = null;
1110                    try {
1111                        Object o = l.get( i );
1112                        if ( o instanceof Variable ) {
1113                            v = (Variable)o;
1114                            l.set( i, new VariableForTest( v.getName(), v.getType() ) );
1115                        }
1116                    }
1117                    catch ( Exception e ) {
1118                        throw new RuntimeException( "exception referencing variable/string"+
1119                                " list item:" + e.getMessage(), e );
1120                    }
1121                }
1122                return l;
1123            }
1124            /**
1125             * see whether given substring is at given position in given string to test
1126             * is protected instead of private only for testing purposes.
1127             * @param s string to see whether has embedded substring
1128             * @param pos position in s to check for embedded substring
1129             * @param sub substring to look for
1130             * @return whether substring is embedded in string at position
1131             */
1132            public boolean hasAtPos( char s[], int pos, char sub[] ) {
1133                return super.hasAtPos( s, pos, sub );
1134            }
1135            /**
1136             * given an ACLMessage content string, removed embedded AID addresses.
1137             * is protected instead of private only for testing purposes.
1138             * @param originalContent content string that want to filter
1139             * @return filtered version of input
1140             */
1141            public String filterEmbeddedAddresses( String originalContent ) {
1142                return super.filterEmbeddedAddresses( originalContent );
1143            }
1144            /** make inner class visible for testing */
1145            public class VariableForTest extends AclMsgCmp.Variable {
1146                /**
1147                 * construct with name and type.
1148                 * @param name string in message known to change
1149                 * @param type group of variables with consistent mapping
1150                 */
1151                public VariableForTest( String name, String type ) {
1152                    super( name, type );
1153                }
1154            }
1155        }
1156        
1157        /**
1158         * test conversion of a golden content string to list of strings and vars.
1159         */
1160        public void testContentStrToVarStrList() {
1161            AclMsgCmpForTest amc = new AclMsgCmpForTest();
1162            Properties props = new Properties();
1163            String aid1     = "a@foo:1098/JADE";
1164            String replyId1 = "reply-id1";
1165            String convId1  = "conv-idX";
1166            String cons1    = "abcdef";
1167            String rand1    = "1633389";
1168            props.setProperty( aid1,     AclMsgCmp.AID_MAP );
1169            props.setProperty( replyId1, AclMsgCmp.REPLY_ID_MAP );
1170            props.setProperty( convId1,  AclMsgCmp.CONVERSATION_ID_MAP );
1171            props.setProperty( cons1,    AclMsgCmp.CONSISTENT_MAP );
1172            props.setProperty( rand1,    AclMsgCmp.RANDOM_MAP );
1173            String s0 = "<foo>" + "<aid>";
1174            String s1 = "</aid>" + "<reply-id>";
1175            String s2 = "</reply-id>" + "<conv-id>";
1176            String s3 = "</conv-id>" + "<cons>";
1177            String s4 = "</cons>" + "<rand>";
1178            String s5 = "</rand>" + "</foo>";
1179            String s =
1180                s0 + aid1 + 
1181                s1 + replyId1 + 
1182                s2 + convId1 + 
1183                s3 + cons1 + 
1184                s4 + rand1 + 
1185                s5;
1186            List l = amc.strToVarStrList( s, props );
1187            try {
1188                Object o;
1189                AclMsgCmpForTest.VariableForTest v;
1190                
1191                assertEquals( 
1192                        "string 0 not found at expected place in constructed list",
1193                        s0, l.get(0) );
1194                
1195                o = l.get(1);
1196                assertTrue( "expected to find variable after string 0",
1197                        o instanceof AclMsgCmpForTest.VariableForTest );
1198                v = (AclMsgCmpForTest.VariableForTest)o;
1199                assertEquals( "didn't find expected AID variable", 
1200                        aid1, v.getName() );
1201                assertEquals( "didn't find expected AID type", 
1202                        AclMsgCmp.AID_MAP, v.getType() );
1203                
1204                assertEquals( 
1205                        "string 1 not found at expected place in constructed list",
1206                        s1, l.get(2) );
1207                
1208                o = l.get(3);
1209                assertTrue( "expected to find variable after string 1",
1210                        o instanceof AclMsgCmpForTest.VariableForTest );
1211                v = (AclMsgCmpForTest.VariableForTest)o;
1212                assertEquals( "didn't find expected reply-id variable", 
1213                        replyId1, v.getName() );
1214                assertEquals( "didn't find expected reply-id type", 
1215                        AclMsgCmp.REPLY_ID_MAP, v.getType() );
1216                
1217                assertEquals( 
1218                        "string 2 not found at expected place in constructed list",
1219                        s2, l.get(4) );
1220                
1221                o = l.get(5);
1222                assertTrue( "expected to find variable after string 2",
1223                        o instanceof AclMsgCmpForTest.VariableForTest );
1224                v = (AclMsgCmpForTest.VariableForTest)o;
1225                assertEquals( "didn't find expected conversation-id variable", 
1226                        convId1, v.getName() );
1227                assertEquals( "didn't find expected conversation-id type", 
1228                        AclMsgCmp.CONVERSATION_ID_MAP, v.getType() );
1229                
1230                assertEquals( 
1231                        "string 3 not found at expected place in constructed list",
1232                        s3, l.get(6) );
1233                
1234                o = l.get(7);
1235                assertTrue( "expected to find variable after string 3",
1236                        o instanceof AclMsgCmpForTest.VariableForTest );
1237                v = (AclMsgCmpForTest.VariableForTest)o;
1238                assertEquals( "didn't find expected consistent variable", 
1239                        cons1, v.getName() );
1240                assertEquals( "didn't find expected consistent type", 
1241                        AclMsgCmp.CONSISTENT_MAP, v.getType() );
1242                
1243                assertEquals( 
1244                        "string 4 not found at expected place in constructed list",
1245                        s4, l.get(8) );
1246                
1247                o = l.get(9);
1248                assertTrue( "expected to find variable after string 4",
1249                        o instanceof AclMsgCmpForTest.VariableForTest );
1250                v = (AclMsgCmpForTest.VariableForTest)o;
1251                assertEquals( "didn't find expected random variable", 
1252                        rand1, v.getName() );
1253                assertEquals( "didn't find expected random type", 
1254                        AclMsgCmp.RANDOM_MAP, v.getType() );
1255                
1256                assertEquals( 
1257                        "string 5 not found at expected place in constructed list",
1258                        s5, l.get(10) );
1259                
1260            }
1261            catch ( Exception e ) {
1262                throw new RuntimeException( "exception referencing variable/string"+
1263                        " list item:" + e.getMessage(), e );
1264            }
1265        }
1266        
1267        /**
1268         * test AclMsgCmp.hasAtPos()
1269         */
1270        public void testHasAtPos() {
1271            AclMsgCmpForTest amc = new AclMsgCmpForTest();
1272            String aidStr = "(agent-identifier :name df@picturebook:1098/JADE"+
1273            " :addresses (sequence http://picturebook:7778/acc))";
1274            String aidStartStr = "(agent-identifier ";
1275            String aidAddrStartStr = " :addresses (sequence ";
1276            assertTrue( "didn't find string at beginning",
1277                    amc.hasAtPos( aidStr.toCharArray(), 0, 
1278                                  aidStartStr.toCharArray() ) );
1279            assertTrue( "didn't find string in middle",
1280                    amc.hasAtPos( aidStr.toCharArray(), 48, 
1281                                  aidAddrStartStr.toCharArray() ) );
1282            assertFalse( "erroneously found string",
1283                    amc.hasAtPos( aidStr.toCharArray(), 1, 
1284                                  aidStartStr.toCharArray() ) );
1285            
1286        }
1287        
1288        /**
1289         * test AclMsgCmp.filterEmbeddedAddresses()
1290         */
1291        public void testFilterEmbeddedAddresses() {
1292            AclMsgCmpForTest amc = new AclMsgCmpForTest();
1293            String aidStr = "(agent-identifier :name df@picturebook:1098/JADE"+
1294            " :addresses (sequence http://picturebook:7778/acc))";
1295            String aidStrNoAddr = 
1296                "(agent-identifier :name df@picturebook:1098/JADE)";
1297            String result = amc.filterEmbeddedAddresses( aidStr );
1298            assertEquals( "didn't remove embedded address slot properly:\"" +
1299                    result+"\"",
1300                    result, aidStrNoAddr );
1301        }
1302        
1303        
1304        // test content comparison
1305    
1306        /**
1307         * test comparison of byte sequence content
1308         * @throws jade.lang.ACLCodec.CodecException converting string to message
1309         */
1310        public void testByteSequenceContent() throws ACLCodec.CodecException {
1311            
1312            byte content1[] = new byte[] { 0, 1, 2 };
1313            byte content2[] = new byte[] { 0, 1, 3 };
1314            
1315            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1316            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1317            
1318            msg1.setByteSequenceContent( content1 );
1319            msg2.setByteSequenceContent( content1 );
1320            
1321            AclMsgCmp amc = new AclMsgCmp();
1322            
1323            assertNull( amc.compare( msg1, msg2 ) );
1324    
1325            msg2.setByteSequenceContent( content2 );
1326            assertNotNull( amc.compare( msg1, msg2 ) );
1327    
1328        }
1329        
1330        
1331        /**
1332         * test content newline normalization
1333         * @throws jade.lang.ACLCodec.CodecException converting string to message
1334         */
1335        public void testContentNewlineNormalization() throws ACLCodec.CodecException {
1336    
1337            String content1 =
1338                "((iota ?x (Registered (df-agent-description :name ?x :services \n"+
1339                "(set (service-description :name caboodle-agent-user))))) \n"+
1340                "(action (agent-identifier :name Recruiter\n"+
1341                ") (REQUEST :reply-to \n"+
1342                "(set (agent-identifier :name gateway\n"+
1343                ")) :language http-get \n"+
1344                ":protocol fipa-request \n"+
1345                ":content \"locale=en_US&locale=en_US&device=html\")) )";
1346            String content2 =
1347                "((iota ?x (Registered (df-agent-description :name ?x :services \r\n"+
1348                "(set (service-description :name caboodle-agent-user))))) \r\n"+
1349                "(action (agent-identifier :name Recruiter\r\n"+
1350                ") (REQUEST :reply-to \r\n"+
1351                "(set (agent-identifier :name gateway\r\n"+
1352                ")) :language http-get \r\n"+
1353                ":protocol fipa-request \r\n"+
1354                ":content \"locale=en_US&locale=en_US&device=html\")) )";
1355            
1356            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1357            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1358            
1359            AclMsgCmp amc = new AclMsgCmp();
1360            
1361            amc.setNewlinesNormalized( true );
1362            msg1.setContent( content1 );
1363            msg2.setContent( content1 );
1364            assertNull( amc.compare( msg1, msg2 ) );
1365    
1366            msg2.setContent( content2 );
1367            assertNull( amc.compare( msg1, msg2 ) );
1368    
1369            amc.setNewlinesNormalized( false );
1370            assertNotNull( amc.compare( msg1, msg2 ) );
1371    
1372        }
1373        
1374        /**
1375         * test globalization of AID strings in content
1376         * @throws jade.lang.ACLCodec.CodecException converting string to message
1377         */
1378        public void testContentAIDGlobalization() throws ACLCodec.CodecException {
1379            String hap = "picturebook:1098/JADE";
1380            String localContent =
1381                "((iota ?x (Registered (df-agent-description :name ?x :services "+
1382                "(set (service-description :name caboodle-agent-user))))) "+
1383                "(action (agent-identifier :name Recruiter"+
1384                ") (REQUEST :reply-to "+
1385                "(set (agent-identifier :name gateway"+
1386                ")) :language http-get "+
1387                ":protocol fipa-request "+
1388                ":content \"locale=en_US&locale=en_US&device=html\")) )";
1389            String globalContent =
1390                "((iota ?x (Registered (df-agent-description :name ?x :services "+
1391                "(set (service-description :name caboodle-agent-user))))) "+
1392                "(action (agent-identifier :name Recruiter"+ '@' + hap +
1393                ") (REQUEST :reply-to "+
1394                "(set (agent-identifier :name gateway"+ '@' + hap +
1395                ")) :language http-get "+
1396                ":protocol fipa-request "+
1397                ":content \"locale=en_US&locale=en_US&device=html\")) )";
1398            
1399            AclMsgCmp amc = new AclMsgCmp();
1400            String globalizedContent = 
1401                amc.globalizeContentAgentIds( localContent, hap );
1402            
1403            assertEquals( "incorrectly globalized content string:\""+
1404                    globalizedContent+"\"",
1405                    globalContent, globalizedContent );
1406        }
1407        
1408        
1409        /**
1410         * test conversion of a golden content string to list of strings and vars.
1411         * @throws jade.lang.ACLCodec.CodecException converting string to message
1412         */
1413        public void testContent() throws ACLCodec.CodecException {
1414            AclMsgCmp amc = new AclMsgCmp();
1415            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1416            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1417            String diffMsg;
1418            
1419            Properties props = new Properties();
1420            String aid1     = "a@foo:1098/JADE";
1421            String replyId1 = "reply-id1";
1422            String convId1  = "conv-idX";
1423            String cons1    = "abcdef";
1424            String rand1    = "16333894234";
1425            props.setProperty( aid1,     AclMsgCmp.AID_MAP );
1426            props.setProperty( replyId1, AclMsgCmp.REPLY_ID_MAP );
1427            props.setProperty( convId1,  AclMsgCmp.CONVERSATION_ID_MAP );
1428            props.setProperty( cons1,    AclMsgCmp.CONSISTENT_MAP );
1429            props.setProperty( rand1,    AclMsgCmp.RANDOM_MAP );
1430            String s0 = "<foo>" + "<aid>";
1431            String s1 = "</aid>" + "<reply-id>";
1432            String s2 = "</reply-id>" + "<conv-id>";
1433            String s3 = "</conv-id>" + "<cons>";
1434            String s4 = "</cons>" + "<rand>";
1435            String s5 = "</rand>" + "</foo>";
1436            String s =
1437                s0 + aid1 + 
1438                s1 + replyId1 + 
1439                s2 + convId1 + 
1440                s3 + cons1 + 
1441                s4 + rand1 + 
1442                s5;
1443            msg1.setContent( s );
1444            
1445            // compare against an equal string, setting mappings
1446            String aid2     = "a@barbaz:1099/JADE";
1447            String replyId2 = "reply.id2";
1448            String convId2  = "conversation-idY";
1449            String cons2    = "ghi";
1450            String rand2    = "qwerty";
1451            String sEqual =
1452                s0 + aid2 + 
1453                s1 + replyId2 + 
1454                s2 + convId2 + 
1455                s3 + cons2 + 
1456                s4 + rand2 + 
1457                s5;
1458            msg2.setContent( sEqual );
1459            diffMsg = amc.compare( msg1, msg2, props );
1460            assertNull( "comparison of messages with equivalent content" +
1461                    " returned difference:"+diffMsg, diffMsg );
1462            
1463            // compare with unequal AID string
1464            String sUnequalAID =
1465                s0 + "b@barbaz:1099/JADE" + 
1466                s1 + replyId2 + 
1467                s2 + convId2 + 
1468                s3 + cons2 + 
1469                s4 + rand2 + 
1470                s5;
1471            msg2.setContent( sUnequalAID );
1472            diffMsg = amc.compare( msg1, msg2, props );
1473            assertNotNull( "comparison of messages failed to find different" +
1474                    " AID variable:", diffMsg );
1475            
1476            // compare with unequal reply-id string
1477            String sUnequalReplyId =
1478                s0 + aid2 + 
1479                s1 + "no-such-exchange" + 
1480                s2 + convId2 + 
1481                s3 + cons2 + 
1482                s4 + rand2 + 
1483                s5;
1484            msg2.setContent( sUnequalReplyId );
1485            diffMsg = amc.compare( msg1, msg2, props );
1486            assertNotNull( "comparison of messages failed to find different" +
1487                    " reply-id variable:", diffMsg );
1488            
1489            // compare with unequal conversation-id string
1490            String sUnequalConvId =
1491                s0 + aid2 + 
1492                s1 + replyId2 + 
1493                s2 + "we're not talking!" + 
1494                s3 + cons2 + 
1495                s4 + rand2 + 
1496                s5;
1497            msg2.setContent( sUnequalConvId );
1498            diffMsg = amc.compare( msg1, msg2, props );
1499            assertNotNull( "comparison of messages failed to find different" +
1500                    " conversation-id variable:", diffMsg );
1501            
1502            // compare with unequal consistent string
1503            String sUnequalCons =
1504                s0 + aid2 + 
1505                s1 + replyId2 + 
1506                s2 + convId2 + 
1507                s3 + "MANY ARE CALLED BUT FEW ARE FROZEN" + 
1508                s4 + rand2 + 
1509                s5;
1510            msg2.setContent( sUnequalCons );
1511            diffMsg = amc.compare( msg1, msg2, props );
1512            assertNotNull( "comparison of messages failed to find different" +
1513                    " consistent variable:", diffMsg );
1514            
1515            // compare with changed random string which should make no difference
1516            String sEqualChgdRandom =
1517                s0 + aid2 + 
1518                s1 + replyId2 + 
1519                s2 + convId2 + 
1520                s3 + cons2 + 
1521                s4 + rand2 + 
1522                s5;
1523            msg2.setContent( sEqualChgdRandom );
1524            diffMsg = amc.compare( msg1, msg2, props );
1525            assertNull( "comparison of messages found erroneous difference after" +
1526                    " changing random variable:"+diffMsg, diffMsg );
1527            
1528        }
1529        
1530        /**
1531         * test comparison of content with variable of type random
1532         * @throws jade.lang.ACLCodec.CodecException converting string to message
1533         */
1534        public void testContentRandom() throws ACLCodec.CodecException {
1535            AclMsgCmp amc = new AclMsgCmp();
1536            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1537            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1538            String diffMsg;
1539            
1540            String content1 = "<CONTENT_ELEMENT type=\"GET-UI\"><user>"+
1541            "<phoneno>6505768544</phoneno><fullname>Kai Laurinolli</fullname>"+
1542            "<userid>11111111111</userid><password>***</password>"+
1543            "<userlocale>en_US</userlocale><username>Kai</username></user>"+
1544            "<name>mainMenu</name><device>html</device>"+
1545            "<session>User_130056312145_0</session></CONTENT_ELEMENT>";
1546            String content2 = "<CONTENT_ELEMENT type=\"GET-UI\"><user>"+
1547            "<phoneno>6505768544</phoneno><fullname>Kai Laurinolli</fullname>"+
1548            "<userid>11111111111</userid><password>***</password>"+
1549            "<userlocale>en_US</userlocale><username>Kai</username></user>"+
1550            "<name>mainMenu</name><device>html</device>"+
1551            "<session>User_170340953758_0</session></CONTENT_ELEMENT>";
1552            msg1.setContent( content1 );
1553            msg2.setContent( content2 );
1554            Properties props = new Properties();
1555            String rand1    = "User_130056312145_0";
1556            props.setProperty( rand1, AclMsgCmp.RANDOM_MAP );
1557            
1558            diffMsg = amc.compare( msg1, msg2, props );
1559            assertNull( "comparison of messages found erroneous difference after" +
1560                    " changing random variable:"+diffMsg, diffMsg );
1561            
1562        }    
1563        
1564        
1565        /**
1566         * test comparison of embedded addresses within content
1567         * @throws jade.lang.ACLCodec.CodecException converting string to message
1568         */
1569        public void testContentEmbeddedAddresses() throws ACLCodec.CodecException {
1570            AclMsgCmp amc = new AclMsgCmp();
1571            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1572            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1573            String diffMsg;
1574            
1575            String contentNoMtpSet = 
1576             "((result (action (agent-identifier :name df@picturebook:1098/JADE)"+
1577             " (search (df-agent-description :services (set (service-description"+
1578             " :type caboodle-agent-recruiting))) (search-constraints :max-depth"+
1579             " 3))) (sequence (df-agent-description :name (agent-identifier :name"+
1580             " Recruiter@picturebook:1098/JADE) :services "+
1581             "(set (service-description"+
1582             " :name Recruiter@picturebook:1098/JADE"+
1583             " :type caboodle-agent-recruiting"+
1584             " :ownership \"Caboodle Networks\"))))))";
1585            
1586            String contentWithMTP =
1587                "((result (action (agent-identifier :name df@picturebook:1098/JADE"+
1588                " :addresses (sequence http://picturebook:7778/acc)) (search "+
1589                "(df-agent-description :services (set (service-description :type"+
1590                " caboodle-agent-recruiting))) (search-constraints :max-depth 3)))"+
1591                " (sequence (df-agent-description :name (agent-identifier :name"+
1592                " Recruiter@picturebook:1098/JADE :addresses"+
1593                " (sequence http://picturebook:7778/acc)) :services (set"+
1594                " (service-description :name Recruiter@picturebook:1098/JADE :type"+
1595                " caboodle-agent-recruiting :ownership \"Caboodle Networks\"))))))";
1596            
1597            msg1.setContent( contentNoMtpSet );
1598            msg2.setContent( contentWithMTP );
1599            
1600            // don't need props, agent global id's are same
1601            
1602            // test default of ignoring AID addresses within content
1603            diffMsg = amc.compare( msg1, msg2 );
1604            assertNull( "comparison of messages with different AID addresses "+
1605                    "found erroneous difference:"+diffMsg, diffMsg );
1606            
1607            amc.setIgnoreContentAIDAddresses( false );
1608            diffMsg = amc.compare( msg1, msg2 );
1609            assertNotNull( "comparison of messages failed to find different" +
1610                    " embedded AID addresses in content:", diffMsg );
1611            
1612            String contentNoMtpSet2 =
1613                "((action ( agent-identifier :name df@picturebook:1098/JADE ) "+
1614                "(search (df-agent-description :services (set "+
1615                "(service-description :type caboodle-agent-recruiting))) "+
1616                "(search-constraints :max-depth 3))))";
1617            String contentWithMTP2 =
1618                "((action ( agent-identifier :name df@picturebook:1098/JADE  "+
1619                ":addresses (sequence http://picturebook:7778/acc )) "+
1620                "(search (df-agent-description :services (set "+
1621                "(service-description :type caboodle-agent-recruiting))) "+
1622                "(search-constraints :max-depth 3))))";
1623            msg1.setContent( contentNoMtpSet2 );
1624            msg2.setContent( contentWithMTP2 );
1625            amc.setIgnoreContentAIDAddresses( true );
1626            diffMsg = amc.compare( msg1, msg2 );
1627            assertNull( "2nd comparison of messages with different AID addresses "+
1628                    "found erroneous difference:"+diffMsg, diffMsg );
1629            
1630            amc.setIgnoreContentAIDAddresses( false );
1631            diffMsg = amc.compare( msg1, msg2 );
1632            assertNotNull( "2nd comparison of messages failed to find different" +
1633                    " embedded AID addresses in content:", diffMsg );
1634            
1635            
1636        }
1637        
1638        /**
1639         * test envelope comparison WHICH IS NOT YET IMPLEMENTED.
1640         * so it checks for an expected runtime exception.
1641         * @throws CodecException 
1642         */
1643        public void testCompareEnvelope() throws CodecException {
1644            AclMsgCmp amc = new AclMsgCmp();
1645            ACLMessage msg1 = AclMsgCmp.stringToMessage( proxyMsg );
1646            ACLMessage msg2 = AclMsgCmp.stringToMessage( proxyMsg );
1647            amc.setCmpEnvelope( true );
1648            try {
1649                amc.compare( msg1, msg2 );
1650                fail("no runtime exception thrown for envelope comparison");
1651            }
1652            catch ( RuntimeException re ) {
1653                assertTrue(true); // because not yet implemented
1654            }
1655        }
1656    
1657        
1658        // suite
1659        
1660        /**
1661         * return the implicit suite of tests
1662         * @return the implicit suite of tests
1663         */
1664        public static Test suite() {
1665            return new TestSuite( 
1666                    AclMsgCmpTest.class, 
1667                    JadeMXSuiteTest.nameWithClass( AclMsgCmpTest.class, 
1668                    "testing AclMsgCmp: ACLMessage comparison") );
1669        }
1670        
1671    
1672    }