geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r479841 - in /geronimo/xbean/trunk/xbean-reflect/src: main/java/org/apache/xbean/recipe/ObjectRecipe.java test/java/org/apache/xbean/recipe/Car.java test/java/org/apache/xbean/recipe/StaticRecipeTest.java
Date Tue, 28 Nov 2006 01:55:05 GMT
Author: dblevins
Date: Mon Nov 27 17:55:03 2006
New Revision: 479841

URL: http://svn.apache.org/viewvc?view=rev&rev=479841
Log:
Added a bug in last couple commits that wasn't picked up by the existing test cases.  Fixed
the bug and added a new test case which seems to cover it.

Added:
    geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Car.java
    geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/StaticRecipeTest.java
Modified:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java?view=diff&rev=479841&r1=479840&r2=479841
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java
(original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java
Mon Nov 27 17:55:03 2006
@@ -114,8 +114,7 @@
     }
 
     public Object getProperty(String name) {
-        if (name == null) throw new NullPointerException("name is null");
-        Object value = properties.get(name);
+        Object value = properties.get(new Property(name));
         return value;
     }
 
@@ -247,7 +246,7 @@
     private Object[] extractConstructorArgs(Map propertyValues, Class[] constructorArgTypes)
{
         Object[] parameters = new Object[constructorArgNames.length];
         for (int i = 0; i < constructorArgNames.length; i++) {
-            String name = constructorArgNames[i];
+            Property name = new Property(constructorArgNames[i]);
             Class type = constructorArgTypes[i];
 
             Object value;

Added: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Car.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Car.java?view=auto&rev=479841
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Car.java (added)
+++ geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Car.java Mon
Nov 27 17:55:03 2006
@@ -0,0 +1,42 @@
+/**
+ * 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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Car {
+
+    private final Person driver;
+    private Person passenger;
+
+    public Car(Person driver) {
+        this.driver = driver;
+    }
+
+    public Person getDriver() {
+        return driver;
+    }
+
+    public Person getPassenger() {
+        return passenger;
+    }
+
+    public void setPassenger(Person passenger) {
+        this.passenger = passenger;
+    }
+}

Added: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/StaticRecipeTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/StaticRecipeTest.java?view=auto&rev=479841
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/StaticRecipeTest.java
(added)
+++ geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/StaticRecipeTest.java
Mon Nov 27 17:55:03 2006
@@ -0,0 +1,42 @@
+/**
+ * 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 junit.framework.TestCase;
+import org.apache.xbean.propertyeditor.PropertyEditors;
+
+import java.net.URL;
+
+public class StaticRecipeTest extends TestCase {
+
+    protected void setUp() throws Exception {
+        PropertyEditors.class.getName();
+    }
+
+    public void testAll() throws Exception {
+
+        Person driver = new Person("Joe", 21, new URL("http://www.acme.org"));
+
+        ObjectRecipe objectRecipe = new ObjectRecipe(Car.class, new String[]{"driver"}, new
Class[]{Person.class});
+
+        objectRecipe.setProperty("driver", new StaticRecipe(driver));
+
+        Car actual = (Car) objectRecipe.create(Car.class.getClassLoader());
+        assertSame("driver", driver, actual.getDriver());
+    }
+
+}



Mime
View raw message