KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > TestBufferUtils


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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: 1.13 $ $Date: 2004/06/02 22:12:14 $
26  *
27  * @author Unknown
28  */

29 public class TestBufferUtils extends BulkTest {
30
31     public TestBufferUtils(String JavaDoc name) {
32         super(name);
33     }
34
35
36     public static Test suite() {
37         return BulkTest.makeSuite(TestBufferUtils.class);
38     }
39
40     public void testNothing() {
41     }
42
43     public void testpredicatedBuffer() {
44         Predicate predicate = new Predicate() {
45             public boolean evaluate(Object JavaDoc o) {
46                 return o instanceof String JavaDoc;
47             }
48         };
49         Buffer buffer = BufferUtils.predicatedBuffer(new ArrayStack(), predicate);
50         assertTrue("returned object should be a PredicatedBuffer",
51             buffer instanceof PredicatedBuffer);
52         try {
53             buffer = BufferUtils.predicatedBuffer(new ArrayStack(), null);
54             fail("Expecting IllegalArgumentException for null predicate.");
55         } catch (IllegalArgumentException JavaDoc ex) {
56             // expected
57
}
58         try {
59             buffer = BufferUtils.predicatedBuffer(null, predicate);
60             fail("Expecting IllegalArgumentException for null buffer.");
61         } catch (IllegalArgumentException JavaDoc ex) {
62             // expected
63
}
64     }
65
66 }
67
Popular Tags