001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.collections.primitives; 018 019import java.util.Collections; 020 021import junit.framework.Test; 022import junit.framework.TestCase; 023import junit.framework.TestSuite; 024 025import org.apache.commons.collections.primitives.adapters.IteratorCharIterator; 026 027/** 028 * @version $Revision: 480451 $ $Date: 2006-11-29 02:45:08 -0500 (Wed, 29 Nov 2006) $ 029 * @author Rodney Waldhoff 030 */ 031public class TestAbstractCharCollection extends TestCase { 032 033 // conventional 034 // ------------------------------------------------------------------------ 035 036 public TestAbstractCharCollection(String testName) { 037 super(testName); 038 } 039 040 public static Test suite() { 041 return new TestSuite(TestAbstractCharCollection.class); 042 } 043 044 // tests 045 // ------------------------------------------------------------------------ 046 047 public void testAddIsUnsupportedByDefault() { 048 CharCollection col = new CharCollectionImpl(); 049 try { 050 col.add((char)1); 051 fail("Expected UnsupportedOperationException"); 052 } catch(UnsupportedOperationException e) { 053 // expected 054 } 055 } 056 // inner classes 057 // ------------------------------------------------------------------------ 058 059 060 static class CharCollectionImpl extends AbstractCharCollection { 061 public CharCollectionImpl() { 062 } 063 064 public CharIterator iterator() { 065 return new IteratorCharIterator(Collections.EMPTY_LIST.iterator()); 066 } 067 068 public int size() { 069 return 0; 070 } 071 } 072}