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.collections;
18  
19  import junit.framework.Test;
20  
21  import org.apache.commons.collections.buffer.PredicatedBuffer;
22  
23  /**
24   * Tests for BufferUtils.
25   * 
26   * @version $Revision: 646780 $ $Date: 2008-04-10 13:48:07 +0100 (Thu, 10 Apr 2008) $
27   * 
28   * @author Unknown
29   */
30  public class TestBufferUtils extends BulkTest {
31  
32      public TestBufferUtils(String name) {
33          super(name);
34      }
35  
36  
37      public static Test suite() {
38          return BulkTest.makeSuite(TestBufferUtils.class);
39      }
40  
41      public void testNothing() {
42      }
43  
44      public void testpredicatedBuffer() {
45          Predicate predicate = new Predicate() {
46              public boolean evaluate(Object o) {
47                  return o instanceof String;
48              }
49          };
50          Buffer buffer = BufferUtils.predicatedBuffer(new ArrayStack(), predicate);
51          assertTrue("returned object should be a PredicatedBuffer",
52              buffer instanceof PredicatedBuffer);
53          try {
54              buffer = BufferUtils.predicatedBuffer(new ArrayStack(), null);
55              fail("Expecting IllegalArgumentException for null predicate.");
56          } catch (IllegalArgumentException ex) {
57              // expected
58          }
59          try {
60              buffer = BufferUtils.predicatedBuffer(null, predicate);
61              fail("Expecting IllegalArgumentException for null buffer.");
62          } catch (IllegalArgumentException ex) {
63              // expected
64          }
65      }
66  
67  }