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:
- specifying the configuration in exactly the same way as in src/main/resources/Ormlite.groovy in the configuration guide (link above) will cause the plugin to complain about a missing "default.url" setting. So either the example is wrong (it may be outdated, but that's unlikely) or I'm missing something regarding the environments (are the configurations being transformed before they are being read? I have not found any documentation on this).
- The application environment enum, is correctly resulting in Environment.TEST during testing and Environment.DEVELOPMENT during a run.
- versions: griffon 2.9.1, griffon-ormlite 1.1.0
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.