0
我有arquillian測試運行在嵌入式野蠅上。即使所有遷移腳本,Integrator類(其中設置了FlyWay)和所有flyway軟件包(來自POM文件)都包含在.war文件中的shrinkwrap文件中(該文件部署在嵌入式wildfly中),因此不會進行遷移。arquillian和flyway:不執行遷移
這是否有任何理由?這主要是不工作還是我錯過了什麼?
我想要達到的目標是由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
}
}
請包括您的Integrator類的設置代碼。 – ytg
好吧,即使未輸入此代碼,我也會添加它。如果我設置了一個斷點,它在運行arquillian測試期間不會被命中...... – badera
如果您對應用程序容器(如WildFly)進行測試,則應該在調試模式下運行它並附加遠程調試器,否則您只能爲JVM提供調試它運行你的測試(這不是一回事)。 –