Search in sources :

Example 1 with Input

use of org.apache.syncope.client.cli.Input in project syncope by apache.

the class MigrateTest method conf.

@Test
public void conf() throws Exception {
    // 1. migrate
    String[] args = new String[4];
    args[0] = "migrate";
    args[1] = "--conf";
    args[2] = BASE_PATH + File.separator + "content12.xml";
    args[3] = BASE_PATH + File.separator + "MasterContent.xml";
    new MigrateCommand().execute(new Input(args));
    // 2. initialize db as persistence-jpa does
    DataSource dataSource = new DriverManagerDataSource("jdbc:h2:mem:syncopedb;DB_CLOSE_DELAY=-1", "sa", null);
    new ResourceDatabasePopulator(new ClassPathResource("/schema20.sql")).execute(dataSource);
    // 3. attempt to set initial content from the migrated MasterContent.xml
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try (InputStream in = new FileInputStream(args[3])) {
        SAXParser parser = factory.newSAXParser();
        parser.parse(in, new ContentLoaderHandler(dataSource, ROOT_ELEMENT, false));
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator) ClassPathResource(org.springframework.core.io.ClassPathResource) FileInputStream(java.io.FileInputStream) MigrateCommand(org.apache.syncope.client.cli.commands.migrate.MigrateCommand) DataSource(javax.sql.DataSource) DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Input(org.apache.syncope.client.cli.Input) DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) SAXParser(javax.xml.parsers.SAXParser) ContentLoaderHandler(org.apache.syncope.core.persistence.jpa.content.ContentLoaderHandler) SAXParserFactory(javax.xml.parsers.SAXParserFactory) Test(org.junit.jupiter.api.Test)

Aggregations

FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 DataSource (javax.sql.DataSource)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 Input (org.apache.syncope.client.cli.Input)1 MigrateCommand (org.apache.syncope.client.cli.commands.migrate.MigrateCommand)1 ContentLoaderHandler (org.apache.syncope.core.persistence.jpa.content.ContentLoaderHandler)1 Test (org.junit.jupiter.api.Test)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 DriverManagerDataSource (org.springframework.jdbc.datasource.DriverManagerDataSource)1 ResourceDatabasePopulator (org.springframework.jdbc.datasource.init.ResourceDatabasePopulator)1