
br.com.maxicredito.ds.test.DsStep Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ds-test Show documentation
Show all versions of ds-test Show documentation
A simples to create datasources in tests
The newest version!
package br.com.maxicredito.ds.test;
import static java.util.logging.Level.FINE;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Logger;
import javax.enterprise.inject.spi.Extension;
import javax.naming.InitialContext;
import com.zaxxer.hikari.HikariDataSource;
/**
* Cria datasource Baseados no arquivo datasources.properties.
*
* @author Clairton Rodrigo Heinzen
*/
public class DsStep extends Step implements Extension {
private static final Logger logger = Logger.getLogger(DsStep.class.getName());
@Override
public void run() {
logger.log(FINE, "Criando do DataSources");
try {
final InitialContext context = new InitialContext();
final String fileName = "datasources.properties";
final ClassLoader loader = getClass().getClassLoader();
final Enumeration resources = loader.getResources(fileName);
while (resources.hasMoreElements()) {
final URL url = resources.nextElement();
final InputStream stream = url.openStream();
final Properties file = new Properties();
file.load(stream);
final Set names = new HashSet();
for (final Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy