Author: djencks Date: Thu Nov 25 09:28:29 2004 New Revision: 106582 URL: http://svn.apache.org/viewcvs?view=rev&rev=106582 Log: simplify and test collection property editors Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/MapEditor.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayListEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/CollectionEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/HashSetEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/LinkedListEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ListEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/SetEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/StackEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/TreeSetEditorTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/VectorEditorTest.java Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java
Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditor.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditor.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,58 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.common.propertyeditor; + +import java.beans.PropertyEditorSupport; +import java.util.Collection; +import java.util.StringTokenizer; + +/** + * An abstract collection editor. Subclasses should provide the correct type of collection from + * the createCollection method and should override setValue to check the type of the value. + * + * @version $Rev: $ $Date: $ + */ +public abstract class AbstractCollectionEditor extends PropertyEditorSupport { + + /** + * Concrete subclasses should implement this method to create the correct type of collection. + * + * @return an empty instance of the type of collection the subclass edits. + */ + protected abstract Collection createCollection(); + + public void setAsText(String text) { + if (text == null) { + setValue(null); + } else { + if (text.startsWith("[")) { + text = text.substring(1); + } + if (text.endsWith("]")) { + text = text.substring(0, text.length() - 1); + } + Collection collection = createCollection(); + StringTokenizer stok = new StringTokenizer(text, ","); + + while (stok.hasMoreTokens()) { + collection.add(stok.nextToken().trim()); + } + + setValue(collection); + } + } +} Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayListEditor.java Thu Nov 25 09:28:29 2004 @@ -19,17 +19,17 @@ import java.util.ArrayList; import java.util.List; +import java.util.Collection; /** * A property editor for [EMAIL PROTECTED] ArrayList}. * * @version $Rev$ $Date$ */ -public class ArrayListEditor - extends ListEditor -{ - protected List createList() - { +public class ArrayListEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new ArrayList(); } + } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/CollectionEditor.java Thu Nov 25 09:28:29 2004 @@ -27,25 +27,12 @@ * * @version $Rev$ $Date$ */ -public class CollectionEditor - extends PropertyEditorSupport -{ - protected Collection createCollection() - { +public class CollectionEditor extends AbstractCollectionEditor { + protected Collection createCollection() { return new LinkedList(); } - - public void setAsText(final String text) - { - Collection bag = createCollection(); - StringTokenizer stok = new StringTokenizer(text, ","); - - // need to handle possible "[" and "]" - - while (stok.hasMoreTokens()) { - bag.add(stok.nextToken().trim()); - } - - setValue(bag); + + public void setValue(Object value) { + super.setValue((Collection)value); } } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/HashSetEditor.java Thu Nov 25 09:28:29 2004 @@ -19,17 +19,17 @@ import java.util.HashSet; import java.util.Set; +import java.util.Collection; /** * A property editor for [EMAIL PROTECTED] HashSet}. * * @version $Rev$ $Date$ */ -public class HashSetEditor - extends SetEditor -{ - protected Set createSet() - { +public class HashSetEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new HashSet(); } + } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/LinkedListEditor.java Thu Nov 25 09:28:29 2004 @@ -19,17 +19,17 @@ import java.util.LinkedList; import java.util.List; +import java.util.Collection; /** * A property editor for [EMAIL PROTECTED] LinkedList}. * * @version $Rev$ $Date$ */ -public class LinkedListEditor - extends ListEditor -{ - protected List createList() - { +public class LinkedListEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new LinkedList(); } + } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ListEditor.java Thu Nov 25 09:28:29 2004 @@ -26,16 +26,11 @@ * * @version $Rev$ $Date$ */ -public class ListEditor - extends CollectionEditor -{ +public class ListEditor extends AbstractCollectionEditor { + protected Collection createCollection() { - return createList(); - } - - protected List createList() - { return new LinkedList(); } + } Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/MapEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/MapEditor.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/MapEditor.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,60 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Properties; +import java.util.Map; + +/** + * A property editor for [EMAIL PROTECTED] java.util.Properties}. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class MapEditor + extends TextPropertyEditorSupport +{ + /** + * + * @throws PropertyEditorException An IOException occured. + */ + public void setAsText(String text) { + try { + ByteArrayInputStream is = new ByteArrayInputStream(text == null? new byte[0]: text.getBytes()); + Properties p = new Properties(); + p.load(is); + + setValue((Map)p); + } catch (IOException e) { + throw new PropertyEditorException(e); + } + } + + public String getAsText() { + Map map = (Map) getValue(); + if (!(map instanceof Properties)) { + Properties p = new Properties(); + if (map != null) { + p.putAll(map); + } + map = p; + } + return map.toString(); + } +} Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/SetEditor.java Thu Nov 25 09:28:29 2004 @@ -27,26 +27,10 @@ * * @version $Rev$ $Date$ */ -public class SetEditor - extends PropertyEditorSupport -{ - protected Collection createCollection() - { - return createSet(); - } - - protected Set createSet() - { +public class SetEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new HashSet(); } - protected void setValue(Set list) - { - super.setValue(list); - } - - public void setValue(Collection bag) - { - setValue((Set)bag); - } } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/StackEditor.java Thu Nov 25 09:28:29 2004 @@ -19,17 +19,17 @@ import java.util.List; import java.util.Stack; +import java.util.Collection; /** * A property editor for [EMAIL PROTECTED] Stack} * * @version $Rev$ $Date$ */ -public class StackEditor - extends ListEditor -{ - protected List createList() - { +public class StackEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new Stack(); } + } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/TreeSetEditor.java Thu Nov 25 09:28:29 2004 @@ -19,17 +19,18 @@ import java.util.Set; import java.util.TreeSet; +import java.util.Collection; /** * A property editor for [EMAIL PROTECTED] TreeSet}. * * @version $Rev$ $Date$ */ -public class TreeSetEditor - extends SetEditor -{ - protected Set createSet() +public class TreeSetEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new TreeSet(); } + } Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java&r1=106581&p2=geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java (original) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/propertyeditor/VectorEditor.java Thu Nov 25 09:28:29 2004 @@ -19,17 +19,17 @@ import java.util.List; import java.util.Vector; +import java.util.Collection; /** * A property editor for [EMAIL PROTECTED] Vector}. * * @version $Rev$ $Date$ */ -public class VectorEditor - extends ListEditor -{ - protected List createList() - { +public class VectorEditor extends AbstractCollectionEditor { + + protected Collection createCollection() { return new Vector(); } + } Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/AbstractCollectionEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,90 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.common.propertyeditor; + +import java.beans.PropertyEditor; +import java.util.Collection; +import java.util.Iterator; + +import junit.framework.TestCase; + +/** + * Abstract superclass for collection editor tests. Implement the two abstract methods and initialize + * editor and ordered in the setUp() method. + * + * @version $Rev: $ $Date: $ + */ +public abstract class AbstractCollectionEditorTest extends TestCase { + PropertyEditor editor; + boolean ordered; + + public void testGetValue_1Item() { + String input = "item"; + + editor.setAsText(input); + Object output = editor.getValue(); + + assertNotNull(output); + checkType(output); + + Collection collection = (Collection) output; + assertEquals(1, collection.size()); + assertEquals(input, collection.iterator().next()); + } + + public void testGetValue_2Items() { + String input = "item1, item2"; + + editor.setAsText(input); + Object output = editor.getValue(); + + assertNotNull(output); + checkType(output); + + Collection collection = (Collection) output; + checkContents(collection); + } + + private void checkContents(Collection collection) { + assertEquals(2, collection.size()); + Iterator iterator = collection.iterator(); + if (ordered) { + assertEquals("item1", iterator.next()); + assertEquals("item2", iterator.next()); + } else { + Object item1 = iterator.next(); + Object item2 = iterator.next(); + assertTrue((item1.equals("item1") && item2.equals("item2")) || (item1.equals("item2") && item2.equals("item1"))); + } + + } + + public void testRoundTrip() { + Collection collection = createCollection(); + collection.add("item1"); + collection.add("item2"); + editor.setValue(collection); + String text = editor.getAsText(); + editor.setAsText(text); + Collection result = (Collection) editor.getValue(); + checkContents(result); + } + + protected abstract void checkType(Object output); + + protected abstract Collection createCollection(); +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayListEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayListEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayListEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Unit test for [EMAIL PROTECTED] ArrayListEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class ArrayListEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(ArrayList.class); + ordered = true; + } + + public void testEditorClass() throws Exception { + assertEquals(ArrayListEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof ArrayList); + } + + protected Collection createCollection() { + return new ArrayList(); + } +} Modified: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java&r1=106581&p2=geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java (original) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java Thu Nov 25 09:28:29 2004 @@ -17,9 +17,8 @@ package org.apache.geronimo.common.propertyeditor; -import java.net.URL; - import java.beans.PropertyEditor; +import java.net.URL; import junit.framework.TestCase; Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/CollectionEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/CollectionEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/CollectionEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Unit test for [EMAIL PROTECTED] CollectionEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class CollectionEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(Collection.class); + ordered = false; + } + + public void testEditorClass() throws Exception { + assertEquals(CollectionEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue(output instanceof Collection); + } + + protected Collection createCollection() { + return new ArrayList(); + } +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/HashSetEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/HashSetEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/HashSetEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.HashSet; + +/** + * Unit test for [EMAIL PROTECTED] HashSetEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class HashSetEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(HashSet.class); + ordered = false; + } + + public void testEditorClass() throws Exception { + assertEquals(HashSetEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof HashSet); + } + + protected Collection createCollection() { + return new HashSet(); + } +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/LinkedListEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/LinkedListEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/LinkedListEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.LinkedList; + +/** + * Unit test for [EMAIL PROTECTED] LinkedListEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class LinkedListEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(LinkedList.class); + ordered = true; + } + + public void testEditorClass() throws Exception { + assertEquals(LinkedListEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof LinkedList); + } + + protected Collection createCollection() { + return new LinkedList(); + } +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ListEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ListEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ListEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,47 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.List; +import java.util.LinkedList; + +/** + * Unit test for [EMAIL PROTECTED] ListEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class ListEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(List.class); + ordered = true; + } + + public void testEditorClass() throws Exception { + assertEquals(ListEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof List); + } + + protected Collection createCollection() { + return new LinkedList(); + } +} Modified: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java?view=diff&rev=106582&p1=geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java&r1=106581&p2=geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java&r2=106582 ============================================================================== --- geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java (original) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/PropertyEditorsTest.java Thu Nov 25 09:28:29 2004 @@ -17,10 +17,8 @@ package org.apache.geronimo.common.propertyeditor; -import java.util.List; - -import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; +import java.util.List; import junit.framework.TestCase; Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/SetEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/SetEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/SetEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,47 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +/** + * Unit test for [EMAIL PROTECTED] HashSetEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class SetEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(Set.class); + ordered = false; + } + + public void testEditorClass() throws Exception { + assertEquals(SetEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof Set); + } + + protected Collection createCollection() { + return new HashSet(); + } +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/StackEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/StackEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/StackEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.Stack; + +/** + * Unit test for [EMAIL PROTECTED] StackEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class StackEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(Stack.class); + ordered = true; + } + + public void testEditorClass() throws Exception { + assertEquals(StackEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof Stack); + } + + protected Collection createCollection() { + return new Stack(); + } +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/TreeSetEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/TreeSetEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/TreeSetEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.TreeSet; + +/** + * Unit test for [EMAIL PROTECTED] TreeSetEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class TreeSetEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(TreeSet.class); + ordered = true; + } + + public void testEditorClass() throws Exception { + assertEquals(TreeSetEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof TreeSet); + } + + protected Collection createCollection() { + return new TreeSet(); + } +} Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/VectorEditorTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/VectorEditorTest.java?view=auto&rev=106582 ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/propertyeditor/VectorEditorTest.java Thu Nov 25 09:28:29 2004 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.common.propertyeditor; + +import java.util.Collection; +import java.util.Vector; + +/** + * Unit test for [EMAIL PROTECTED] VectorEditor} class. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class VectorEditorTest extends AbstractCollectionEditorTest { + + protected void setUp() { + editor = PropertyEditors.findEditor(Vector.class); + ordered = true; + } + + public void testEditorClass() throws Exception { + assertEquals(VectorEditor.class, editor.getClass()); + } + + protected void checkType(Object output) { + assertTrue("editor returned a: " + output.getClass(), output instanceof Vector); + } + + protected Collection createCollection() { + return new Vector(); + } +}