我在嵌入式野生动物上进行了arquillian测试。即使所有迁移脚本,Integrator类(FlyWay设置)和所有flyway包(来自POM文件)都包含在.war文件中的shrinkwrap(部署在嵌入式wildfly上),也不会进行迁移。
这有什么理由吗?这主要是不起作用还是我错过了什么?
我想要实现的是,arquillian运行的自动化测试将使用相同的迁移脚本在内存数据库中设置与生产数据库相同的方案。
编辑:如下面提到的 ytg ,我添加了Integrator类;但是,此代码未在arquillian测试中输入;如果我在集成方法的基础上设置一个断点,它将永远不会被击中。为什么呢?
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationInfo;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.source.MetadataImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
public class FlywayIntegrator implements Integrator
{
@Override
public void integrate(final Configuration configuration,
final SessionFactoryImplementor sessionFactoryImplementor,
final SessionFactoryServiceRegistry sessionFactoryServiceRegistry)
{
System.out.println("Starting Flyway database migrations");
Flyway flywayEvending = new Flyway();
// enable this to migrate from the state currently on useqrnow.com
flywayEvending.setBaselineVersionAsString("0");
flywayEvending.setBaselineOnMigrate(true);
flywayEvending.setDataSource(...)
flywayEvending.setLocations(...);
for (MigrationInfo i : flywayEvending.info().all())
{
System.out.println("migrate task: " + i.getVersion() + " : " + i.getDescription() + " from file: " + i.getScript());
}
flywayEvending.migrate();
}
@Override
public void integrate(final MetadataImplementor metadataImplementor, final SessionFactoryImplementor sessionFactoryImplementor, final SessionFactoryServiceRegistry sessionFactoryServiceRegistry)
{
// do nothing
}
@Override
public void disintegrate(final SessionFactoryImplementor sessionFactoryImplementor, final SessionFactoryServiceRegistry sessionFactoryServiceRegistry)
{
// do nothing
}
}