I'm currently writing integration tests for a Java EE application and use openejb/openjpa. But as I'm using CMP I have to use a javaagent to enhance my classes. In maven I can configure my surefire plugin to do this enhancement, or better set the agent as vm parameter to the test.

But as I'm currently developing I like to run my tests quite often in eclipse. But there I don't want to set the agent all the time via

java -javaagent:openejb-javaagent-4.6.0.jar _\[other params...](other-params....html)

Does someone have a useful solution for this problem?

有帮助吗?

解决方案

For testing in Eclipse purposes, I always create a variable that can be used in the VM arguments section of your Run Configuration. This way all you need to specify is something like ${agent} (or whatever you call it) rather than the full javaagent string.

其他提示

Mhh but not sure, looking at my properties, my classes should be enhanced at runtime:

@Before
public void startupContainer() throws NamingException {
    Properties p = new Properties();
    p.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
    p.put("openjpa.jdbc.DBDictionary", "hsql(SupportsSelectForUpdate=true)");
    p.put("openejb.embedded.initialcontext.close", "destroy");
    p.put("openjpa.RuntimeUnenhancedClasses", "supported");
    p.put("openjpa.DynamicEnhancementAgent", "true");
    p.put("javax.persistence.lock.timeout", "0");
    p.put("openejb.log.factory", "slf4j");

    ejbContainer = EJBContainer.createEJBContainer(p);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top