Martin Taal's Blog

About EMF, Teneo, CDO, Texo, Hibernate, Open-Source ERP and other topics

Archive for November 2011

EMFT Texo: model-driven test data generation

leave a comment »

When doing test driven development often/most of the time specific test data is created to test a specific situation. This makes sense as with specific test data you can test very specific functions of your code. However, creating test data is a tedious job and there is never enough time to do it all.

For Texo I wanted something different: model-driven testing, which starts with generating test data on the basis of an ecore/xsd model. With model-driven testing I only need to add a model to the test framework and the rest is taken care of: code and orm/jpa generation, test data generation, persisting, converting, comparing of results etc.

To support the Texo test framework Texo includes a test data generator: which generates EMF EObjects (with data and references) on the basis of an ecore model. The EMF EObjects can be used in other EMF tools such as EMF compare for comparing results. In Texo the EMF objects are converted to real java pojos and persisted in the database or serialized as xml/xmi.

Now, let’s see some code, how can you actually generate test data:

<pre>final ModelDataGenerator modelDataGenerator = new ModelDataGenerator();
System.err.println("Generated " + modelDataGenerator.getTotalObjectCount() + " objects ");
List<EObject> result = modelDataGenerator.getResult();</pre>

You define the eclasses you want to have in the top of the containment hierarchy (startEClasses) and a set of parameters which define the depth and breadth of the generation. The result is a list of EObjects which form the root of the containment hierarchy.

Texo test data generation tries to be smart when generating test data:

  • required efeatures are always set
  • objects which are created are re-used in references from other objects
  • for filling primitive values specific (overridable) value generators are used

This wraps it up, Texo provides test data generation and uses it for a model-driven test environment. Model-driven testing is a great addition to traditional specific testing. Model-driven testing has an attractive ‘mass’ side to it, it makes it very easy to add new models to the test environment thereby increasing the test coverage.

For more information on Texo and Texo test data generation visit this wiki page. If you have any questions or remarks please visit the EMFT newsgroup or forum.

gr. Martin

Written by martintaal

November 22, 2011 at 7:47 am

Posted in Texo

EMFT Texo: generating a DAO layer from ecore/xsd models

leave a comment »

The Dao pattern has been with us a for a while now. However, since the arrival of JPA/ORM tools there has been a lot of discussion if the DAO concept still makes sense. For me it always depends on the case, I have used the DAO pattern in some specific cases and have not needed it in other cases.

In any case, Texo offers DAO generation with some special functions which make sense to have when developing real-life applications (something I do for a living):

  • cross-referencing functionality
  • remove with cascade delete for single associations
  • findBy property
  • findBy using EStructuralFeatures (the ecore runtime model)
  • get and getAll

Okay, let’s see how to generate the DAO classes and how to use them at runtime. First ofcourse install Texo from the update site. Then after restarting, right click on a model file (ecore or xsd) and select the ‘Generate the Model + Dao code’ option. As a default the dao classes are generated in a sub package of the model code.

 * The Dao implementation for the model object '<em><strong>Forum</strong></em>'.
 * @generated
public class ForumDao extends BaseDao {

   * @generated
  public Class getEntityClass() {
    return Forum.class;

   * @generated
  public EClass getEClass() {
    return ForumModelPackage.INSTANCE.getForumEClass();

Now to get to the DAO at runtime you can use the Texo DaoRegistry class, the DAO classes are registered when the model get’s initialized in memory:

final BaseDao bookDao = DaoRegistry.getInstance().getDaoForEntity(Book.class);

Or you can use the Dao class directly:

final BookDao bookDao = DaoRegistry.getInstance().getDao(BookDao.class);

and you can for example do cross-reference checks using the DAO:

// is the book referenced, only check non-containment references

bookDao.isReferenced(book, false));

// get maximum 10 referers and include containment references

List referers = bookDao.getReferingObjects(book, 10, true);

The DAO instance gets access to an EntityManager using the Texo EntityManagerProvider, it is a light-weight concept which makes it easy to pass your EntityManager instance to the Texo runtime code.

My plan is to extend the DAO generation to automatically generate typed findBy* methods based on annotations in the model.

For more information on the DAO support by Texo visit this wiki page. And as before feel free to give feedback or ask questions on the EMFT newsgroup or forum.

gr. Martin

Written by martintaal

November 10, 2011 at 3:52 pm

Posted in Texo

Moving Texo and Teneo over to git

with one comment

More and more projects at seem to move over to git. I am using git and mercurial in several customer projects and the experience is great. I use the command line mainly and the speed, ease of branching and merging are a big plus.

So time to move Texo and Teneo over to git. Here is a summary of my experience. I will talk mainly about the changes I had to do to the buckminster build I use for Teneo and Texo. But first, credits should go to the CDO project for providing me good examples of the changes I needed to make and to the Eclipse webmasters to give very responsive help in creating the git repositories.

First to the build configuration, I had to make the following changes:

  • Set source code management to git and the url to the git repository, which for Texo is: git://
  • Then I specified in the ‘Local subdirectory for repo (optional)’ the directory within the workspace to which hudson should clone the repository. This setting can be found within the advanced section of a repository.

As a next step I had to set the correct path to the build ant script (see the ‘Build File’ field in the advanced tab of the Invoke Ant Build section), the path within the git clone local directory, in this case this was:

  • git/infra/org.eclipse.emf.texo.releng.buckminster/build.xml

So now hudson would listen to the correct location for changes and will clone the repository and run the correct build script.

Now to the build script and buckminster setup itself.

In the build xml I set a property which contains the correct path to a directory where hudson clones the git repository:

<property name="gitPath" location="${hudsonWorkSpacePath}/git" />

With Texo I let hudson do the git repository cloning. You can also tell buckminster to do it though, afaik this can be done by passing parameter named: git.clone as a jvmarg when launching buckminster.

Then I needed to change the rmap files, from using cvs to using git. Here is a snippet of one of the rmap file which reads the git repository cloned by hudson:

<provider componentTypes="osgi.bundle" readerType="git" source="true">
	<uri format="{0},tests/{1}">
		<bc:propertyRef key="gitPath"/>
		<bc:propertyRef key="buckminster.component"/>

It uses the gitPath property defined earlier to get to the correct repository location.

And this was it! So overall, the changes where quite small and Texo and Teneo build correctly from the git repositories.

For your reference here are some links to the builds projects and build pages:

For any questions/remarks please visit the EMFT Texo newsgroup or forum.

gr. Martin

Written by martintaal

November 1, 2011 at 8:42 pm

Posted in Teneo, Texo