Index: org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/dynobject/impl/DefaultDynClassTest.java
===================================================================
--- org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/dynobject/impl/DefaultDynClassTest.java	(revision 628)
+++ org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/dynobject/impl/DefaultDynClassTest.java	(revision 629)
@@ -26,6 +26,10 @@
  */
 package org.gvsig.tools.dynobject.impl;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.easymock.MockControl;
 
 import org.gvsig.tools.ToolsLocator;
@@ -34,6 +38,8 @@
 import org.gvsig.tools.dynobject.DynField;
 import org.gvsig.tools.dynobject.DynObject;
 import org.gvsig.tools.dynobject.DynObjectManager;
+import org.gvsig.tools.dynobject.DynObjectValueItem;
+import org.gvsig.tools.dynobject.DynStruct;
 import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
 
 /**
@@ -43,198 +49,412 @@
  */
 public class DefaultDynClassTest extends AbstractLibraryAutoInitTestCase {
 
-    private MockControl managerControl;
-    private DynObjectManager manager;
-    private DefaultDynClass dynClass;
+	private MockControl managerControl;
+	private DynObjectManager manager;
+	private DefaultDynClass dynClass;
 
-    protected void doSetUp() throws Exception {
-        managerControl = MockControl.createNiceControl(DynObjectManager.class);
-        manager = (DynObjectManager) managerControl.getMock();
-        dynClass =
-            new DefaultDynClass(manager, new DefaultDynClassName("dynclass"),
-                "description");
-    }
+	protected void doSetUp() throws Exception {
+		managerControl = MockControl.createNiceControl(DynObjectManager.class);
+		manager = (DynObjectManager) managerControl.getMock();
+		dynClass = new DefaultDynClass(manager, new DefaultDynClassName(
+				"dynclass"), "description");
+	}
 
-    /**
-     * Test method for
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#newInstance()}.
-     */
-    // public void testNewInstance() {
-    // TODO: solve
-    // MockControl dynObjControl = MockControl
-    // .createNiceControl(DynObject.class);
-    // DynObject dynObj = (DynObject) dynObjControl.getMock();
-    // dynObjControl.expectAndReturn(dynObj.getDynClass(), dynClass);
-    // dynObjControl.replay();
-    //
-    // managerControl.expectAndReturn(manager.createDynObject(dynClass),
-    // dynObj);
-    // managerControl.replay();
-    //
-    // DynObject newDynObj = dynClass.newInstance();
-    // assertTrue(dynClass.isInstance(newDynObj));
-    // }
+	/**
+	 * Test method for
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#newInstance()}.
+	 */
+	// public void testNewInstance() {
+	// TODO: solve
+	// MockControl dynObjControl = MockControl
+	// .createNiceControl(DynObject.class);
+	// DynObject dynObj = (DynObject) dynObjControl.getMock();
+	// dynObjControl.expectAndReturn(dynObj.getDynClass(), dynClass);
+	// dynObjControl.replay();
+	//
+	// managerControl.expectAndReturn(manager.createDynObject(dynClass),
+	// dynObj);
+	// managerControl.replay();
+	//
+	// DynObject newDynObj = dynClass.newInstance();
+	// assertTrue(dynClass.isInstance(newDynObj));
+	// }
 
-    /**
-     * Test method for
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#extend(org.gvsig.tools.dynobject.DynClass)}
-     * .
-     */
-    public void testExtendDynClass() {
-        final String parent = "parent";
+	/**
+	 * Test method for
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#extend(org.gvsig.tools.dynobject.DynClass)}
+	 * .
+	 */
+	public void testExtendDynClass() {
+		final String parent = "parent";
 
-        DefaultDynClassName name = new DefaultDynClassName(parent);
+		DefaultDynClassName name = new DefaultDynClassName(parent);
 
-        DefaultDynClass parentDynClass =
-            new DefaultDynClass(manager, name, "parent description");
+		DefaultDynClass parentDynClass = new DefaultDynClass(manager, name,
+				"parent description");
 
-        managerControl.expectAndReturn(manager.has(parent), true);
-        managerControl.expectAndReturn(manager.get(parent), parentDynClass);
-        managerControl.replay();
+		managerControl.expectAndReturn(manager.has(parent), true);
+		managerControl.expectAndReturn(manager.get(parent), parentDynClass);
+		managerControl.replay();
 
-        dynClass.extend(parentDynClass);
+		dynClass.extend(parentDynClass);
 
-        DynClass[] parents = dynClass.getSuperDynClasses();
-        assertEquals(parentDynClass, parents[0]);
-    }
+		DynClass[] parents = dynClass.getSuperDynClasses();
+		assertEquals(parentDynClass, parents[0]);
+	}
 
-    /**
-     * Test method for
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#extend(java.lang.String)}
-     * .
-     */
-    public void testExtendString() {
-        final String parent = "parent";
+	/**
+	 * Test method for
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#extend(java.lang.String)}
+	 * .
+	 */
+	public void testExtendString() {
+		final String parent = "parent";
 
-        DefaultDynClassName name = new DefaultDynClassName(parent);
+		DefaultDynClassName name = new DefaultDynClassName(parent);
 
-        DefaultDynClass parentDynClass =
-            new DefaultDynClass(manager, name, "parent description");
+		DefaultDynClass parentDynClass = new DefaultDynClass(manager, name,
+				"parent description");
 
-        managerControl.expectAndReturn(manager.has(parent), true);
-        managerControl.expectAndReturn(manager.get(parent), parentDynClass);
-        managerControl.replay();
+		managerControl.expectAndReturn(manager.has(parent), true);
+		managerControl.expectAndReturn(manager.get(parent), parentDynClass);
+		managerControl.replay();
 
-        dynClass.extend(parent);
+		dynClass.extend(parent);
 
-        DynClass[] parents = dynClass.getSuperDynClasses();
-        assertEquals(parentDynClass, parents[0]);
-    }
+		DynClass[] parents = dynClass.getSuperDynClasses();
+		assertEquals(parentDynClass, parents[0]);
+	}
 
-    /**
-     * Test method for
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#getDynField(java.lang.String)}
-     * ,
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#addDynField(java.lang.String)}
-     * ,
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#removeDynField(java.lang.String)}
-     * ,
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#getDeclaredDynFields()}
-     * .
-     */
-    public void testDynFields() {
-        final String field1 = "field1";
-        final String field2 = "field2";
+	/**
+	 * Test method for
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#getDynField(java.lang.String)}
+	 * ,
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#addDynField(java.lang.String)}
+	 * ,
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#removeDynField(java.lang.String)}
+	 * ,
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#getDeclaredDynFields()}
+	 * .
+	 */
+	public void testDynFields() {
+		final String field1 = "field1";
+		final String field2 = "field2";
 
-        DynField dynField1 = dynClass.addDynField(field1);
-        assertEquals(dynField1, dynClass.getDynField(field1));
+		DynField dynField1 = dynClass.addDynField(field1);
+		assertEquals(dynField1, dynClass.getDynField(field1));
 
-        DynField dynField2 = dynClass.addDynField(field2);
-        assertEquals(dynField2, dynClass.getDynField(field2));
+		DynField dynField2 = dynClass.addDynField(field2);
+		assertEquals(dynField2, dynClass.getDynField(field2));
 
-        DynField[] fields = dynClass.getDeclaredDynFields();
-        assertEquals(2, fields.length);
+		DynField[] fields = dynClass.getDeclaredDynFields();
+		assertEquals(2, fields.length);
 
-        dynClass.removeDynField(field1);
-        assertNull(dynClass.getDynField(field1));
-    }
+		dynClass.removeDynField(field1);
+		assertNull(dynClass.getDynField(field1));
+	}
 
-    /**
-     * Test method for
-     * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#equals(Object)}.
-     */
-    public void testEquals() {
-        DefaultDynClass dynClass2 =
-            new DefaultDynClass(manager, new DefaultDynClassName("dynclass2"),
-                "description2");
-        DefaultDynClass dynClassB =
-            new DefaultDynClass(manager, new DefaultDynClassName("dynclass"),
-                "description");
+	/**
+	 * Test method for
+	 * {@link org.gvsig.tools.dynobject.impl.DefaultDynClass#equals(Object)}.
+	 */
+	public void testEquals() {
+		DefaultDynClass dynClass2 = new DefaultDynClass(manager,
+				new DefaultDynClassName("dynclass2"), "description2");
+		DefaultDynClass dynClassB = new DefaultDynClass(manager,
+				new DefaultDynClassName("dynclass"), "description");
 
-        assertTrue(dynClass.equals(dynClassB));
-        assertFalse(dynClass.equals(dynClass2));
-        assertFalse(dynClass.equals(null));
-    }
+		assertTrue(dynClass.equals(dynClassB));
+		assertFalse(dynClass.equals(dynClass2));
+		assertFalse(dynClass.equals(null));
+	}
 
-    /**
-     * Validation test: DynObjects as dynfields within a dynObject.
-     * 
-     * Metadata A will have metadata B as porperty. for each dynField, a
-     * validate function will be triggered with the current
-     * 
-     * @throws Exception
-     * 
-     */
-    public void testValidate() throws Exception {
+	/**
+	 * Validation test: DynObjects as dynfields within a dynObject.
+	 * 
+	 * Metadata A will have metadata B as porperty. for each dynField, a
+	 * validate function will be triggered with the current
+	 * 
+	 * @throws Exception
+	 * 
+	 */
+	public void testValidate() throws Exception {
 
-        /**
-         * Creating and registering both dynClasses
-         */
-        DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
+		/**
+		 * Creating and registering both dynClasses
+		 */
+		DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
 
-        DynClass dynClassA =
-            new DefaultDynClass(manager, new DefaultDynClassName("metadata",
-                "DynclassA"), "descriptionA");
-        dynManager.add(dynClassA);
+		DynClass dynClassA = new DefaultDynClass(manager,
+				new DefaultDynClassName("metadata", "DynclassA"),
+				"descriptionA");
+		dynManager.add(dynClassA);
 
-        DynClass dynClassB =
-            new DefaultDynClass(manager, new DefaultDynClassName("metadata",
-                "DynclassB"), "descriptionB");
-        dynManager.add(dynClassB);
+		DynClass dynClassB = new DefaultDynClass(manager,
+				new DefaultDynClassName("metadata", "DynclassB"),
+				"descriptionB");
+		dynManager.add(dynClassB);
 
-        /**
-         * Filling dynClass B with "Name" and "Street"
-         */
+		/**
+		 * Filling dynClass B with "Name" and "Street"
+		 */
 		dynClassB.addDynFieldString("name");
-        dynClassB.addDynFieldString("street");
+		dynClassB.addDynFieldString("street");
 
-        /**
-         * Filling dynClass A with "Name" and the dynClass B named "dynObjB"
-         */
+		/**
+		 * Filling dynClass A with "Name" and the dynClass B named "dynObjB"
+		 */
 		dynClassA.addDynFieldString("name");
-        dynClassA.addDynField("dynObjB").setType(DataTypes.DYNOBJECT)
-            .setSubtype(dynClassB.getFullName());
+		dynClassA.addDynField("dynObjB").setType(DataTypes.DYNOBJECT)
+				.setSubtype(dynClassB.getFullName());
 
-        /**
-         * Creating dynObjects for current dynClasses and applying dynObject B
-         * as a property of A
-         */
-        DynObject dynObjA = new DefaultDynObject(dynClassA);
-        DynObject dynObjB = new DefaultDynObject(dynClassB);
+		/**
+		 * Creating dynObjects for current dynClasses and applying dynObject B
+		 * as a property of A
+		 */
+		DynObject dynObjA = new DefaultDynObject(dynClassA);
+		DynObject dynObjB = new DefaultDynObject(dynClassB);
 
-        // TODO: Note that even specified a subType, if we set a different
-        // dynObject, it will not check if the subType is correct.
-        dynObjA.setDynValue("dynObjB", dynObjB);
+		// TODO: Note that even specified a subType, if we set a different
+		// dynObject, it will not check if the subType is correct.
+		dynObjA.setDynValue("dynObjB", dynObjB);
 
-        /**
-         * Once the structure has been created, we will validate each field of
-         * dynObject A, which also contains B as a property.
-         */
-        DynField[] fields = dynObjA.getDynClass().getDynFields();
-        DynField field;
-        Object value;
-        for (int i = 0; i < fields.length; ++i) {
-            field = fields[i];
-            value = dynObjA.getDynValue(field.getName());
+		/**
+		 * Once the structure has been created, we will validate each field of
+		 * dynObject A, which also contains B as a property.
+		 */
+		DynField[] fields = dynObjA.getDynClass().getDynFields();
+		DynField field;
+		Object value;
+		for (int i = 0; i < fields.length; ++i) {
+			field = fields[i];
+			value = dynObjA.getDynValue(field.getName());
 
-            // Checking that it actually contains the DynObject B as a
-            // property
-            if (field.getType() == DataTypes.DYNOBJECT) {
-                assertTrue(dynClassB.equals(((DynObject) value).getDynClass()));
-            }
+			// Checking that it actually contains the DynObject B as a
+			// property
+			if (field.getType() == DataTypes.DYNOBJECT) {
+				assertTrue(dynClassB.equals(((DynObject) value).getDynClass()));
+			}
 
-            // Performing validation
-            field.validate(value);
-        }
-    }
+			// Performing validation
+			field.validate(value);
+		}
+	}
+
+	/**
+	 * 
+	 * Duplicate test: checking if, given two dynClasses A and B, dynFields from
+	 * class A can be duplicated into dynClass B by using setters in B with the
+	 * returned values of getters of A as input.
+	 * 
+	 */
+	public void testSetters() {
+		/**
+		 * Creating and registering both dynClasses
+		 */
+		DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
+
+		DynClass dynClassA = new DefaultDynClass(manager,
+				new DefaultDynClassName("metadata", "DynclassA"),
+				"descriptionA");
+
+		DynClass dynClassB = new DefaultDynClass(manager,
+				new DefaultDynClassName("metadata", "DynclassB"),
+				"descriptionB");
+
+		/**
+		 * Filling dynClass B with "Name" and "Street"
+		 */
+		dynClassB.addDynFieldString("name");
+		dynClassB.addDynFieldString("street");
+
+		fillInitialDynfields(dynClassA, dynClassB.getFullName());
+
+		// /**
+		// * Creating dynObjects for current dynClasses and applying dynObject B
+		// * as a property of A
+		// */
+		// DynObject dynObjA = new DefaultDynObject(dynClassA);
+		// DynObject dynObjB = new DefaultDynObject(dynClassB);
+
+		copyDefinitions(dynClassA, dynClassB);
+
+		checkValues(dynClassA, dynClassB);
+	}
+
+	private List createList(Object[] values) {
+		DynObjectValueItem[] valueItems = new DynObjectValueItem[values.length];
+		for (int i = 0; i < values.length; i++) {
+			valueItems[i] = new DynObjectValueItem(values[i]);
+		}
+		return Arrays.asList(valueItems);
+	}
+
+	/**
+	 * Filling dynClass A with different parameters that will be duplicated into
+	 * dynClass B afterwards.
+	 */
+	private void fillInitialDynfields(DynClass definition,
+			String dynClassBFullName) {
+
+		List items = new ArrayList();
+
+		definition.addDynFieldString("name");
+		definition.addDynField("dynObjB").setType(DataTypes.DYNOBJECT)
+				.setSubtype(dynClassBFullName);
+
+		definition.addDynFieldString("id").setReadOnly(true); // optional
+
+		definition.addDynFieldString("language").setMandatory(true);
+
+		definition.addDynFieldString("charachterset").setMandatory(true)
+				.setAvailableValues(createList(new String[] { "a", "b", "c" }));
+
+		definition
+				.addDynFieldList("hierarchyLevels")
+				.setElementsType(DataTypes.STRING)
+				.setMandatory(true)
+				.getElementsType()
+				.setAvailableValues(
+						createList(new String[] { "hier1", "hier2", "hier3" }));
+
+		definition.addDynFieldDate("date").setMandatory(true);
+
+		definition.addDynFieldList("keywords")
+				.setElementsType(DataTypes.STRING);
+
+		definition.addDynFieldList("dynObjects")
+				.setElementsType(DataTypes.DYNOBJECT).setMandatory(true)
+				.setSubtype(dynClassBFullName).getElementsType()
+				.setSubtype(dynClassBFullName);
+
+	}
+
+	private void copyDefinitions(DynClass dynClassA, DynClass dynClassB) {
+		DynField field;
+		DynField fields[] = dynClassA.getDynFields();
+		for (int i = 0; i < fields.length; i++) {
+			field = fields[i];
+			;
+			if (dynClassB.getDynField(field.getName()) == null) {
+				addDynField(dynClassB, field);
+			}
+		}
+
+		// dynFields must have the same number of items or more if some items
+		// have been previously defined.
+		assertTrue(dynClassB.getDynFields().length >= fields.length);
+	}
+
+	private void copyValues(DynObject oldDefinition, DynObject newDefinition) {
+		Object value;
+		DynField field;
+		DynField fields[] = oldDefinition.getDynClass().getDynFields();
+		for (int i = 0; i < fields.length; i++) {
+			field = fields[i];
+			value = oldDefinition.getDynValue(field.getName());
+			if (newDefinition.getDynClass().getDynField(field.getName()) == null) {
+				addDynField(newDefinition.getDynClass(), field);
+			}
+			if (value == null) {
+				continue;
+			}
+			if (value instanceof DynObject) {
+				DynObject parent = (DynObject) value;
+				DynStruct parentDefinition = parent.getDynClass();
+				DynClass childDefinition = manager.get(
+						parentDefinition.getName(),
+						parentDefinition.getNamespace());
+				DynObject child = manager.createDynObject(childDefinition);
+
+				copyValues(child, parent);
+				newDefinition.setDynValue(field.getName(), child);
+
+			} else {
+				newDefinition.setDynValue(field.getName(), value);
+			}
+		}
+	}
+
+	private void addDynField(DynStruct definition, DynField field) {
+		DynField dynField = definition.addDynField(field.getName())
+				.setType(field.getType()).setSubtype(field.getSubtype())
+				.setAvailableValues(field.getAvailableValues())
+				.setClassOfItems(field.getClassOfItems())
+				.setClassOfValue(field.getClassOfValue())
+				.setDefaultFieldValue(field.getDefaultValue())
+				.setDescription(field.getDescription())
+				.setGroup(field.getGroup()).setHidden(field.isHidden())
+				.setMandatory(field.isMandatory())
+				.setMaxValue(field.getMaxValue())
+				.setMinValue(field.getMinValue()).setOrder(field.getOder())
+				.setPersistent(field.isPersistent())
+				.setReadOnly(field.isReadOnly());
+
+		copyElementsType(dynField, field.getElementsType());
+	}
+
+	private void copyElementsType(DynField dynField, DynField elementsType) {
+		if (elementsType == null) {
+			return;
+		}
+
+		dynField.setElementsType(elementsType.getType());
+		dynField.getElementsType().setSubtype(elementsType.getSubtype())
+				.setAvailableValues(elementsType.getAvailableValues())
+				.setClassOfItems(elementsType.getClassOfItems())
+				.setClassOfValue(elementsType.getClassOfValue())
+				.setDefaultFieldValue(elementsType.getDefaultValue())
+				.setDescription(elementsType.getDescription())
+				.setGroup(elementsType.getGroup())
+				.setHidden(elementsType.isHidden())
+				.setMandatory(elementsType.isMandatory())
+				.setMaxValue(elementsType.getMaxValue())
+				.setMinValue(elementsType.getMinValue())
+				.setOrder(elementsType.getOder())
+				.setPersistent(elementsType.isPersistent())
+				.setReadOnly(elementsType.isReadOnly());
+	}
+
+	private void checkValues(DynClass dynObjA, DynClass dynObjB) {
+		DynField[] dynFieldsA = dynObjA.getDynFields();
+		DynField[] dynFieldsB = dynObjB.getDynFields();
+
+		DynField field;
+		boolean done = false;
+		for (int i = 0; i < dynFieldsA.length; ++i) {
+			field = dynFieldsA[i];
+			for (int j = 0; j < dynFieldsB.length; ++j) {
+				if (dynFieldsB[j].getName().equals(field.getName())) {
+					checkDynField(field, dynFieldsB[j]);
+					done = true;
+				}
+			}
+			// dynField must be defined in both lists.
+			assertTrue(done);
+
+		}
+	}
+
+	private void checkDynField(DynField fieldA, DynField fieldB) {
+
+		assertEquals(fieldA.getName(), fieldA.getName());
+		assertEquals(fieldA.getType(), fieldB.getType());
+		assertEquals(fieldA.getSubtype(), fieldB.getSubtype());
+		assertEquals(fieldA.getAvailableValues(), fieldB.getAvailableValues());
+		assertEquals(fieldA.getClassOfItems(), fieldB.getClassOfItems());
+		assertEquals(fieldA.getClassOfValue(), fieldB.getClassOfValue());
+		assertEquals(fieldA.getDefaultValue(), fieldB.getDefaultValue());
+		assertEquals(fieldA.getDescription(), fieldB.getDescription());
+		assertEquals(fieldA.getGroup(), fieldB.getGroup());
+		assertEquals(fieldA.isHidden(), fieldB.isHidden());
+		assertEquals(fieldA.isMandatory(), fieldB.isMandatory());
+		assertEquals(fieldA.getMaxValue(), fieldB.getMaxValue());
+		assertEquals(fieldA.getMinValue(), fieldB.getMinValue());
+		assertEquals(fieldA.getOder(), fieldB.getOder());
+		assertEquals(fieldA.isPersistent(), fieldB.isPersistent());
+		assertEquals(fieldA.isReadOnly(), fieldB.isReadOnly());
+
+	}
+
 }
