86bfcd5c4493e06e6c8d26607d19b6b2784bdb14
[policy/engine.git] / ECOMP-PDP / src / test / java / org / openecomp / policy / pdp / test / FunctionDefinitionEqualityTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP-PDP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.policy.pdp.test;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
28
29 import java.net.URI;
30 import java.util.ArrayList;
31 import java.util.Calendar;
32 import java.util.Date;
33 import java.util.List;
34
35 import javax.security.auth.x500.X500Principal;
36
37 import org.junit.Test;
38
39 import com.att.research.xacml.api.XACML1;
40 import com.att.research.xacml.api.XACML3;
41 import com.att.research.xacml.std.datatypes.Base64Binary;
42 import com.att.research.xacml.std.datatypes.DataTypeRFC822Name;
43 import com.att.research.xacml.std.datatypes.DataTypes;
44 import com.att.research.xacml.std.datatypes.HexBinary;
45 import com.att.research.xacml.std.datatypes.RFC822Name;
46 import com.att.research.xacml.std.datatypes.XPathDayTimeDuration;
47 import com.att.research.xacml.std.datatypes.XPathYearMonthDuration;
48 import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
49 import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
50 import com.att.research.xacmlatt.pdp.policy.FunctionArgumentAttributeValue;
51 import com.att.research.xacmlatt.pdp.std.StdFunctions;
52 import com.att.research.xacmlatt.pdp.std.functions.*;
53
54 /**
55  * Test FunctionDefinitionEquality, all of its super-classes, and all XACML functions supported by that class.
56  * 
57  * TO RUN - use jUnit
58  * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
59  * 
60  * In the first implementation of XACML we had separate files for each XACML Function.
61  * This release combines multiple Functions in fewer files to minimize code duplication.
62  * This file supports the following XACML codes:
63  *              string-equal
64  *              boolean-equal
65  *              integer-equal
66  *              double-equal
67  *              date-equal
68  *              time-equal
69  *              dateTime-equal
70  *              dayTimeDuration-equal
71  *              yearMonthDuration-equal
72  * 
73  * Each of these is put into a separate test method just to keep things organized.
74  * 
75  *
76  */
77 public class FunctionDefinitionEqualityTest {
78
79         /*
80          * variables useful in the following tests
81          */
82         List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
83         
84         FunctionArgumentAttributeValue stringAttr1 = null;
85         FunctionArgumentAttributeValue stringAttr2 = null;
86         FunctionArgumentAttributeValue stringAttr3 = null;
87         FunctionArgumentAttributeValue stringAttr4 =  null;
88
89         FunctionArgumentAttributeValue booleanAttrT1 = null;
90         FunctionArgumentAttributeValue booleanAttrT2 = null;
91         FunctionArgumentAttributeValue booleanAttrF1 = null;
92         FunctionArgumentAttributeValue booleanAttrF2 = null;
93
94         FunctionArgumentAttributeValue intAttr1 = null;
95         FunctionArgumentAttributeValue intAttr1a = null;
96         FunctionArgumentAttributeValue intAttr2 = null;
97         FunctionArgumentAttributeValue intAttr0 = null;
98         FunctionArgumentAttributeValue intAttrNeg1 = null;
99
100         public FunctionDefinitionEqualityTest() {
101                 try {
102                         stringAttr1 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue("abc"));
103                         stringAttr2 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue("abc"));
104                         stringAttr3 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue("ABC"));
105                         stringAttr4 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue("def"));
106
107                         booleanAttrT1 = new FunctionArgumentAttributeValue(DataTypes.DT_BOOLEAN.createAttributeValue(true));
108                         booleanAttrT2 = new FunctionArgumentAttributeValue(DataTypes.DT_BOOLEAN.createAttributeValue(true));
109                         booleanAttrF1 = new FunctionArgumentAttributeValue(DataTypes.DT_BOOLEAN.createAttributeValue(false));
110                         booleanAttrF2 = new FunctionArgumentAttributeValue(DataTypes.DT_BOOLEAN.createAttributeValue(false));
111
112                         intAttr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(1));
113                         intAttr1a = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(1));
114                         intAttr2 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(2));
115                         intAttr0 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(0));
116                         intAttrNeg1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(-1));
117                 } catch (Exception e) {
118                         fail("creating attribute e="+ e);
119                 }
120         }
121         
122         
123         
124         
125         /**
126          * String (matching case)
127          */
128         @Test
129         public void testString_Equal() {
130                 
131                 // String exact match
132                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_STRING_EQUAL;
133                 
134                 // check identity and type of the thing created
135                 assertEquals(XACML3.ID_FUNCTION_STRING_EQUAL, fd.getId());
136                 assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeArgs().getId());
137                 
138                 // just to be safe...  If tests take too long these can probably be eliminated
139                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
140                 assertFalse(fd.returnsBag());
141                 assertEquals(new Integer(2), fd.getNumArgs());
142                 
143                 // test normal equals and non-equals
144                 // check "abc" with "abc" - separate string objects with same value
145                 arguments.add(stringAttr1);
146                 arguments.add(stringAttr2);
147                 ExpressionResult res = fd.evaluate(null, arguments);
148                 assertTrue(res.isOk());
149                 Boolean resValue = (Boolean)res.getValue().getValue();
150                 assertTrue(resValue);
151
152                 // check "abc" with "ABC" (not same)
153                 arguments.clear();
154                 arguments.add(stringAttr1);
155                 arguments.add(stringAttr3);
156                 res = fd.evaluate(null, arguments);
157                 assertTrue(res.isOk());
158                 resValue = (Boolean)res.getValue().getValue();
159                 assertFalse(resValue);
160                 
161                 // test bad args data types?  Not needed?
162                 arguments.clear();
163                 arguments.add(stringAttr1);
164                 arguments.add(intAttr1);
165                 res = fd.evaluate(null, arguments);
166                 assertFalse(res.isOk());
167
168         }
169
170         
171         
172         /**
173          * Boolean
174          */
175         @Test
176         public void testBoolean_Equal() {
177                 
178                 // String exact match
179                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_BOOLEAN_EQUAL;
180                 
181                 // check identity and type of the thing created
182                 assertEquals(XACML3.ID_FUNCTION_BOOLEAN_EQUAL, fd.getId());
183                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeArgs().getId());
184                 
185                 // just to be safe...  If tests take too long these can probably be eliminated
186                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
187                 assertFalse(fd.returnsBag());
188                 assertEquals(new Integer(2), fd.getNumArgs());
189                 
190                 // test normal equals and non-equals
191                 // check separate objects with same value
192                 arguments.add(booleanAttrT1);
193                 arguments.add(booleanAttrT2);
194                 ExpressionResult res = fd.evaluate(null, arguments);
195                 assertTrue(res.isOk());
196                 Boolean resValue = (Boolean)res.getValue().getValue();
197                 assertTrue(resValue);
198
199                 // check different values
200                 arguments.clear();
201                 arguments.add(booleanAttrT1);
202                 arguments.add(booleanAttrF1);
203                 res = fd.evaluate(null, arguments);
204                 assertTrue(res.isOk());
205                 resValue = (Boolean)res.getValue().getValue();
206                 assertFalse(resValue);
207                 
208                 // test bad args data types?  Not needed?
209                 arguments.clear();
210                 arguments.add(stringAttr1);
211                 arguments.add(intAttr1);
212                 res = fd.evaluate(null, arguments);
213                 assertFalse(res.isOk());
214
215         }
216         
217         
218         /**
219          * Integer
220          */
221         @Test
222         public void testInteger_Equal() {
223                 
224                 // String exact match
225                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_INTEGER_EQUAL;
226                 
227                 // check identity and type of the thing created
228                 assertEquals(XACML3.ID_FUNCTION_INTEGER_EQUAL, fd.getId());
229                 assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
230                 
231                 // just to be safe...  If tests take too long these can probably be eliminated
232                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
233                 assertFalse(fd.returnsBag());
234                 assertEquals(new Integer(2), fd.getNumArgs());
235                 
236                 // test normal equals and non-equals
237                 // check separate objects with same value
238                 arguments.add(intAttr1);
239                 arguments.add(intAttr1a);
240                 ExpressionResult res = fd.evaluate(null, arguments);
241                 assertTrue(res.isOk());
242                 Boolean resValue = (Boolean)res.getValue().getValue();
243                 assertTrue(resValue);
244
245                 // check not same
246                 arguments.clear();
247                 arguments.add(intAttr1);
248                 arguments.add(intAttr2);
249                 res = fd.evaluate(null, arguments);
250                 assertTrue(res.isOk());
251                 resValue = (Boolean)res.getValue().getValue();
252                 assertFalse(resValue);
253                 
254                 arguments.clear();
255                 arguments.add(intAttr1);
256                 arguments.add(intAttrNeg1);
257                 res = fd.evaluate(null, arguments);
258                 assertTrue(res.isOk());
259                 resValue = (Boolean)res.getValue().getValue();
260                 assertFalse(resValue);
261                 
262                 
263                 // test bad args data types?  Not needed?
264                 arguments.clear();
265                 arguments.add(stringAttr1);
266                 arguments.add(intAttr1);
267                 res = fd.evaluate(null, arguments);
268                 assertFalse(res.isOk());
269
270         }
271         
272         
273         
274         /**
275          * Double
276          */
277         @Test
278         public void testDouble_Equal() {
279                 FunctionArgumentAttributeValue attr1 = null;
280                 FunctionArgumentAttributeValue attr1a = null;
281                 FunctionArgumentAttributeValue attr2 = null;
282                 FunctionArgumentAttributeValue attrNeg1 = null;
283                 try {
284                         attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.0));
285                         attr1a = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.0));
286                         attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(2.4));
287                         attrNeg1 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-1.0));
288                 } catch (Exception e) {
289                         fail("creating attribute e="+ e);
290                 }
291                 
292                 // String exact match
293                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_DOUBLE_EQUAL;
294                 
295                 // check identity and type of the thing created
296                 assertEquals(XACML3.ID_FUNCTION_DOUBLE_EQUAL, fd.getId());
297                 assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
298                 
299                 // just to be safe...  If tests take too long these can probably be eliminated
300                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
301                 assertFalse(fd.returnsBag());
302                 assertEquals(new Integer(2), fd.getNumArgs());
303                 
304                 // test normal equals and non-equals
305                 // check separate objects with the same value
306                 arguments.add(attr1);
307                 arguments.add(attr1a);
308                 ExpressionResult res = fd.evaluate(null, arguments);
309                 assertTrue(res.isOk());
310                 Boolean resValue = (Boolean)res.getValue().getValue();
311                 assertTrue(resValue);
312
313                 // check not same
314                 arguments.clear();
315                 arguments.add(attr1);
316                 arguments.add(attr2);
317                 res = fd.evaluate(null, arguments);
318                 assertTrue(res.isOk());
319                 resValue = (Boolean)res.getValue().getValue();
320                 assertFalse(resValue);
321                 
322                 arguments.clear();
323                 arguments.add(attr1);
324                 arguments.add(attrNeg1);
325                 res = fd.evaluate(null, arguments);
326                 assertTrue(res.isOk());
327                 resValue = (Boolean)res.getValue().getValue();
328                 assertFalse(resValue);
329                 
330                 
331                 // test bad args data types?  Not needed?
332                 arguments.clear();
333                 arguments.add(stringAttr1);
334                 arguments.add(intAttr1);
335                 res = fd.evaluate(null, arguments);
336                 assertFalse(res.isOk());
337
338         }
339         
340         
341         
342         
343         
344         /**
345          * Date
346          */
347         @Test
348         public void testDate_Equal() {
349                 Calendar calendar = Calendar.getInstance();
350                 Date today = calendar.getTime();
351                 Date longAgo = new Date(1234);
352                 // create a date that is different than "today" but within the same day (i.e. has a different hour)
353                 if (calendar.get(Calendar.HOUR_OF_DAY) > 3) {
354                         calendar.set(Calendar.HOUR_OF_DAY, 3);
355                 } else {
356                         calendar.set(Calendar.HOUR_OF_DAY, 5);
357                 }
358                 Date todayPlus = calendar.getTime();
359
360
361                 FunctionArgumentAttributeValue attrToday = null;
362                 FunctionArgumentAttributeValue attrToday2 = null;
363                 FunctionArgumentAttributeValue attrLaterToday = null;           
364                 FunctionArgumentAttributeValue attrYesterday = null;
365                 try {
366                         attrToday = new FunctionArgumentAttributeValue(DataTypes.DT_DATE.createAttributeValue(today));
367                         attrToday2 = new FunctionArgumentAttributeValue(DataTypes.DT_DATE.createAttributeValue(today));
368                         attrLaterToday = new FunctionArgumentAttributeValue(DataTypes.DT_DATE.createAttributeValue(todayPlus));         
369                         attrYesterday = new FunctionArgumentAttributeValue(DataTypes.DT_DATE.createAttributeValue(longAgo));
370                 } catch (Exception e) {
371                         fail("creating attribute e="+ e);
372                 }
373                 
374                 // String exact match
375                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_DATE_EQUAL;
376                 
377                 // check identity and type of the thing created
378                 assertEquals(XACML3.ID_FUNCTION_DATE_EQUAL, fd.getId());
379                 assertEquals(DataTypes.DT_DATE.getId(), fd.getDataTypeArgs().getId());
380                 
381                 // just to be safe...  If tests take too long these can probably be eliminated
382                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
383                 assertFalse(fd.returnsBag());
384                 assertEquals(new Integer(2), fd.getNumArgs());
385                 
386                 // test normal equals and non-equals
387                 // check separate objects with the same value
388                 arguments.add(attrToday);
389                 arguments.add(attrToday2);
390                 ExpressionResult res = fd.evaluate(null, arguments);
391                 assertTrue(res.isOk());
392                 Boolean resValue = (Boolean)res.getValue().getValue();
393                 assertTrue(resValue);
394
395                 // check not same
396                 arguments.clear();
397                 arguments.add(attrToday);
398                 arguments.add(attrYesterday);
399                 res = fd.evaluate(null, arguments);
400                 assertTrue(res.isOk());
401                 resValue = (Boolean)res.getValue().getValue();
402                 assertFalse(resValue);
403                 
404                 // Date objects with different times but within the same day should match
405                 arguments.clear();
406                 arguments.add(attrToday);
407                 arguments.add(attrLaterToday);
408                 res = fd.evaluate(null, arguments);
409                 assertTrue(res.isOk());
410                 resValue = (Boolean)res.getValue().getValue();
411                 assertTrue(resValue);
412
413                 // test bad args data types?  Not needed?
414                 arguments.clear();
415                 arguments.add(stringAttr1);
416                 arguments.add(intAttr1);
417                 res = fd.evaluate(null, arguments);
418                 assertFalse(res.isOk());
419
420         }
421         
422         
423         
424         
425         /**
426          * Time
427          */
428         @Test
429         public void testTime_Equal() {
430                 
431                 Date now = new Date();
432                 Date now2 = new Date(now.getTime());
433                 Date notNow = new Date(now.getTime() - 100000);
434                 
435                 FunctionArgumentAttributeValue attrNow = null;
436                 FunctionArgumentAttributeValue attrNow2 = null;
437                 FunctionArgumentAttributeValue attrNotNow = null;
438                 try {
439                         attrNow = new FunctionArgumentAttributeValue(DataTypes.DT_TIME.createAttributeValue(now));
440                         attrNow2 = new FunctionArgumentAttributeValue(DataTypes.DT_TIME.createAttributeValue(now2));
441                         attrNotNow = new FunctionArgumentAttributeValue(DataTypes.DT_TIME.createAttributeValue(notNow));
442                 } catch (Exception e) {
443                         fail("creating attribute e="+ e);
444                 }
445
446                 // String exact match
447                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_TIME_EQUAL;
448                 
449                 // check identity and type of the thing created
450                 assertEquals(XACML3.ID_FUNCTION_TIME_EQUAL, fd.getId());
451                 assertEquals(DataTypes.DT_TIME.getId(), fd.getDataTypeArgs().getId());
452                 
453                 // just to be safe...  If tests take too long these can probably be eliminated
454                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
455                 assertFalse(fd.returnsBag());
456                 assertEquals(new Integer(2), fd.getNumArgs());
457                 
458                 // test normal equals and non-equals
459                 // check separate objects with the same value
460                 arguments.add(attrNow);
461                 arguments.add(attrNow2);
462                 ExpressionResult res = fd.evaluate(null, arguments);
463                 assertTrue(res.isOk());
464                 Boolean resValue = (Boolean)res.getValue().getValue();
465                 assertTrue(resValue);
466
467                 // check not same
468                 arguments.clear();
469                 arguments.add(attrNow);
470                 arguments.add(attrNotNow);
471                 res = fd.evaluate(null, arguments);
472                 assertTrue(res.isOk());
473                 resValue = (Boolean)res.getValue().getValue();
474                 assertFalse(resValue);
475                 
476                 // test bad args data types?  Not needed?
477                 arguments.clear();
478                 arguments.add(stringAttr1);
479                 arguments.add(intAttr1);
480                 res = fd.evaluate(null, arguments);
481                 assertFalse(res.isOk());
482
483         }
484         
485         
486         
487         
488         /**
489          * DateTime
490          */
491         @Test
492         public void testDateTime_Equal() {
493                 Calendar calendar = Calendar.getInstance();
494                 Date today = calendar.getTime();
495                 Date longAgo = new Date(1234);
496                 // create a dateTime that is different than "today" changing only the Timezone
497                 if (calendar.get(Calendar.ZONE_OFFSET) > 3) {
498                         calendar.set(Calendar.ZONE_OFFSET, 3);
499                 } else {
500                         calendar.set(Calendar.ZONE_OFFSET, 5);
501                 }
502                 Date todayPlus = calendar.getTime();
503
504
505                 FunctionArgumentAttributeValue attrToday = null;
506                 FunctionArgumentAttributeValue attrToday2 = null;
507                 FunctionArgumentAttributeValue attrLaterToday = null;           
508                 FunctionArgumentAttributeValue attrYesterday = null;
509                 try {
510                         attrToday = new FunctionArgumentAttributeValue(DataTypes.DT_DATETIME.createAttributeValue(today));
511                         attrToday2 = new FunctionArgumentAttributeValue(DataTypes.DT_DATETIME.createAttributeValue(today));
512                         attrLaterToday = new FunctionArgumentAttributeValue(DataTypes.DT_DATETIME.createAttributeValue(todayPlus));             
513                         attrYesterday = new FunctionArgumentAttributeValue(DataTypes.DT_DATETIME.createAttributeValue(longAgo));
514                 } catch (Exception e) {
515                         fail("creating attribute e="+ e);
516                 }
517                 
518                 // String exact match
519                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_DATETIME_EQUAL;
520                 
521                 // check identity and type of the thing created
522                 assertEquals(XACML3.ID_FUNCTION_DATETIME_EQUAL, fd.getId());
523                 assertEquals(DataTypes.DT_DATETIME.getId(), fd.getDataTypeArgs().getId());
524                 
525                 // just to be safe...  If tests take too long these can probably be eliminated
526                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
527                 assertFalse(fd.returnsBag());
528                 assertEquals(new Integer(2), fd.getNumArgs());
529                 
530                 // test normal equals and non-equals
531                 // check separate objects with the same value
532                 arguments.add(attrToday);
533                 arguments.add(attrToday2);
534                 ExpressionResult res = fd.evaluate(null, arguments);
535                 assertTrue(res.isOk());
536                 Boolean resValue = (Boolean)res.getValue().getValue();
537                 assertTrue(resValue);
538
539                 // check not same
540                 arguments.clear();
541                 arguments.add(attrToday);
542                 arguments.add(attrYesterday);
543                 res = fd.evaluate(null, arguments);
544                 assertTrue(res.isOk());
545                 resValue = (Boolean)res.getValue().getValue();
546                 assertFalse(resValue);
547                 
548                 // DateTime with different Zones should not match
549                 arguments.clear();
550                 arguments.add(attrToday);
551                 arguments.add(attrLaterToday);
552                 res = fd.evaluate(null, arguments);
553                 assertTrue(res.isOk());
554                 resValue = (Boolean)res.getValue().getValue();
555                 assertFalse(resValue);
556
557                 // test bad args data types?  Not needed?
558                 arguments.clear();
559                 arguments.add(stringAttr1);
560                 arguments.add(intAttr1);
561                 res = fd.evaluate(null, arguments);
562                 assertFalse(res.isOk());
563
564         }
565         
566         
567         /**
568          * dayTimeDuration - Version1
569          */
570         @Test
571         public void testDayTimeDuration_Equal_V1() {
572                 
573                 XPathDayTimeDuration dur1 = new XPathDayTimeDuration(1, 3, 5, 12, 38);
574                 XPathDayTimeDuration dur2 = new XPathDayTimeDuration(1, 3, 5, 12, 38);
575                 XPathDayTimeDuration differentDur = new XPathDayTimeDuration(-1, 4, 7, 5, 33);
576
577                 FunctionArgumentAttributeValue attrDur1 = null;
578                 FunctionArgumentAttributeValue attrDur2 = null;
579                 FunctionArgumentAttributeValue attrDifferentDur = null;
580                 try {
581                         attrDur1 = new FunctionArgumentAttributeValue(DataTypes.DT_DAYTIMEDURATION.createAttributeValue(dur1));
582                         attrDur2 = new FunctionArgumentAttributeValue(DataTypes.DT_DAYTIMEDURATION.createAttributeValue(dur2));
583                         attrDifferentDur = new FunctionArgumentAttributeValue(DataTypes.DT_DAYTIMEDURATION.createAttributeValue(differentDur));         
584                 } catch (Exception e) {
585                         fail("creating attribute e="+ e);
586                 }
587                 
588                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_DAYTIMEDURATION_EQUAL_VERSION1;
589                 
590                 // check identity and type of the thing created
591                 assertEquals(XACML1.ID_FUNCTION_DAYTIMEDURATION_EQUAL, fd.getId());
592                 assertEquals(DataTypes.DT_DAYTIMEDURATION.getId(), fd.getDataTypeArgs().getId());
593                 
594                 // just to be safe...  If tests take too long these can probably be eliminated
595                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
596                 assertFalse(fd.returnsBag());
597                 assertEquals(new Integer(2), fd.getNumArgs());
598                 
599                 // test normal equals and non-equals
600                 // check separate objects with the same value
601                 arguments.add(attrDur1);
602                 arguments.add(attrDur2);
603                 ExpressionResult res = fd.evaluate(null, arguments);
604                 assertTrue(res.isOk());
605                 Boolean resValue = (Boolean)res.getValue().getValue();
606                 assertTrue(resValue);
607
608                 // check not same
609                 arguments.clear();
610                 arguments.add(attrDur1);
611                 arguments.add(attrDifferentDur);
612                 res = fd.evaluate(null, arguments);
613                 assertTrue(res.isOk());
614                 resValue = (Boolean)res.getValue().getValue();
615                 assertFalse(resValue);
616
617                 // test bad args data types?  Not needed?
618                 arguments.clear();
619                 arguments.add(stringAttr1);
620                 arguments.add(intAttr1);
621                 res = fd.evaluate(null, arguments);
622                 assertFalse(res.isOk());
623
624         }
625         
626         
627         /**
628          * dayTimeDuration - Current version
629          */
630         @Test
631         public void testDayTimeDuration_Equal() {
632                 
633                 XPathDayTimeDuration dur1 = new XPathDayTimeDuration(1, 3, 5, 12, 38);
634                 XPathDayTimeDuration dur2 = new XPathDayTimeDuration(1, 3, 5, 12, 38);
635                 XPathDayTimeDuration differentDur = new XPathDayTimeDuration(-1, 4, 7, 5, 33);
636
637                 FunctionArgumentAttributeValue attrDur1 = null;
638                 FunctionArgumentAttributeValue attrDur2 = null;
639                 FunctionArgumentAttributeValue attrDifferentDur = null;         
640                 try {
641                         attrDur1 = new FunctionArgumentAttributeValue(DataTypes.DT_DAYTIMEDURATION.createAttributeValue(dur1));
642                         attrDur2 = new FunctionArgumentAttributeValue(DataTypes.DT_DAYTIMEDURATION.createAttributeValue(dur2));
643                         attrDifferentDur = new FunctionArgumentAttributeValue(DataTypes.DT_DAYTIMEDURATION.createAttributeValue(differentDur)); 
644                 } catch (Exception e) {
645                         fail("creating attribute e="+ e);
646                 }
647                 
648                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_DAYTIMEDURATION_EQUAL;
649                 
650                 // check identity and type of the thing created
651                 assertEquals(XACML3.ID_FUNCTION_DAYTIMEDURATION_EQUAL, fd.getId());
652                 assertEquals(DataTypes.DT_DAYTIMEDURATION.getId(), fd.getDataTypeArgs().getId());
653                 
654                 // just to be safe...  If tests take too long these can probably be eliminated
655                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
656                 assertFalse(fd.returnsBag());
657                 assertEquals(new Integer(2), fd.getNumArgs());
658                 
659                 // test normal equals and non-equals
660                 // check separate objects with the same value
661                 arguments.add(attrDur1);
662                 arguments.add(attrDur2);
663                 ExpressionResult res = fd.evaluate(null, arguments);
664                 assertTrue(res.isOk());
665                 Boolean resValue = (Boolean)res.getValue().getValue();
666                 assertTrue(resValue);
667
668                 // check not same
669                 arguments.clear();
670                 arguments.add(attrDur1);
671                 arguments.add(attrDifferentDur);
672                 res = fd.evaluate(null, arguments);
673                 assertTrue(res.isOk());
674                 resValue = (Boolean)res.getValue().getValue();
675                 assertFalse(resValue);
676
677                 // test bad args data types?  Not needed?
678                 arguments.clear();
679                 arguments.add(stringAttr1);
680                 arguments.add(intAttr1);
681                 res = fd.evaluate(null, arguments);
682                 assertFalse(res.isOk());
683
684         }
685         
686         
687         
688         /**
689          * dayTimeDuration - Version1
690          */
691         @Test
692         public void testYearMonthDuration_Equal_V1() {
693                 
694                 XPathYearMonthDuration dur1 = new XPathYearMonthDuration(1, 3, 5);
695                 XPathYearMonthDuration dur2 = new XPathYearMonthDuration(1, 3, 5);
696                 XPathYearMonthDuration differentDur = new XPathYearMonthDuration(-1, 4, 7);
697
698                 FunctionArgumentAttributeValue attrDur1 = null;
699                 FunctionArgumentAttributeValue attrDur2 = null;
700                 FunctionArgumentAttributeValue attrDifferentDur = null;         
701                 try {
702                         attrDur1 = new FunctionArgumentAttributeValue(DataTypes.DT_YEARMONTHDURATION.createAttributeValue(dur1));
703                         attrDur2 = new FunctionArgumentAttributeValue(DataTypes.DT_YEARMONTHDURATION.createAttributeValue(dur2));
704                         attrDifferentDur = new FunctionArgumentAttributeValue(DataTypes.DT_YEARMONTHDURATION.createAttributeValue(differentDur));
705                 } catch (Exception e) {
706                         fail("creating attribute e="+ e);
707                 }
708
709                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_YEARMONTHDURATION_EQUAL_VERSION1;
710                 
711                 // check identity and type of the thing created
712                 assertEquals(XACML1.ID_FUNCTION_YEARMONTHDURATION_EQUAL, fd.getId());
713                 assertEquals(DataTypes.DT_YEARMONTHDURATION.getId(), fd.getDataTypeArgs().getId());
714                 
715                 // just to be safe...  If tests take too long these can probably be eliminated
716                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
717                 assertFalse(fd.returnsBag());
718                 assertEquals(new Integer(2), fd.getNumArgs());
719                 
720                 // test normal equals and non-equals
721                 // check separate objects with the same value
722                 arguments.add(attrDur1);
723                 arguments.add(attrDur2);
724                 ExpressionResult res = fd.evaluate(null, arguments);
725                 assertTrue(res.isOk());
726                 Boolean resValue = (Boolean)res.getValue().getValue();
727                 assertTrue(resValue);
728
729                 // check not same
730                 arguments.clear();
731                 arguments.add(attrDur1);
732                 arguments.add(attrDifferentDur);
733                 res = fd.evaluate(null, arguments);
734                 assertTrue(res.isOk());
735                 resValue = (Boolean)res.getValue().getValue();
736                 assertFalse(resValue);
737
738                 // test bad args data types?  Not needed?
739                 arguments.clear();
740                 arguments.add(stringAttr1);
741                 arguments.add(intAttr1);
742                 res = fd.evaluate(null, arguments);
743                 assertFalse(res.isOk());
744
745         }
746         
747         
748
749         
750         /**
751          * dayTimeDuration - Current version
752          */
753         @Test
754         public void testYearMonthDuration_Equal() {
755                 
756                 XPathYearMonthDuration dur1 = new XPathYearMonthDuration(1, 3, 5);
757                 XPathYearMonthDuration dur2 = new XPathYearMonthDuration(1, 3, 5);
758                 XPathYearMonthDuration differentDur = new XPathYearMonthDuration(-1, 4, 7);
759
760                 FunctionArgumentAttributeValue attrDur1 = null;
761                 FunctionArgumentAttributeValue attrDur2 = null;
762                 FunctionArgumentAttributeValue attrDifferentDur = null;         
763                 try {
764                         attrDur1 = new FunctionArgumentAttributeValue(DataTypes.DT_YEARMONTHDURATION.createAttributeValue(dur1));
765                         attrDur2 = new FunctionArgumentAttributeValue(DataTypes.DT_YEARMONTHDURATION.createAttributeValue(dur2));
766                         attrDifferentDur = new FunctionArgumentAttributeValue(DataTypes.DT_YEARMONTHDURATION.createAttributeValue(differentDur));       
767                 } catch (Exception e) {
768                         fail("creating attribute e="+ e);
769                 }
770
771                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_YEARMONTHDURATION_EQUAL;
772                 
773                 // check identity and type of the thing created
774                 assertEquals(XACML3.ID_FUNCTION_YEARMONTHDURATION_EQUAL, fd.getId());
775                 assertEquals(DataTypes.DT_YEARMONTHDURATION.getId(), fd.getDataTypeArgs().getId());
776                 
777                 // just to be safe...  If tests take too long these can probably be eliminated
778                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
779                 assertFalse(fd.returnsBag());
780                 assertEquals(new Integer(2), fd.getNumArgs());
781                 
782                 // test normal equals and non-equals
783                 // check separate objects with the same value
784                 arguments.add(attrDur1);
785                 arguments.add(attrDur2);
786                 ExpressionResult res = fd.evaluate(null, arguments);
787                 assertTrue(res.isOk());
788                 Boolean resValue = (Boolean)res.getValue().getValue();
789                 assertTrue(resValue);
790
791                 // check not same
792                 arguments.clear();
793                 arguments.add(attrDur1);
794                 arguments.add(attrDifferentDur);
795                 res = fd.evaluate(null, arguments);
796                 assertTrue(res.isOk());
797                 resValue = (Boolean)res.getValue().getValue();
798                 assertFalse(resValue);
799
800                 // test bad args data types?  Not needed?
801                 arguments.clear();
802                 arguments.add(stringAttr1);
803                 arguments.add(intAttr1);
804                 res = fd.evaluate(null, arguments);
805                 assertFalse(res.isOk());
806
807         }
808         
809         
810         /**
811          * URI
812          */
813         @Test
814         public void testAnyURI_Equal() {
815
816                 URI uri1 = null;
817                 URI uri2 = null;
818                 URI uriNotThere = null;
819                 try {
820                         uri1 = new URI("http://someplace.com/gothere");
821                         uri2 = new URI("http://someplace.com/gothere");
822                         uriNotThere = new URI("http://someplace.com/notGoingThere");
823                 } catch (Exception e) {
824                         fail(e.toString());
825                 }
826
827                 FunctionArgumentAttributeValue attrUri1 = null;
828                 FunctionArgumentAttributeValue attrUri2 = null;
829                 FunctionArgumentAttributeValue attrUriNotThere = null;  
830                 try {
831                         attrUri1 = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue(uri1));
832                         attrUri2 = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue(uri2));
833                         attrUriNotThere = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue(uriNotThere));    
834                 } catch (Exception e) {
835                         fail("creating attribute e="+ e);
836                 }
837
838                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_ANYURI_EQUAL;
839                 
840                 // check identity and type of the thing created
841                 assertEquals(XACML3.ID_FUNCTION_ANYURI_EQUAL, fd.getId());
842                 assertEquals(DataTypes.DT_ANYURI.getId(), fd.getDataTypeArgs().getId());
843                 
844                 // just to be safe...  If tests take too long these can probably be eliminated
845                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
846                 assertFalse(fd.returnsBag());
847                 assertEquals(new Integer(2), fd.getNumArgs());
848                 
849                 // test normal equals and non-equals
850                 // check separate objects with the same value
851                 arguments.add(attrUri1);
852                 arguments.add(attrUri2);
853                 ExpressionResult res = fd.evaluate(null, arguments);
854                 assertTrue(res.isOk());
855                 Boolean resValue = (Boolean)res.getValue().getValue();
856                 assertTrue(resValue);
857
858                 // check not same
859                 arguments.clear();
860                 arguments.add(attrUri1);
861                 arguments.add(attrUriNotThere);
862                 res = fd.evaluate(null, arguments);
863                 assertTrue(res.isOk());
864                 resValue = (Boolean)res.getValue().getValue();
865                 assertFalse(resValue);
866
867                 // test bad args data types?  Not needed?
868                 arguments.clear();
869                 arguments.add(stringAttr1);
870                 arguments.add(intAttr1);
871                 res = fd.evaluate(null, arguments);
872                 assertFalse(res.isOk());
873
874         }
875         
876         
877         /**
878          * X500Name
879          */
880         @Test
881         public void testX500Name_Equal() {
882
883                 X500Principal name1 = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US");
884                 X500Principal name2 = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US");
885                 X500Principal name3 = new X500Principal("CN=NotDuke, OU=NotThere, O=Oracle, C=US");
886
887
888                 FunctionArgumentAttributeValue attrName1 = null;
889                 FunctionArgumentAttributeValue attrName1a = null;
890                 FunctionArgumentAttributeValue attrNotSameName = null;          
891                 try {
892                         attrName1 = new FunctionArgumentAttributeValue(DataTypes.DT_X500NAME.createAttributeValue(name1));
893                         attrName1a = new FunctionArgumentAttributeValue(DataTypes.DT_X500NAME.createAttributeValue(name2));
894                         attrNotSameName = new FunctionArgumentAttributeValue(DataTypes.DT_X500NAME.createAttributeValue(name3));        
895                 } catch (Exception e) {
896                         fail("creating attribute e="+ e);
897                 }
898
899                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_X500NAME_EQUAL;
900                 
901                 // check identity and type of the thing created
902                 assertEquals(XACML3.ID_FUNCTION_X500NAME_EQUAL, fd.getId());
903                 assertEquals(DataTypes.DT_X500NAME.getId(), fd.getDataTypeArgs().getId());
904                 
905                 // just to be safe...  If tests take too long these can probably be eliminated
906                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
907                 assertFalse(fd.returnsBag());
908                 assertEquals(new Integer(2), fd.getNumArgs());
909                 
910                 // test normal equals and non-equals
911                 // check separate objects with the same value
912                 arguments.add(attrName1);
913                 arguments.add(attrName1a);
914                 ExpressionResult res = fd.evaluate(null, arguments);
915                 assertTrue(res.isOk());
916                 Boolean resValue = (Boolean)res.getValue().getValue();
917                 assertTrue(resValue);
918
919                 // check not same
920                 arguments.clear();
921                 arguments.add(attrName1);
922                 arguments.add(attrNotSameName);
923                 res = fd.evaluate(null, arguments);
924                 assertTrue(res.isOk());
925                 resValue = (Boolean)res.getValue().getValue();
926                 assertFalse(resValue);
927
928                 // test bad args data types?  Not needed?
929                 arguments.clear();
930                 arguments.add(stringAttr1);
931                 arguments.add(intAttr1);
932                 res = fd.evaluate(null, arguments);
933                 assertFalse(res.isOk());
934
935         }
936         
937         
938         
939         /**
940          * RFC822Name
941          */
942         @Test
943         public void testRfc822Name_Equal() {
944
945                 RFC822Name name1 = null;
946                 RFC822Name name1a = null;
947                 RFC822Name differentLocalName = null;
948                 RFC822Name differentDomainName = null;
949                 RFC822Name localCaseName = null;
950                 RFC822Name domainCaseName = null;
951                 @SuppressWarnings("unused")
952                 RFC822Name noAtName = null;
953                 
954                 try {
955                         name1 = RFC822Name.newInstance("localPart@DomainPart");
956                         name1a = RFC822Name.newInstance("localPart@DomainPart");
957                         differentLocalName = RFC822Name.newInstance("differentlocalPart@DomainPart");
958                         differentDomainName = RFC822Name.newInstance("localPart@differentDomainPart");
959                         localCaseName = RFC822Name.newInstance("LOCALPart@DomainPart");
960                         domainCaseName = RFC822Name.newInstance("localPart@DOMAINPart");
961
962
963                 } catch (Exception e) {
964                         fail(e.toString());
965                 }
966                 
967                 // should not be able to create a name without an @.  If you try, newInstance returns null
968                 Exception exSeen = null;
969                 try {
970                         noAtName = RFC822Name.newInstance("nameWithoutAnAtSign");
971                 } catch (Exception e) {
972                         exSeen = e;
973                 }
974                 assertNotNull(exSeen);
975                 
976
977                 FunctionArgumentAttributeValue attrName1 = null;
978                 FunctionArgumentAttributeValue attrName1a = null;
979                 FunctionArgumentAttributeValue attrDifferentLocalName = null;           
980                 FunctionArgumentAttributeValue attrDifferentDomainName = null;          
981                 FunctionArgumentAttributeValue attrLocalCaseName = null;
982                 FunctionArgumentAttributeValue attrDomainCaseName = null;
983                 try {
984                         attrName1 = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(name1));
985                         attrName1a = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(name1a));
986                         attrDifferentLocalName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(differentLocalName));          
987                         attrDifferentDomainName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(differentDomainName));                
988                         attrLocalCaseName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(localCaseName));
989                         attrDomainCaseName = new FunctionArgumentAttributeValue(DataTypes.DT_RFC822NAME.createAttributeValue(domainCaseName));
990                 } catch (Exception e) {
991                         fail("creating attribute e="+ e);
992                 }
993
994                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_RFC822NAME_EQUAL;
995                 
996                 // check identity and type of the thing created
997                 assertEquals(XACML3.ID_FUNCTION_RFC822NAME_EQUAL, fd.getId());
998                 assertEquals(DataTypeRFC822Name.newInstance().getId(), fd.getDataTypeArgs().getId());
999                 
1000                 // just to be safe...  If tests take too long these can probably be eliminated
1001                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
1002                 assertFalse(fd.returnsBag());
1003                 assertEquals(new Integer(2), fd.getNumArgs());
1004                 
1005                 // test normal equals and non-equals
1006                 // check separate objects with the same value
1007                 arguments.add(attrName1);
1008                 arguments.add(attrName1a);
1009                 ExpressionResult res = fd.evaluate(null, arguments);
1010                 assertTrue(res.isOk());
1011                 Boolean resValue = (Boolean)res.getValue().getValue();
1012                 assertTrue(resValue);
1013
1014                 // check not same Local
1015                 arguments.clear();
1016                 arguments.add(attrName1);
1017                 arguments.add(attrDifferentLocalName);
1018                 res = fd.evaluate(null, arguments);
1019                 assertTrue(res.isOk());
1020                 resValue = (Boolean)res.getValue().getValue();
1021                 assertFalse(resValue);
1022                 
1023                 // check not same Domain
1024                 arguments.clear();
1025                 arguments.add(attrName1);
1026                 arguments.add(attrDifferentDomainName);
1027                 res = fd.evaluate(null, arguments);
1028                 assertTrue(res.isOk());
1029                 resValue = (Boolean)res.getValue().getValue();
1030                 assertFalse(resValue);
1031                 
1032                 // test case-sensitivity in local part
1033                 arguments.clear();
1034                 arguments.add(attrName1);
1035                 arguments.add(attrLocalCaseName);
1036                 res = fd.evaluate(null, arguments);
1037                 assertTrue(res.isOk());
1038                 resValue = (Boolean)res.getValue().getValue();
1039                 assertFalse(resValue);
1040                 
1041                 // test non-case-sensitivity in Domain part
1042                 arguments.clear();
1043                 arguments.add(attrName1);
1044                 arguments.add(attrDomainCaseName);
1045                 res = fd.evaluate(null, arguments);
1046                 assertTrue(res.isOk());
1047                 resValue = (Boolean)res.getValue().getValue();
1048                 assertTrue(resValue);
1049                 
1050                 // test bad args data types?  Not needed?
1051                 arguments.clear();
1052                 arguments.add(stringAttr1);
1053                 arguments.add(intAttr1);
1054                 res = fd.evaluate(null, arguments);
1055                 assertFalse(res.isOk());
1056
1057         }
1058         
1059         
1060         /**
1061          * Hex Binary
1062          */
1063         @Test
1064         public void testHexBinary_Equal() {
1065                 HexBinary binary = null;
1066                 HexBinary sameBinary = null;
1067                 HexBinary differentBinary = null;
1068                 try {
1069                         binary = HexBinary.newInstance("e04fd020ea3a6910a2d808002b30309d");
1070                         sameBinary = HexBinary.newInstance("e04fd020ea3a6910a2d808002b30309d");
1071                         differentBinary = HexBinary.newInstance("f123a890ee3d");
1072                 } catch (Exception e) {
1073                         fail(e.toString());
1074                 }
1075
1076                 FunctionArgumentAttributeValue attrBinary = null;
1077                 FunctionArgumentAttributeValue attrSameBinary = null;
1078                 FunctionArgumentAttributeValue attrDifferentBinary = null;;             
1079                 try {
1080                         attrBinary = new FunctionArgumentAttributeValue(DataTypes.DT_HEXBINARY.createAttributeValue(binary));
1081                         attrSameBinary = new FunctionArgumentAttributeValue(DataTypes.DT_HEXBINARY.createAttributeValue(sameBinary));
1082                         attrDifferentBinary = new FunctionArgumentAttributeValue(DataTypes.DT_HEXBINARY.createAttributeValue(differentBinary));         
1083
1084                 } catch (Exception e) {
1085                         fail("creating attribute e="+ e);
1086                 }
1087
1088                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_HEXBINARY_EQUAL;
1089                 
1090                 // check identity and type of the thing created
1091                 assertEquals(XACML3.ID_FUNCTION_HEXBINARY_EQUAL, fd.getId());
1092                 assertEquals(DataTypes.DT_HEXBINARY.getId(), fd.getDataTypeArgs().getId());
1093                 
1094                 // just to be safe...  If tests take too long these can probably be eliminated
1095                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
1096                 assertFalse(fd.returnsBag());
1097                 assertEquals(new Integer(2), fd.getNumArgs());
1098                 
1099                 // test normal equals and non-equals
1100                 // check separate objects with the same value
1101                 arguments.add(attrBinary);
1102                 arguments.add(attrSameBinary);
1103                 ExpressionResult res = fd.evaluate(null, arguments);
1104                 assertTrue(res.isOk());
1105                 Boolean resValue = (Boolean)res.getValue().getValue();
1106                 assertTrue(resValue);
1107
1108                 // check not same
1109                 arguments.clear();
1110                 arguments.add(attrBinary);
1111                 arguments.add(attrDifferentBinary);
1112                 res = fd.evaluate(null, arguments);
1113                 assertTrue(res.isOk());
1114                 resValue = (Boolean)res.getValue().getValue();
1115                 assertFalse(resValue);
1116
1117                 // test bad args data types?  Not needed?
1118                 arguments.clear();
1119                 arguments.add(stringAttr1);
1120                 arguments.add(intAttr1);
1121                 res = fd.evaluate(null, arguments);
1122                 assertFalse(res.isOk());
1123
1124         }
1125         
1126         
1127         /**
1128          * Base64 Binary
1129          */
1130         @Test
1131         public void testBase64Binary_Equal() {
1132                 Base64Binary binary = null;
1133                 Base64Binary sameBinary = null;
1134                 Base64Binary differentBinary = null;
1135                 try {
1136                         binary = Base64Binary.newInstance("TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz");
1137                         sameBinary = Base64Binary.newInstance("TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz");
1138                         differentBinary = Base64Binary.newInstance("f123a890ee3d");
1139                 } catch (Exception e) {
1140                         fail(e.toString());
1141                 }
1142
1143                 FunctionArgumentAttributeValue attrBinary = null;
1144                 FunctionArgumentAttributeValue attrSameBinary = null;
1145                 FunctionArgumentAttributeValue attrDifferentBinary = null;              
1146                 try {
1147                         attrBinary = new FunctionArgumentAttributeValue(DataTypes.DT_BASE64BINARY.createAttributeValue(binary));
1148                         attrSameBinary = new FunctionArgumentAttributeValue(DataTypes.DT_BASE64BINARY.createAttributeValue(sameBinary));
1149                         attrDifferentBinary = new FunctionArgumentAttributeValue(DataTypes.DT_BASE64BINARY.createAttributeValue(differentBinary));              
1150
1151                 } catch (Exception e) {
1152                         fail("creating attribute e="+ e);
1153                 }
1154
1155                 FunctionDefinitionEquality<?> fd = (FunctionDefinitionEquality<?>) StdFunctions.FD_BASE64BINARY_EQUAL;
1156                 
1157                 // check identity and type of the thing created
1158                 assertEquals(XACML3.ID_FUNCTION_BASE64BINARY_EQUAL, fd.getId());
1159                 assertEquals(DataTypes.DT_BASE64BINARY.getId(), fd.getDataTypeArgs().getId());
1160                 
1161                 // just to be safe...  If tests take too long these can probably be eliminated
1162                 assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
1163                 assertFalse(fd.returnsBag());
1164                 assertEquals(new Integer(2), fd.getNumArgs());
1165                 
1166                 // test normal equals and non-equals
1167                 // check separate objects with the same value
1168                 arguments.add(attrBinary);
1169                 arguments.add(attrSameBinary);
1170                 ExpressionResult res = fd.evaluate(null, arguments);
1171                 assertTrue(res.isOk());
1172                 Boolean resValue = (Boolean)res.getValue().getValue();
1173                 assertTrue(resValue);
1174
1175                 // check not same
1176                 arguments.clear();
1177                 arguments.add(attrBinary);
1178                 arguments.add(attrDifferentBinary);
1179                 res = fd.evaluate(null, arguments);
1180                 assertTrue(res.isOk());
1181                 resValue = (Boolean)res.getValue().getValue();
1182                 assertFalse(resValue);
1183
1184                 // test bad args data types?  Not needed?
1185                 arguments.clear();
1186                 arguments.add(stringAttr1);
1187                 arguments.add(intAttr1);
1188                 res = fd.evaluate(null, arguments);
1189                 assertFalse(res.isOk());
1190
1191         }
1192 }