cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: Unit Testing cayenne apps
Date Tue, 23 Apr 2013 13:01:17 GMT
In older versions of Cayenne, I used this code in my testing framework
to change where to load the configuration files:

    protected Configuration newConfiguration(String cayenneDomainFileName) {
        DefaultConfiguration conf;
        if (null == cayenneDomainFileName)
        {
            conf = new CustomBasicServletConfiguration();
        }
        else
        {
            conf = new CustomBasicServletConfiguration(cayenneDomainFileName);
        }
        conf.addClassPath("com/gvea/cayenne/model/ebpp");
        return conf;
    }

However, I also use a custom file name for testing.


On Tue, Apr 23, 2013 at 8:05 AM, Juan José Gil <matero@gmail.com> wrote:
> Hi, I'm using cayenne as persistence layer.
>
> The project is builded with maven and developed with Eclipse.
>
> The DB is migrated using flyway (http://flywaydb.org/) and I'm using
> different DBs config for:
>
>  * production
>  * development
>  * testing
>
> So, for migrations, deployment, continuous integration and anything that
> relies on maven I'm using maven "filtering" capabilities to define the jdbc
> url of the database to be used.
>
> BUT when I'm working at eclipse, and try to run my tests / startup my
> webapp, I cant filter the project resources (not automatically at least)
> So currently I'm copy-pasting my cayenne conf from src/main/resources/db to
> src/test/resources/db... and I'm not happy with this solution, I feel it
> smelly, propense to failure, it's ugly, very ugly!
>
> I did try to only define the cayenne config at testing resources, but when
> I do that, it doesn't find the mapping xml.
>
> Is there a way con pass the mapping path instead of a mapping name to a
> cayenne config?
>
> Can someone point me what should be done to avoid this code/conf smell?

Mime
View raw message