Index: org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/DynObjectFactoryTest.java
===================================================================
--- org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/DynObjectFactoryTest.java	(revision 628)
+++ org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/DynObjectFactoryTest.java	(revision 629)
@@ -5,6 +5,9 @@
 import java.util.GregorianCalendar;
 import java.util.Map;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.gvsig.tools.ToolsLocator;
 import org.gvsig.tools.dynobject.DynClass;
 import org.gvsig.tools.dynobject.DynObject;
@@ -15,8 +18,6 @@
 import org.gvsig.tools.persistence.exception.PersistenceException;
 import org.gvsig.tools.persistence.exception.PersistenceTypeNotSupportedException;
 import org.gvsig.tools.persistence.exception.PersistenceValidateExceptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class DynObjectFactoryTest extends AbstractBasicTest {
 
@@ -25,7 +26,7 @@
 
 	private static int counter = 0;
 
-	protected static final String OBJ1_NAME = "MyObjectBasicTypes";
+	protected String OBJ1_NAME = "MyObjectBasicTypes";
 	protected DynObjectManager dynManager;
 
 	private static Date getDate() {
@@ -39,47 +40,62 @@
 	}
 
 	protected void register() throws Exception {
-		if(this.manager.getDynObjectDefinition(OBJ1_NAME)==null){
+		if (this.manager.getDynObjectDefinition(OBJ1_NAME) == null) {
 			InputStream resource = this
-			.getClass()
-			.getClassLoader()
-			.getResourceAsStream(
-			"org/gvsig/tools/persistence/BasicTypes2Test.xml");
-			
-			Map definitions = this.dynManager.importDynClassDefinitions(resource, null);
-			DynClass dynStruct = (DynClass)definitions.get(OBJ1_NAME);
+					.getClass()
+					.getClassLoader()
+					.getResourceAsStream(
+							"org/gvsig/tools/persistence/BasicTypes2Test.xml");
+
+			Map definitions = this.dynManager.importDynClassDefinitions(
+					resource, null);
+			DynClass dynStruct = (DynClass) definitions.get(OBJ1_NAME);
 			this.manager.addDefinition(dynStruct, null, null);
 		}
 
 	}
-	
-	private DynObject createDynObject1(){
-		DynObject obj = this.dynManager.createDynObject(OBJ1_NAME, PersistenceManager.PERSISTENCE_DYNOBJECT_NAMESPACE);
-		float value = (counter/3)*700;
 
-		obj.setDynValue("a", new Integer((int)value));
+	protected DynObject createDynObject1() {
+		return createDynObject1(OBJ1_NAME);
+	}
+
+	protected DynObject createDynObject1(String name) {
+		DynObject obj = this.dynManager.createDynObject(name,
+				PersistenceManager.PERSISTENCE_DYNOBJECT_NAMESPACE);
+		float value = (counter / 3) * 700;
+
+		obj.setDynValue("a", new Integer((int) value));
 		obj.setDynValue("b", new Long((long) value));
 		obj.setDynValue("c", new Double(value));
 		obj.setDynValue("d", new Float(value));
-		obj.setDynValue("e", new Boolean((counter%2) == 0));
+		obj.setDynValue("e", new Boolean((counter % 2) == 0));
 		obj.setDynValue("f", String.valueOf(value));
 		obj.setDynValue("g", getDate());
-		
+
 		counter++;
-		
+
 		return obj;
 	}
 
 	void check(DynObject obj1, DynObject obj2) {
-		assertEquals("int value mistmach", obj1.getDynValue("a"), obj2.getDynValue("a"));
-		assertEquals("long value mistmach", obj1.getDynValue("b"), obj2.getDynValue("b"));
-		assertEquals("double value mistmach", ((Double)obj1.getDynValue("c")).doubleValue(), ((Double)obj2.getDynValue("c")).doubleValue(),0.01);
-		assertEquals("float value mistmach", ((Float)obj1.getDynValue("d")).floatValue(), ((Float)obj2.getDynValue("d")).floatValue(), 0.01);
-		assertEquals("boolean value mistmach", obj1.getDynValue("e"), obj2.getDynValue("e"));
-		assertEquals("String value mistmach", obj1.getDynValue("f"), obj2.getDynValue("f"));
-		assertTrue("Date value mistmach", obj1.getDynValue("g").equals(obj2.getDynValue("g")));
+		assertEquals("int value mistmach", obj1.getDynValue("a"),
+				obj2.getDynValue("a"));
+		assertEquals("long value mistmach", obj1.getDynValue("b"),
+				obj2.getDynValue("b"));
+		assertEquals("double value mistmach",
+				((Double) obj1.getDynValue("c")).doubleValue(),
+				((Double) obj2.getDynValue("c")).doubleValue(), 0.01);
+		assertEquals("float value mistmach",
+				((Float) obj1.getDynValue("d")).floatValue(),
+				((Float) obj2.getDynValue("d")).floatValue(), 0.01);
+		assertEquals("boolean value mistmach", obj1.getDynValue("e"),
+				obj2.getDynValue("e"));
+		assertEquals("String value mistmach", obj1.getDynValue("f"),
+				obj2.getDynValue("f"));
+		assertTrue("Date value mistmach",
+				obj1.getDynValue("g").equals(obj2.getDynValue("g")));
 	}
-	
+
 	public void testRegisterFactory() throws Exception {
 		register();
 	}
@@ -92,19 +108,21 @@
 			assertNotNull("Can't retrieve state", state);
 			DynStruct definition = state.getDefinition();
 			assertNotNull("Can't register class", definition);
-			assertEquals("Registration don't work, name incorrect", OBJ1_NAME,
-					definition.getName());
+			assertEquals("Registration doesn't work, incorrect name", obj
+					.getDynClass().getName(), definition.getName());
 		} catch (BaseException ex) {
 			logger.warn(ex.getMessageStack(), ex);
 			throw ex;
 		}
 	}
-	
-	public void testSetState() throws PersistenceTypeNotSupportedException, PersistenceClassNotRegistered, PersistenceException, PersistenceValidateExceptions {
+
+	public void testSetState() throws PersistenceTypeNotSupportedException,
+			PersistenceClassNotRegistered, PersistenceException,
+			PersistenceValidateExceptions {
 		DynObject obj1 = createDynObject1();
 		PersistentState state = manager.getState(obj1);
 		assertNotNull("Can't retrieve state", state);
-		
+
 		DynObject obj2 = (DynObject) manager.create(state);
 		check(obj1, obj2);
 	}
@@ -118,8 +136,8 @@
 		DynObject obj1 = createDynObject1();
 		PersistentState state = this.saveAndRestoreState(obj1);
 		DynObject obj2 = (DynObject) manager.create(state);
-		
-		check(obj1, obj2);		
+
+		check(obj1, obj2);
 	}
 
 	protected String getTestId() {
@@ -127,5 +145,4 @@
 
 	}
 
-
 }
