Author: epunzalan
Date: Wed Mar 29 00:44:23 2006
New Revision: 389708

URL: http://svn.apache.org/viewcvs?rev=389708&view=rev
Log:
Reverted from plexus-utils 1.2-SNAPSHOT to 1.1 for 2.0.3 compatibility

Modified:
    maven/sandbox/maven-plugin-testing-harness/pom.xml
    
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java

Modified: maven/sandbox/maven-plugin-testing-harness/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/pom.xml?rev=389708&r1=389707&r2=389708&view=diff
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/pom.xml (original)
+++ maven/sandbox/maven-plugin-testing-harness/pom.xml Wed Mar 29 00:44:23 2006
@@ -28,7 +28,7 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.2-SNAPSHOT</version>
+      <version>1.1</version>
     </dependency>
   </dependencies>
   <scm>

Modified: 
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java
URL: 
http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java?rev=389708&r1=389707&r2=389708&view=diff
==============================================================================
--- 
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java
 (original)
+++ 
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java
 Wed Mar 29 00:44:23 2006
@@ -16,11 +16,6 @@
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.Reader;
-import java.util.Map;
-
 import org.apache.maven.monitor.logging.DefaultLog;
 import org.apache.maven.plugin.Mojo;
 import org.apache.maven.plugin.logging.Log;
@@ -33,6 +28,14 @@
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Field;
+import java.lang.reflect.AccessibleObject;
+
 // todo: add a way to use the plugin POM for the lookup so that the user 
doesn't have to provide the a:g:v:goal
 // as the role hint for the mojo lookup.
 // todo: standarize the execution of the mojo and looking at the results, but 
could simply have a template method
@@ -266,7 +269,7 @@
     protected Object getVariableValueFromObject( Object object, String 
variable )
         throws IllegalAccessException
     {
-        return ReflectionUtils.getValueIncludingSuperclasses( variable, object 
);
+        return ReflectionUtils.getFieldByNameIncludingSuperclasses( variable, 
object.getClass() );
 
     }
 
@@ -279,10 +282,31 @@
      * @param object
      * @return map of variable names and values
      */
-    protected Map getVariablesAndValuesFromObject( Object object )
+    protected Map getVariablesAndValuesFromObject( Class clazz, Object object )
         throws IllegalAccessException
     {
-        return ReflectionUtils.getVariablesAndValuesIncludingSuperclasses( 
object );
+        Map map = new HashMap();
+
+        Field[] fields = clazz.getDeclaredFields();
+
+        AccessibleObject.setAccessible( fields, true);
+
+        for (int i = 0; i < fields.length; ++i)
+        {
+            Field field = fields[i];
+
+            map.put( field.getName(), field.get( object ) );
+
+        }
+
+        Class superclass = clazz.getSuperclass();
+
+        if ( !Object.class.equals(  superclass ) )
+        {
+            map.putAll( getVariablesAndValuesFromObject( superclass, object ) 
);
+        }
+
+        return map;
     }
 
 
@@ -296,7 +320,11 @@
     protected void setVariableValueToObject( Object object, String variable, 
Object value )
         throws IllegalAccessException
     {
-        ReflectionUtils.setVariableValueInObject( object, variable, value );
+        Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( 
variable, object.getClass() );
+
+        field.setAccessible( true );
+
+        field.set(object, value );
     }
     /**
      * sometimes the parent element might contain the correct value so 
generalize that access


Reply via email to