Package liquibase.integration.cdi

Source Code of liquibase.integration.cdi.CDITestProducer

package liquibase.integration.cdi;

import liquibase.integration.cdi.annotations.LiquibaseType;
import liquibase.resource.ClassLoaderResourceAccessor;
import liquibase.resource.ResourceAccessor;
import org.hsqldb.jdbc.JDBCDataSource;
import org.jboss.weld.resources.ClassLoaderResourceLoader;

import javax.enterprise.inject.Produces;
import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.SQLException;
import java.util.Enumeration;

/**
* A Test CDI Producer used for testing CDILiquibase
*
@author Aaron Walker (http://github.com/aaronwalker)
*/
public class CDITestProducer {

    @Produces @LiquibaseType
    public CDILiquibaseConfig createConfig() {
        CDILiquibaseConfig config = new CDILiquibaseConfig();
        config.setChangeLog("liquibase/parser/core/xml/simpleChangeLog.xml");
        return config;
    }

    @Produces @LiquibaseType
    public DataSource createDataSource() throws SQLException {
        JDBCDataSource ds = new JDBCDataSource();
        ds.setDatabase("jdbc:hsqldb:mem:test");
        ds.setUser("sa");
        ds.setPassword("");
        return ds;
    }

    @Produces @LiquibaseType
    public ResourceAccessor create() {
        return new ClassLoaderResourceAccessor(getClass().getClassLoader());
    }

}
TOP

Related Classes of liquibase.integration.cdi.CDITestProducer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.