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 gn...@apache.org on 2012/10/03 11:18:00 UTC

svn commit: r1393363 - in /geronimo/xbean/trunk/xbean-spring/src/test: java/org/apache/xbean/spring/context/Recipe2UsingXBeanTest.java java/org/apache/xbean/spring/example/RecipeService2.java resources/org/apache/xbean/spring/context/recipe2-xbean.xml

Author: gnodet
Date: Wed Oct  3 09:18:00 2012
New Revision: 1393363

URL: http://svn.apache.org/viewvc?rev=1393363&view=rev
Log:
[XBEAN-121] Added a test for constructor injection with array argument

Added:
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/Recipe2UsingXBeanTest.java
      - copied, changed from r1393346, geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanTest.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService2.java
      - copied, changed from r1393346, geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService.java
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe2-xbean.xml
      - copied, changed from r1393346, geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean.xml

Copied: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/Recipe2UsingXBeanTest.java (from r1393346, geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanTest.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/Recipe2UsingXBeanTest.java?p2=geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/Recipe2UsingXBeanTest.java&p1=geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanTest.java&r1=1393346&r2=1393363&rev=1393363&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanTest.java (original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/Recipe2UsingXBeanTest.java Wed Oct  3 09:18:00 2012
@@ -16,12 +16,34 @@
  */
 package org.apache.xbean.spring.context;
 
+import java.util.List;
+
+import org.apache.xbean.spring.example.Recipe;
+import org.apache.xbean.spring.example.RecipeService2;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
-public class RecipeUsingXBeanTest extends RecipeUsingSpringTest {
+public class Recipe2UsingXBeanTest extends SpringTestSupport {
+
+    public void testRecipes() throws Exception {
+        RecipeService2 svc = (RecipeService2) getBean("recipeService");
+
+        List list = svc.getRecipes();
+        assertNotNull(list);
+        assertEquals(2, list.size());
+        Recipe r = (Recipe) list.get(0);
+        assertEquals("Food", r.getIngredients());
+        assertEquals("Mash together", r.getInstructions());
+
+        r = (Recipe) list.get(1);
+        assertEquals("Food", r.getIngredients());
+        assertEquals("Mash together", r.getInstructions());
+
+        assertNotNull(svc.getTopRecipe());
+        assertEquals("Food", svc.getTopRecipe().getIngredients());
+    }
 
     protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/recipe-xbean.xml");
+        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/recipe2-xbean.xml");
     }
 
 }

Copied: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService2.java (from r1393346, geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService2.java?p2=geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService2.java&p1=geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService.java&r1=1393346&r2=1393363&rev=1393363&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService.java (original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RecipeService2.java Wed Oct  3 09:18:00 2012
@@ -17,15 +17,22 @@
 package org.apache.xbean.spring.example;
 
 import java.util.List;
+
 /**
- * @org.apache.xbean.XBean element="recipe-service"
+ * @org.apache.xbean.XBean element="recipe-service2"
  * @author Dan Diephouse
  */
-public class RecipeService
+public class RecipeService2
 {
-    private List recipes;
-    private Recipe topRecipe;
-    
+    private final List recipes;
+    private final Recipe topRecipe;
+
+
+    public RecipeService2(List recipes, Recipe topRecipe) {
+        this.recipes = recipes;
+        this.topRecipe = topRecipe;
+    }
+
     /**
      * @org.apache.xbean.FlatCollection childElement="recipe"
      * @return
@@ -35,11 +42,6 @@ public class RecipeService
         return recipes;
     }
 
-    public void setRecipes(List recipes)
-    {
-        this.recipes = recipes;
-    }
-
     /**
      * @org.apache.xbean.Flat
      * @return
@@ -47,8 +49,4 @@ public class RecipeService
     public Recipe getTopRecipe() {
         return topRecipe;
     }
-
-    public void setTopRecipe(Recipe topRecipe) {
-        this.topRecipe = topRecipe;
-    }
 }

Copied: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe2-xbean.xml (from r1393346, geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean.xml)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe2-xbean.xml?p2=geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe2-xbean.xml&p1=geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean.xml&r1=1393346&r2=1393363&rev=1393363&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean.xml (original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe2-xbean.xml Wed Oct  3 09:18:00 2012
@@ -17,21 +17,25 @@
     limitations under the License.
 
 -->
-<beans xmlns:x="http://xbean.apache.org/schemas/pizza" xmlns:foo="urn:foo">
+<beans xmlns:x="http://xbean.apache.org/schemas/pizza"
+       xmlns:util="http://www.springframework.org/schema/util">
 
-  <x:recipe-service id="recipeService">
-    <x:topRecipe>
-      <x:instructions>Mash together</x:instructions>
-      <x:ingredients>Food</x:ingredients>
-    </x:topRecipe>
-    <x:recipe>
-      <x:instructions>Mash together</x:instructions>
-      <x:ingredients>Food</x:ingredients>
-    </x:recipe>
-    <x:recipe>
-      <x:instructions>Mash together</x:instructions>
-      <x:ingredients>Food</x:ingredients>
-    </x:recipe>
-  </x:recipe-service>
+  <x:recipe-service2 id="recipeService" recipes="#recipes" topRecipe="#topRecipe" />
+
+  <util:list id="recipes">
+      <x:recipe>
+          <x:instructions>Mash together</x:instructions>
+          <x:ingredients>Food</x:ingredients>
+      </x:recipe>
+      <x:recipe>
+          <x:instructions>Mash together</x:instructions>
+          <x:ingredients>Food</x:ingredients>
+      </x:recipe>
+  </util:list>
+
+  <x:recipe id="topRecipe">
+    <x:instructions>Mash together</x:instructions>
+    <x:ingredients>Food</x:ingredients>
+  </x:recipe>
 
 </beans>