You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by ga...@apache.org on 2009/04/29 07:01:14 UTC

svn commit: r769660 - in /geronimo/xbean/trunk/xbean-reflect/src: main/java/org/apache/xbean/recipe/CollectionRecipe.java test/java/org/apache/xbean/recipe/CollectionRecipeTest.java

Author: gawor
Date: Wed Apr 29 05:01:13 2009
New Revision: 769660

URL: http://svn.apache.org/viewvc?rev=769660&view=rev
Log:
return right collection type if type was not explicity set

Added:
    geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java   (with props)
Modified:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java?rev=769660&r1=769659&r2=769660&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java Wed Apr 29 05:01:13 2009
@@ -189,11 +189,11 @@
         // no type explicitly set
         if (RecipeHelper.hasDefaultConstructor(type)) {
             return type;
-        } else if (expectedClass.isAssignableFrom(SortedSet.class)) {
+        } else if (SortedSet.class.isAssignableFrom(expectedClass)) {
             return TreeSet.class;
-        } else if (expectedClass.isAssignableFrom(Set.class)) {
+        } else if (Set.class.isAssignableFrom(expectedClass)) {
             return LinkedHashSet.class;
-        } else if (expectedClass.isAssignableFrom(List.class)) {
+        } else if (List.class.isAssignableFrom(expectedClass)) {
             return ArrayList.class;
         } else {
             return ArrayList.class;

Added: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java?rev=769660&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java (added)
+++ geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java Wed Apr 29 05:01:13 2009
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.xbean.recipe;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CollectionRecipeTest extends TestCase {
+
+    public void testList() throws Exception {
+        assertEquals(ArrayList.class, new CollectionRecipe().create(List.class, false).getClass());
+        assertEquals(ArrayList.class, new CollectionRecipe().create(ArrayList.class, false).getClass());
+        assertEquals(LinkedList.class, new CollectionRecipe().create(LinkedList.class, false).getClass());
+    }
+    
+    public void testSet() throws Exception {
+        assertEquals(LinkedHashSet.class, new CollectionRecipe().create(Set.class, false).getClass());
+        assertEquals(TreeSet.class, new CollectionRecipe().create(SortedSet.class, false).getClass());
+        assertEquals(HashSet.class, new CollectionRecipe().create(HashSet.class, false).getClass());
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/CollectionRecipeTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain