For my griffon desktop client application I'm trying to write some tests involving OrmLite. I have configured OrmLite with a java configuration file using the configuration section of the griffon-ormlite plugin guide. What I'm trying to do is configure OrmLite to use a different (blank) database during testing. However the application is not picking up the test configuration and is instead loading the default setting.
Things to note:
Here's the configuration file:
import java.util.Map;
import griffon.util.AbstractMapResourceBundle;
import static griffon.util.CollectionUtils.map;
public class Ormlite extends AbstractMapResourceBundle {
@Override
protected void initialize(Map<String, Object> entries) {
map(entries)
// the default database setting
.e("database", map()
.e("url", "jdbc:h2:internal")
)
.e("environments", map()
.e("test", map()
// the database that should be used during testing, but is not being picked up
.e("database", map()
.e("url", "jdbc:h2:mem:internal-test")
)
)
);
}
}
Any help is extremely appreciated.
I'm afraid the problem lies in that class based ResourceBundles do not offer support for the environments
block (or any other conditional block for that matter) just like the Groovy scripts do. We recently added this kind of support to Properties files (see https://github.com/griffon/griffon/issues/196); leaving us with the need to add the same for class based bundles.
If you can, switch to Groovy script configuration as a workaround, make sure to add griffon-groovy
as a project dependency. this will add at least ~7M worth of dependencies.
I've filed https://github.com/griffon/griffon/issues/212 to keep track of this feature.