如何在集成测试中设置保存点(hsqldb在内存中)?

时间:2015-06-30 09:51:19

标签: java sql jpa hsqldb savepoints

我有hsqldb(在内存中)的集成测试,现在我需要在我的测试中设置保存点,在BaseTest类中,如何在测试中设置保存点(hsqldb(内存中))?

BaseTest:

@ContextConfiguration(classes = {TestConfig.class})
public class BaseTest {

    @Before
    public void savePoint() {
        //set savepoint - How can do it this?

    }

    @After
    public void rollBackToSavePoint() {
        //roll back to savepoint - How can do it this?

    }
}

我的测试:

@RunWith(SpringJUnit4ClassRunner.class)
public class MyTest extends BaseTest {

    @Test
    public void test1() {
     ...
    }
}

TestConfig:

import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;

@Configuration
@EnableJpaRepositories("database.dao")
@ComponentScan(basePackageClasses = { MyServiceImpl.class})
@EntityScan({"database.model"})
@Import({DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class TestConfig {

...

}

1 个答案:

答案 0 :(得分:2)

它帮助了我:

'Ж', 'ק', 'ओ', 'を'