01: /*
02: * Copyright 2001-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.collections;
17:
18: import junit.framework.Test;
19:
20: import org.apache.commons.collections.buffer.PredicatedBuffer;
21:
22: /**
23: * Tests for BufferUtils.
24: *
25: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
26: *
27: * @author Unknown
28: */
29: public class TestBufferUtils extends BulkTest {
30:
31: public TestBufferUtils(String name) {
32: super (name);
33: }
34:
35: public static Test suite() {
36: return BulkTest.makeSuite(TestBufferUtils.class);
37: }
38:
39: public void testNothing() {
40: }
41:
42: public void testpredicatedBuffer() {
43: Predicate predicate = new Predicate() {
44: public boolean evaluate(Object o) {
45: return o instanceof String;
46: }
47: };
48: Buffer buffer = BufferUtils.predicatedBuffer(new ArrayStack(),
49: predicate);
50: assertTrue("returned object should be a PredicatedBuffer",
51: buffer instanceof PredicatedBuffer);
52: try {
53: buffer = BufferUtils.predicatedBuffer(new ArrayStack(),
54: 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: }
|