我尝试使用DbSetup来填充数据库,但它不起作用
class CommonOperations {
public static final Operation DELETE_ALL =
deleteAllFrom("ACH_GROUP");
public static final Operation INSERT_REFERENCE_DATA =
sequenceOf(
insertInto("ACH_GROUP")
.columns(" ID"," CLOSED"," NAME"," OPENED"," COMPETENCE_ID" ," LASTMODIFIEDDATE"," uuid") .values(1,""," JAVA","",1,"","&#34 ;) 。建立()); }
public class CompetenceDaoImplementationTest {
private static String username = "sa";
private static String password = "12345";
private static String URL = "jdbc:sqlserver://localhost:1433;databaseName=DB_Achi";
// the tracker is static because JUnit uses a separate Test instance for every test method.
private static DbSetupTracker dbSetupTracker = new DbSetupTracker();
@Before
public void prepare() throws Exception {
Operation operation =
sequenceOf(
CommonOperations.DELETE_ALL,
CommonOperations.INSERT_REFERENCE_DATA);
// without DataSource
DbSetup dbSetup = new DbSetup(new DriverManagerDestination(URL, username, password), operation);
// use the tracker to launch the DbSetup.
dbSetupTracker.launchIfNecessary(dbSetup);
}
@Test
public void testShowGroups() {
dbSetupTracker.skipNextLaunch();
}