From 7fc129450bf7211592a213144ce6570ce97741b8 Mon Sep 17 00:00:00 2001 From: Emerson Oliveira Date: Wed, 21 Aug 2013 14:49:53 -0300 Subject: [PATCH] Adição das configurações para realização de testes funcionais com Arquillian --- impl/extension/jdbc/pom.xml | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- impl/extension/jdbc/src/test/java/test/Tests.java | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 impl/extension/jdbc/src/test/java/test/Tests.java diff --git a/impl/extension/jdbc/pom.xml b/impl/extension/jdbc/pom.xml index 92ff64f..877284d 100755 --- a/impl/extension/jdbc/pom.xml +++ b/impl/extension/jdbc/pom.xml @@ -34,7 +34,8 @@ ou escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. --> - + 4.0.0 @@ -71,8 +72,95 @@ commons-dbcp commons-dbcp + + + + junit + junit + test + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + + + + + src/test/resources + true + + + + + maven-dependency-plugin + + + unpack + process-test-classes + + unpack + + + + + org.jboss.as + jboss-as-dist + ${jbossas.version} + zip + false + target + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.1,) + + unpack + + + + + + + + + + + + + + sonatype-nexus-snapshots @@ -97,4 +185,46 @@ + + + + arquillian-test + + + + br.gov.frameworkdemoiselle + demoiselle-core + + + javax.enterprise + cdi-api + + + validation-api + javax.validation + + + org.slf4j + slf4j-api + + + + org.javassist + javassist + + + + + org.eclipse.persistence + javax.persistence + provided + + + + + + + 7.1.1.Final + diff --git a/impl/extension/jdbc/src/test/java/test/Tests.java b/impl/extension/jdbc/src/test/java/test/Tests.java new file mode 100644 index 0000000..3d53c7e --- /dev/null +++ b/impl/extension/jdbc/src/test/java/test/Tests.java @@ -0,0 +1,97 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package test; + +import java.io.File; +import java.util.Locale; + +import javax.enterprise.inject.Default; +import javax.enterprise.inject.Produces; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.FileAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.resolver.api.maven.Maven; +import org.junit.Ignore; + +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; +import br.gov.frameworkdemoiselle.internal.producer.ConnectionProducer; +import br.gov.frameworkdemoiselle.internal.producer.DataSourceProducer; +import br.gov.frameworkdemoiselle.internal.proxy.BasicDataSourceProxy; +import br.gov.frameworkdemoiselle.internal.proxy.ConnectionProxy; +import br.gov.frameworkdemoiselle.transaction.JDBCTransaction; + +@Ignore +public final class Tests { + + private Tests() { + } + + public static WebArchive createDeployment(final Class baseClass) { + return createDeployment().addPackages(true, baseClass.getPackage()); + } + + public static WebArchive createDeployment() { + File[] libs = Maven.resolver().offline().loadPomFromFile("pom.xml", "arquillian-test") + .importCompileAndRuntimeDependencies().resolve().withTransitivity().asFile(); + + return ShrinkWrap + .create(WebArchive.class) + .addClass(Tests.class) + .addClass(JDBCConfig.class) + .addClass(ConnectionProducer.class) + .addClass(DataSourceProducer.class) + .addClass(BasicDataSourceProxy.class) + .addClass(ConnectionProxy.class) + .addClass(JDBCTransaction.class) + .addAsResource(createFileAsset("src/main/resources/demoiselle-jdbc-bundle.properties"), + "demoiselle-jdbc-bundle.properties") +// .addAsResource(createFileAsset("src/test/resources/logging.properties"), "logging.properties") + .addAsWebInfResource(createFileAsset("src/test/resources/META-INF/beans.xml"), "beans.xml") + .addAsLibraries(libs); + } + + public static FileAsset createFileAsset(final String pathname) { + return new FileAsset(new File(pathname)); + } + + @Default + @Produces + public Locale create() { + return Locale.getDefault(); + } +} -- libgit2 0.21.2