Index: org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/DynObjectFactory4Test.java
===================================================================
--- org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/DynObjectFactory4Test.java	(revision 0)
+++ org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/DynObjectFactory4Test.java	(revision 629)
@@ -0,0 +1,56 @@
+package org.gvsig.tools.persistence;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dynobject.DynClass;
+import org.gvsig.tools.dynobject.DynObject;
+
+public class DynObjectFactory4Test extends DynObjectFactoryTest {
+
+	private String OBJPARENT_NAME = "MyObjectComplexTypes";
+
+	public void doSetUp() throws Exception {
+		super.doSetUp();
+	}
+
+	protected void register() throws Exception {
+		if (this.manager.getDynObjectDefinition(OBJPARENT_NAME) == null) {
+			InputStream resource = this
+			.getClass()
+			.getClassLoader()
+			.getResourceAsStream(
+			"org/gvsig/tools/persistence/BasicTypes2Test.xml");
+			
+			Map definitions = this.dynManager.importDynClassDefinitions(
+					resource, null);
+
+			DynClass dynStruct = (DynClass) definitions.get(OBJPARENT_NAME);
+			this.manager.addDefinition(dynStruct, null, null);
+			// ToolsLocator.getDynObjectManager().add(dynStruct);
+
+			dynStruct = (DynClass) definitions.get(OBJ1_NAME);
+			ToolsLocator.getDynObjectManager().add(dynStruct);
+			this.manager.addDefinition(dynStruct, null, null);
+
+		}
+
+	}
+	
+	void check(DynObject obj1, DynObject obj2) {
+		super.check(obj1, obj2);
+
+	}
+
+	protected DynObject createDynObject1() {
+		DynObject dynObject = super.createDynObject1(OBJPARENT_NAME);
+		dynObject.setDynValue("child", super.createDynObject1(OBJ1_NAME));
+		return dynObject;
+	}
+
+	protected String getTestId() {
+		return "dopf4";
+	}
+
+}
Index: org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/resources/org/gvsig/tools/persistence/BasicTypes2Test.xml
===================================================================
--- org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/resources/org/gvsig/tools/persistence/BasicTypes2Test.xml	(revision 628)
+++ org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/resources/org/gvsig/tools/persistence/BasicTypes2Test.xml	(revision 629)
@@ -21,5 +21,14 @@
       <fields>
       </fields>
     </class>
+    <class name="MyObjectComplexTypes">
+      <description>Test the extends with namespace</description>
+      <extends>
+      	<class name="MyObjectBasicTypes"/>
+      </extends>
+      <fields>
+      	<field name="child" type="dynObject" subtype="MyObjectBasicTypes"></field>
+      </fields>
+    </class>
   </classes>
 </definitions>  
