package org.apache.commons.collections;


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


public abstract class TestPredicatedCollection extends BulkTest {

    public TestPredicatedCollection(String name) {
        super(name);
    }


    protected abstract Collection predicatedCollection();

    protected Predicate getPredicate() {
        return new Predicate() {
            public boolean evaluate(Object o) {
                return o instanceof String;
            }
        };
    }


    public void testIllegalAdd() {
        Collection c = predicatedCollection();
        Integer i = new Integer(3);
        try {
            c.add(i);
            fail("Integer should fail string predicate.");
        } catch (IllegalArgumentException e) {
            // expected
        }
        assertTrue("Collection shouldn't contain illegal element", 
         !c.contains(i));   
    }


    public void testIllegalAddAll() {
        Collection c = predicatedCollection();
        List elements = new ArrayList();
        elements.add("one");
        elements.add("two");
        elements.add(new Integer(3));
        elements.add("four");
        try {
            c.addAll(elements);
            fail("Integer should fail string predicate.");
        } catch (IllegalArgumentException e) {
            // expected
        }
        assertTrue("Collection shouldn't contain illegal element", 
         !c.contains("one"));   
        assertTrue("Collection shouldn't contain illegal element", 
         !c.contains("two"));   
        assertTrue("Collection shouldn't contain illegal element", 
         !c.contains(new Integer(3)));   
        assertTrue("Collection shouldn't contain illegal element", 
         !c.contains("four"));   
    }

}

@@ -1,8 +1,2680 @@
+/* ====================================================================%0A * The Apache Software License, Version 1.1%0A *%0A * Copyright (c) 2003 The Apache Software Foundation.  All rights%0A * reserved.%0A *%0A * Redistribution and use in source and binary forms, with or without%0A * modification, are permitted provided that the following conditions%0A * are met:%0A *%0A * 1. Redistributions of source code must retain the above copyright%0A *    notice, this list of conditions and the following disclaimer.%0A *%0A * 2. Redistributions in binary form must reproduce the above copyright%0A *    notice, this list of conditions and the following disclaimer in%0A *    the documentation and/or other materials provided with the%0A *    distribution.%0A *%0A * 3. The end-user documentation included with the redistribution,%0A *    if any, must include the following acknowledgment:%0A *       %22This product includes software developed by the%0A *        Apache Software Foundation (http://www.apache.org/).%22%0A *    Alternately, this acknowledgment may appear in the software itself,%0A *    if and wherever such third-party acknowledgments normally appear.%0A *%0A * 4. The names %22Apache%22 and %22Apache Software Foundation%22 and%0A *    %22Apache Turbine%22 must not be used to endorse or promote products%0A *    derived from this software without prior written permission. For%0A *    written permission, please contact apache@apache.org.%0A *%0A * 5. Products derived from this software may not be called %22Apache%22,%0A *    %22Apache Turbine%22, nor may %22Apache%22 appear in their name, without%0A *    prior written permission of the Apache Software Foundation.%0A *%0A * THIS SOFTWARE IS PROVIDED %60%60AS IS'' AND ANY EXPRESSED OR IMPLIED%0A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES%0A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE%0A * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR%0A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF%0A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND%0A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,%0A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT%0A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF%0A * SUCH DAMAGE.%0A * ====================================================================%0A *%0A * This software consists of voluntary contributions made by many%0A * individuals on behalf of the Apache Software Foundation.  For more%0A * information on the Apache Software Foundation, please see%0A * %3Chttp://www.apache.org/%3E.%0A */%0A
 package 
@@ -2706,17 +2706,16 @@
 tions;%0A%0A
-%0A
 import j
@@ -2787,16 +2787,27 @@
 .List;%0A%0A
+/**%0A * %0A */
 %0Apublic 

Add licence