protected DeploymentTemplateInfo assertTemplate(String name, Class<?> clazz) throws Exception {
    DeploymentTemplateInfo info = createDeploymentInfo(name, clazz);
    assertNotNull(info);

    ManagedObject mo = mof.createManagedObject(clazz);
    assertNotNull(mo);

    log.debug(">> " + info.getName());
    assertTemplateInfo(info, mo);

    return info;
  }
/**
 * @author <a href="mailto:[email protected]t.com">Emanuel Muckenhuber</a>
 * @version $Revision$
 */
public class AbstractComponentMapperTest extends BaseTestCase {

  /** The managed object factory. */
  private ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance();

  /** The persistence factory. */
  private AbstractPersistenceFactory persistenceFactory = new AbstractPersistenceFactory();

  public AbstractComponentMapperTest(String name) {
    super(name);
  }

  protected ManagedObjectFactory getMOF() {
    return managedObjectFactory;
  }

  protected PersistenceFactory getPersistenceFactory() {
    return persistenceFactory;
  }

  protected void addComponentMapper(ComponentMapper mapper) {
    persistenceFactory.addComponentMapper(mapper);
  }

  protected PersistenceRoot restore(PersistenceRoot root) throws Exception {
    File file = File.createTempFile("test", null);
    serialize(root, file);
    return deserialize(file);
  }

  protected void serialize(PersistenceRoot moElement, File file) throws Exception {
    JAXBContext ctx = JAXBContext.newInstance(PersistenceRoot.class);
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
    marshaller.marshal(moElement, file);
    marshaller.marshal(moElement, System.out);
  }

  protected PersistenceRoot deserialize(File file) throws Exception {
    JAXBContext ctx = JAXBContext.newInstance(PersistenceRoot.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    return (PersistenceRoot) unmarshaller.unmarshal(file);
  }
}