DbSetup populate the database

▼魔方 西西 提交于 2019-12-11 14:26:31

问题


I tried to use to DbSetup to populate the database, but it did not work

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, "", "") .build()); }

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();
}

来源:https://stackoverflow.com/questions/22990140/dbsetup-populate-the-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!