KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > collection > TestUnmodifiableCollection


1 /*
2  * Copyright 2003-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.collection;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Arrays JavaDoc;
20 import java.util.Collection JavaDoc;
21 import java.util.List JavaDoc;
22
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25
26 /**
27  * Extension of {@link AbstractTestCollection} for exercising the
28  * {@link UnmodifiableCollection} implementation.
29  *
30  * @since Commons Collections 3.0
31  * @version $Revision: 1.4 $ $Date: 2004/06/02 22:06:33 $
32  *
33  * @author Phil Steitz
34  * @author Stephen Colebourne
35  */

36 public class TestUnmodifiableCollection extends AbstractTestCollection {
37     
38     public TestUnmodifiableCollection(String JavaDoc testName) {
39         super(testName);
40     }
41     
42     public static Test suite() {
43         return new TestSuite(TestUnmodifiableCollection.class);
44     }
45     
46     public static void main(String JavaDoc args[]) {
47         String JavaDoc[] testCaseName = { TestUnmodifiableCollection.class.getName()};
48         junit.textui.TestRunner.main(testCaseName);
49     }
50
51     //-----------------------------------------------------------------------
52
public Collection JavaDoc makeCollection() {
53         return UnmodifiableCollection.decorate(new ArrayList JavaDoc());
54     }
55     
56     public Collection JavaDoc makeFullCollection() {
57         List JavaDoc list = new ArrayList JavaDoc();
58         list.addAll(Arrays.asList(getFullElements()));
59         return UnmodifiableCollection.decorate(list);
60     }
61     
62     public Collection JavaDoc makeConfirmedCollection() {
63         ArrayList JavaDoc list = new ArrayList JavaDoc();
64         return list;
65     }
66
67     public Collection JavaDoc makeConfirmedFullCollection() {
68         ArrayList JavaDoc list = new ArrayList JavaDoc();
69         list.addAll(Arrays.asList(getFullElements()));
70         return list;
71     }
72
73     public boolean isAddSupported() {
74         return false;
75     }
76     
77     public boolean isRemoveSupported() {
78         return false;
79     }
80
81     public String JavaDoc getCompatibilityVersion() {
82         return "3.1";
83     }
84
85 // public void testCreate() throws Exception {
86
// resetEmpty();
87
// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableCollection.emptyCollection.version3.1.obj");
88
// resetFull();
89
// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableCollection.fullCollection.version3.1.obj");
90
// }
91

92 }
93
Popular Tags