1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.lang;
18  
19  import java.lang.reflect.Constructor;
20  import java.lang.reflect.Modifier;
21  
22  import junit.framework.Test;
23  import junit.framework.TestCase;
24  import junit.framework.TestSuite;
25  import junit.textui.TestRunner;
26  
27  /**
28   * Unit tests {@link org.apache.commons.lang.BooleanUtils}.
29   *
30   * @author Stephen Colebourne
31   * @author Matthew Hawthorne
32   * @version $Id: BooleanUtilsTest.java 589050 2007-10-27 05:07:45Z bayard $
33   */
34  public class BooleanUtilsTest extends TestCase {
35  
36      public BooleanUtilsTest(String name) {
37          super(name);
38      }
39  
40      public static void main(String[] args) {
41          TestRunner.run(suite());
42      }
43  
44      public static Test suite() {
45          TestSuite suite = new TestSuite(BooleanUtilsTest.class);
46          suite.setName("BooleanUtils Tests");
47          return suite;
48      }
49  
50      protected void setUp() throws Exception {
51          super.setUp();
52      }
53  
54      protected void tearDown() throws Exception {
55          super.tearDown();
56      }
57  
58      //-----------------------------------------------------------------------
59      public void testConstructor() {
60          assertNotNull(new BooleanUtils());
61          Constructor[] cons = BooleanUtils.class.getDeclaredConstructors();
62          assertEquals(1, cons.length);
63          assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
64          assertEquals(true, Modifier.isPublic(BooleanUtils.class.getModifiers()));
65          assertEquals(false, Modifier.isFinal(BooleanUtils.class.getModifiers()));
66      }
67      
68      //-----------------------------------------------------------------------
69      public void test_negate_Boolean() {
70          assertSame(null, BooleanUtils.negate(null));
71          assertSame(Boolean.TRUE, BooleanUtils.negate(Boolean.FALSE));
72          assertSame(Boolean.FALSE, BooleanUtils.negate(Boolean.TRUE));
73      }
74  
75      //-----------------------------------------------------------------------
76      public void test_isTrue_Boolean() {
77          assertEquals(true, BooleanUtils.isTrue(Boolean.TRUE));
78          assertEquals(false, BooleanUtils.isTrue(Boolean.FALSE));
79          assertEquals(false, BooleanUtils.isTrue((Boolean) null));
80      }
81  
82      public void test_isNotTrue_Boolean() {
83          assertEquals(false, BooleanUtils.isNotTrue(Boolean.TRUE));
84          assertEquals(true, BooleanUtils.isNotTrue(Boolean.FALSE));
85          assertEquals(true, BooleanUtils.isNotTrue((Boolean) null));
86      }
87  
88      //-----------------------------------------------------------------------
89      public void test_isFalse_Boolean() {
90          assertEquals(false, BooleanUtils.isFalse(Boolean.TRUE));
91          assertEquals(true, BooleanUtils.isFalse(Boolean.FALSE));
92          assertEquals(false, BooleanUtils.isFalse((Boolean) null));
93      }
94  
95      public void test_isNotFalse_Boolean() {
96          assertEquals(true, BooleanUtils.isNotFalse(Boolean.TRUE));
97          assertEquals(false, BooleanUtils.isNotFalse(Boolean.FALSE));
98          assertEquals(true, BooleanUtils.isNotFalse((Boolean) null));
99      }
100 
101     //-----------------------------------------------------------------------
102     public void test_toBooleanObject_boolean() {
103         assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(true));
104         assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(false));
105     }
106 
107     public void test_toBoolean_Boolean() {
108         assertEquals(true, BooleanUtils.toBoolean(Boolean.TRUE));
109         assertEquals(false, BooleanUtils.toBoolean(Boolean.FALSE));
110         assertEquals(false, BooleanUtils.toBoolean((Boolean) null));
111     }
112 
113     public void test_toBooleanDefaultIfNull_Boolean_boolean() {
114         assertEquals(true, BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, true));
115         assertEquals(true, BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false));
116         assertEquals(false, BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true));
117         assertEquals(false, BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, false));
118         assertEquals(true, BooleanUtils.toBooleanDefaultIfNull((Boolean) null, true));
119         assertEquals(false, BooleanUtils.toBooleanDefaultIfNull((Boolean) null, false));
120     }
121 
122     //-----------------------------------------------------------------------
123     //-----------------------------------------------------------------------
124     public void test_toBoolean_int() {
125         assertEquals(true, BooleanUtils.toBoolean(1));
126         assertEquals(true, BooleanUtils.toBoolean(-1));
127         assertEquals(false, BooleanUtils.toBoolean(0));
128     }
129     
130     public void test_toBooleanObject_int() {
131         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(1));
132         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(-1));
133         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(0));
134     }
135     
136     public void test_toBooleanObject_Integer() {
137         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(1)));
138         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(-1)));
139         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(0)));
140         assertEquals(null, BooleanUtils.toBooleanObject((Integer) null));
141     }
142     
143     //-----------------------------------------------------------------------
144     public void test_toBoolean_int_int_int() {
145         assertEquals(true, BooleanUtils.toBoolean(6, 6, 7));
146         assertEquals(false, BooleanUtils.toBoolean(7, 6, 7));
147         try {
148             BooleanUtils.toBoolean(8, 6, 7);
149             fail();
150         } catch (IllegalArgumentException ex) {}
151     }
152     
153     public void test_toBoolean_Integer_Integer_Integer() {
154         Integer six = new Integer(6);
155         Integer seven = new Integer(7);
156 
157         assertEquals(true, BooleanUtils.toBoolean((Integer) null, null, seven));
158         assertEquals(false, BooleanUtils.toBoolean((Integer) null, six, null));
159         try {
160             BooleanUtils.toBoolean(null, six, seven);
161             fail();
162         } catch (IllegalArgumentException ex) {}
163         
164         assertEquals(true, BooleanUtils.toBoolean(new Integer(6), six, seven));
165         assertEquals(false, BooleanUtils.toBoolean(new Integer(7), six, seven));
166         try {
167             BooleanUtils.toBoolean(new Integer(8), six, seven);
168             fail();
169         } catch (IllegalArgumentException ex) {}
170     }
171     
172     //-----------------------------------------------------------------------
173     public void test_toBooleanObject_int_int_int() {
174         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(6, 6, 7, 8));
175         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(7, 6, 7, 8));
176         assertEquals(null, BooleanUtils.toBooleanObject(8, 6, 7, 8));
177         try {
178             BooleanUtils.toBooleanObject(9, 6, 7, 8);
179             fail();
180         } catch (IllegalArgumentException ex) {}
181     }
182     
183     public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
184         Integer six = new Integer(6);
185         Integer seven = new Integer(7);
186         Integer eight = new Integer(8);
187 
188         assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
189         assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
190         assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null));
191         try {
192             BooleanUtils.toBooleanObject(null, six, seven, eight);
193             fail();
194         } catch (IllegalArgumentException ex) {}
195         
196         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(6), six, seven, eight));
197         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(7), six, seven, eight));
198         assertEquals(null, BooleanUtils.toBooleanObject(new Integer(8), six, seven, eight));
199         try {
200             BooleanUtils.toBooleanObject(new Integer(9), six, seven, eight);
201             fail();
202         } catch (IllegalArgumentException ex) {}
203     }
204     
205     //-----------------------------------------------------------------------
206     public void test_toInteger_boolean() {
207         assertEquals(1, BooleanUtils.toInteger(true));
208         assertEquals(0, BooleanUtils.toInteger(false));
209     }
210     
211     public void test_toIntegerObject_boolean() {
212         assertEquals(new Integer(1), BooleanUtils.toIntegerObject(true));
213         assertEquals(new Integer(0), BooleanUtils.toIntegerObject(false));
214     }
215     
216     public void test_toIntegerObject_Boolean() {
217         assertEquals(new Integer(1), BooleanUtils.toIntegerObject(Boolean.TRUE));
218         assertEquals(new Integer(0), BooleanUtils.toIntegerObject(Boolean.FALSE));
219         assertEquals(null, BooleanUtils.toIntegerObject((Boolean) null));
220     }
221     
222     //-----------------------------------------------------------------------
223     public void test_toInteger_boolean_int_int() {
224         assertEquals(6, BooleanUtils.toInteger(true, 6, 7));
225         assertEquals(7, BooleanUtils.toInteger(false, 6, 7));
226     }
227     
228     public void test_toInteger_Boolean_int_int_int() {
229         assertEquals(6, BooleanUtils.toInteger(Boolean.TRUE, 6, 7, 8));
230         assertEquals(7, BooleanUtils.toInteger(Boolean.FALSE, 6, 7, 8));
231         assertEquals(8, BooleanUtils.toInteger(null, 6, 7, 8));
232     }
233     
234     public void test_toIntegerObject_boolean_Integer_Integer() {
235         Integer six = new Integer(6);
236         Integer seven = new Integer(7);
237         assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven));
238         assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven));
239     }
240     
241     public void test_toIntegerObject_Boolean_Integer_Integer_Integer() {
242         Integer six = new Integer(6);
243         Integer seven = new Integer(7);
244         Integer eight = new Integer(8);
245         assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight));
246         assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight));
247         assertEquals(eight, BooleanUtils.toIntegerObject((Boolean) null, six, seven, eight));
248         assertEquals(null, BooleanUtils.toIntegerObject((Boolean) null, six, seven, null));
249     }
250     
251     //-----------------------------------------------------------------------
252     //-----------------------------------------------------------------------
253     public void test_toBooleanObject_String() {
254         assertEquals(null, BooleanUtils.toBooleanObject((String) null));
255         assertEquals(null, BooleanUtils.toBooleanObject(""));
256         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("false"));
257         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("no"));
258         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("off"));
259         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("FALSE"));
260         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("NO"));
261         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("OFF"));
262         assertEquals(null, BooleanUtils.toBooleanObject("oof"));
263         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("true"));
264         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("yes"));
265         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("on"));
266         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TRUE"));
267         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("ON"));
268         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("YES"));
269         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
270     }
271     
272     public void test_toBooleanObject_String_String_String_String() {
273         assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((String) null, null, "N", "U"));
274         assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((String) null, "Y", null, "U"));
275         assertSame(null, BooleanUtils.toBooleanObject((String) null, "Y", "N", null));
276         try {
277             BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
278             fail();
279         } catch (IllegalArgumentException ex) {}
280 
281         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U"));
282         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U"));
283         assertEquals(null, BooleanUtils.toBooleanObject("U", "Y", "N", "U"));
284         try {
285             BooleanUtils.toBooleanObject(null, "Y", "N", "U");
286             fail();
287         } catch (IllegalArgumentException ex) {}
288         try {
289             BooleanUtils.toBooleanObject("X", "Y", "N", "U");
290             fail();
291         } catch (IllegalArgumentException ex) {}
292     }
293 
294     //-----------------------------------------------------------------------
295     public void test_toBoolean_String() {
296         assertEquals(false, BooleanUtils.toBoolean((String) null));
297         assertEquals(false, BooleanUtils.toBoolean(""));
298         assertEquals(false, BooleanUtils.toBoolean("off"));
299         assertEquals(false, BooleanUtils.toBoolean("oof"));
300         assertEquals(false, BooleanUtils.toBoolean("yep"));
301         assertEquals(false, BooleanUtils.toBoolean("trux"));
302         assertEquals(false, BooleanUtils.toBoolean("false"));
303         assertEquals(false, BooleanUtils.toBoolean("a"));
304         assertEquals(true, BooleanUtils.toBoolean("true")); // interned handled differently
305         assertEquals(true, BooleanUtils.toBoolean(new StringBuffer("tr").append("ue").toString()));
306         assertEquals(true, BooleanUtils.toBoolean("truE"));
307         assertEquals(true, BooleanUtils.toBoolean("trUe"));
308         assertEquals(true, BooleanUtils.toBoolean("trUE"));
309         assertEquals(true, BooleanUtils.toBoolean("tRue"));
310         assertEquals(true, BooleanUtils.toBoolean("tRuE"));
311         assertEquals(true, BooleanUtils.toBoolean("tRUe"));
312         assertEquals(true, BooleanUtils.toBoolean("tRUE"));
313         assertEquals(true, BooleanUtils.toBoolean("TRUE"));
314         assertEquals(true, BooleanUtils.toBoolean("TRUe"));
315         assertEquals(true, BooleanUtils.toBoolean("TRuE"));
316         assertEquals(true, BooleanUtils.toBoolean("TRue"));
317         assertEquals(true, BooleanUtils.toBoolean("TrUE"));
318         assertEquals(true, BooleanUtils.toBoolean("TrUe"));
319         assertEquals(true, BooleanUtils.toBoolean("TruE"));
320         assertEquals(true, BooleanUtils.toBoolean("True"));
321         assertEquals(true, BooleanUtils.toBoolean("on"));
322         assertEquals(true, BooleanUtils.toBoolean("oN"));
323         assertEquals(true, BooleanUtils.toBoolean("On"));
324         assertEquals(true, BooleanUtils.toBoolean("ON"));
325         assertEquals(true, BooleanUtils.toBoolean("yes"));
326         assertEquals(true, BooleanUtils.toBoolean("yeS"));
327         assertEquals(true, BooleanUtils.toBoolean("yEs"));
328         assertEquals(true, BooleanUtils.toBoolean("yES"));
329         assertEquals(true, BooleanUtils.toBoolean("Yes"));
330         assertEquals(true, BooleanUtils.toBoolean("YeS"));
331         assertEquals(true, BooleanUtils.toBoolean("YEs"));
332         assertEquals(true, BooleanUtils.toBoolean("YES"));
333         assertEquals(false, BooleanUtils.toBoolean("yes?"));
334         assertEquals(false, BooleanUtils.toBoolean("tru"));
335     }
336 
337     public void test_toBoolean_String_String_String() {
338         assertEquals(true, BooleanUtils.toBoolean((String) null, null, "N"));
339         assertEquals(false, BooleanUtils.toBoolean((String) null, "Y", null));
340         try {
341             BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
342             fail();
343         } catch (IllegalArgumentException ex) {}
344         
345         assertEquals(true, BooleanUtils.toBoolean("Y", "Y", "N"));
346         assertEquals(false, BooleanUtils.toBoolean("N", "Y", "N"));
347         try {
348             BooleanUtils.toBoolean(null, "Y", "N");
349             fail();
350         } catch (IllegalArgumentException ex) {}
351         try {
352             BooleanUtils.toBoolean("X", "Y", "N");
353             fail();
354         } catch (IllegalArgumentException ex) {}
355     }
356 
357     //-----------------------------------------------------------------------
358     public void test_toStringTrueFalse_Boolean() {
359         assertEquals(null, BooleanUtils.toStringTrueFalse((Boolean) null));
360         assertEquals("true", BooleanUtils.toStringTrueFalse(Boolean.TRUE));
361         assertEquals("false", BooleanUtils.toStringTrueFalse(Boolean.FALSE));
362     }
363     
364     public void test_toStringOnOff_Boolean() {
365         assertEquals(null, BooleanUtils.toStringOnOff((Boolean) null));
366         assertEquals("on", BooleanUtils.toStringOnOff(Boolean.TRUE));
367         assertEquals("off", BooleanUtils.toStringOnOff(Boolean.FALSE));
368     }
369     
370     public void test_toStringYesNo_Boolean() {
371         assertEquals(null, BooleanUtils.toStringYesNo((Boolean) null));
372         assertEquals("yes", BooleanUtils.toStringYesNo(Boolean.TRUE));
373         assertEquals("no", BooleanUtils.toStringYesNo(Boolean.FALSE));
374     }
375     
376     public void test_toString_Boolean_String_String_String() {
377         assertEquals("U", BooleanUtils.toString((Boolean) null, "Y", "N", "U"));
378         assertEquals("Y", BooleanUtils.toString(Boolean.TRUE, "Y", "N", "U"));
379         assertEquals("N", BooleanUtils.toString(Boolean.FALSE, "Y", "N", "U"));
380     }
381     
382     //-----------------------------------------------------------------------
383     public void test_toStringTrueFalse_boolean() {
384         assertEquals("true", BooleanUtils.toStringTrueFalse(true));
385         assertEquals("false", BooleanUtils.toStringTrueFalse(false));
386     }
387     
388     public void test_toStringOnOff_boolean() {
389         assertEquals("on", BooleanUtils.toStringOnOff(true));
390         assertEquals("off", BooleanUtils.toStringOnOff(false));
391     }
392     
393     public void test_toStringYesNo_boolean() {
394         assertEquals("yes", BooleanUtils.toStringYesNo(true));
395         assertEquals("no", BooleanUtils.toStringYesNo(false));
396     }
397     
398     public void test_toString_boolean_String_String_String() {
399         assertEquals("Y", BooleanUtils.toString(true, "Y", "N"));
400         assertEquals("N", BooleanUtils.toString(false, "Y", "N"));
401     }
402     
403     //  testXor
404     //  -----------------------------------------------------------------------
405     public void testXor_primitive_nullInput() {
406         final boolean[] b = null;
407         try {
408             BooleanUtils.xor(b);
409             fail("Exception was not thrown for null input.");
410         } catch (IllegalArgumentException ex) {}
411     }
412 
413     public void testXor_primitive_emptyInput() {
414         try {
415             BooleanUtils.xor(new boolean[] {});
416             fail("Exception was not thrown for empty input.");
417         } catch (IllegalArgumentException ex) {}
418     }
419 
420     public void testXor_primitive_validInput_2items() {
421         assertTrue(
422             "True result for (true, true)",
423             ! BooleanUtils.xor(new boolean[] { true, true }));
424 
425         assertTrue(
426             "True result for (false, false)",
427             ! BooleanUtils.xor(new boolean[] { false, false }));
428 
429         assertTrue(
430             "False result for (true, false)",
431             BooleanUtils.xor(new boolean[] { true, false }));
432 
433         assertTrue(
434             "False result for (false, true)",
435             BooleanUtils.xor(new boolean[] { false, true }));
436     }
437 
438     public void testXor_primitive_validInput_3items() {
439         assertTrue(
440             "False result for (false, false, true)",
441             BooleanUtils.xor(new boolean[] { false, false, true }));
442 
443         assertTrue(
444             "False result for (false, true, false)",
445             BooleanUtils.xor(new boolean[] { false, true, false }));
446 
447         assertTrue(
448             "False result for (true, false, false)",
449             BooleanUtils.xor(new boolean[] { true, false, false }));
450 
451         assertTrue(
452             "True result for (true, true, true)",
453             ! BooleanUtils.xor(new boolean[] { true, true, true }));
454 
455         assertTrue(
456             "True result for (false, false)",
457             ! BooleanUtils.xor(new boolean[] { false, false, false }));
458 
459         assertTrue(
460             "True result for (true, true, false)",
461             ! BooleanUtils.xor(new boolean[] { true, true, false }));
462 
463         assertTrue(
464             "True result for (true, false, true)",
465             ! BooleanUtils.xor(new boolean[] { true, false, true }));
466 
467         assertTrue(
468             "False result for (false, true, true)",
469             ! BooleanUtils.xor(new boolean[] { false, true, true }));
470     }
471 
472     public void testXor_object_nullInput() {
473         final Boolean[] b = null;
474         try {
475             BooleanUtils.xor(b);
476             fail("Exception was not thrown for null input.");
477         } catch (IllegalArgumentException ex) {}
478     }
479 
480     public void testXor_object_emptyInput() {
481         try {
482             BooleanUtils.xor(new Boolean[] {});
483             fail("Exception was not thrown for empty input.");
484         } catch (IllegalArgumentException ex) {}
485     }
486     
487     public void testXor_object_nullElementInput() {
488         try {
489             BooleanUtils.xor(new Boolean[] {null});
490             fail("Exception was not thrown for null element input.");
491         } catch (IllegalArgumentException ex) {}
492     }
493 
494     public void testXor_object_validInput_2items() {
495         assertTrue(
496             "True result for (true, true)",
497             ! BooleanUtils
498                 .xor(new Boolean[] { Boolean.TRUE, Boolean.TRUE })
499                 .booleanValue());
500 
501         assertTrue(
502             "True result for (false, false)",
503             ! BooleanUtils
504                 .xor(new Boolean[] { Boolean.FALSE, Boolean.FALSE })
505                 .booleanValue());
506 
507         assertTrue(
508             "False result for (true, false)",
509             BooleanUtils
510                 .xor(new Boolean[] { Boolean.TRUE, Boolean.FALSE })
511                 .booleanValue());
512 
513         assertTrue(
514             "False result for (false, true)",
515             BooleanUtils
516                 .xor(new Boolean[] { Boolean.FALSE, Boolean.TRUE })
517                 .booleanValue());
518     }
519 
520     public void testXor_object_validInput_3items() {
521         assertTrue(
522             "False result for (false, false, true)",
523             BooleanUtils
524                 .xor(
525                     new Boolean[] {
526                         Boolean.FALSE,
527                         Boolean.FALSE,
528                         Boolean.TRUE })
529                 .booleanValue());
530 
531         assertTrue(
532             "False result for (false, true, false)",
533             BooleanUtils
534                 .xor(
535                     new Boolean[] {
536                         Boolean.FALSE,
537                         Boolean.TRUE,
538                         Boolean.FALSE })
539                 .booleanValue());
540 
541         assertTrue(
542             "False result for (true, false, false)",
543             BooleanUtils
544                 .xor(
545                     new Boolean[] {
546                         Boolean.TRUE,
547                         Boolean.FALSE,
548                         Boolean.FALSE })
549                 .booleanValue());
550 
551         assertTrue(
552             "True result for (true, true, true)",
553             ! BooleanUtils
554                 .xor(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE })
555                 .booleanValue());
556 
557         assertTrue(
558             "True result for (false, false)",
559             ! BooleanUtils.xor(
560                     new Boolean[] {
561                         Boolean.FALSE,
562                         Boolean.FALSE,
563                         Boolean.FALSE })
564                 .booleanValue());
565 
566         assertTrue(
567             "True result for (true, true, false)",
568             ! BooleanUtils.xor(
569                     new Boolean[] {
570                         Boolean.TRUE,
571                         Boolean.TRUE,
572                         Boolean.FALSE })
573                 .booleanValue());
574 
575         assertTrue(
576             "True result for (true, false, true)",
577             ! BooleanUtils.xor(
578                     new Boolean[] {
579                         Boolean.TRUE,
580                         Boolean.FALSE,
581                         Boolean.TRUE })
582                 .booleanValue());
583 
584         assertTrue(
585             "False result for (false, true, true)",
586             ! BooleanUtils.xor(
587                     new Boolean[] {
588                         Boolean.FALSE,
589                         Boolean.TRUE,
590                         Boolean.TRUE })
591                 .booleanValue());
592                 
593     }
594 
595 }