Commit c410689e9d2815d5f383001e7cbb45c9c5f8cf86
1 parent
7fc12945
Exists in
master
Adição de testes para producer
Showing
5 changed files
with
198 additions
and
0 deletions
Show diff stats
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerDefaultTestWithName.java
0 → 100644
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +package connection.producer; | ||
2 | + | ||
3 | +import static org.junit.Assert.assertEquals; | ||
4 | +import static org.junit.Assert.assertNotNull; | ||
5 | +import static org.junit.Assert.fail; | ||
6 | + | ||
7 | +import java.sql.Connection; | ||
8 | +import java.sql.SQLException; | ||
9 | + | ||
10 | +import javax.inject.Inject; | ||
11 | + | ||
12 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
13 | +import org.jboss.arquillian.junit.Arquillian; | ||
14 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
15 | +import org.junit.Test; | ||
16 | +import org.junit.runner.RunWith; | ||
17 | + | ||
18 | +import test.Tests; | ||
19 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | ||
20 | + | ||
21 | +@RunWith(Arquillian.class) | ||
22 | +public class ConnectionProducerDefaultTestWithName { | ||
23 | + | ||
24 | + @Inject | ||
25 | + private JDBCConfig config; | ||
26 | + | ||
27 | + private static String PATH = "src/test/resources/producer"; | ||
28 | + | ||
29 | + @Inject | ||
30 | + private Connection connection; | ||
31 | + | ||
32 | + @Deployment | ||
33 | + public static WebArchive createDeployment() { | ||
34 | + WebArchive deployment = Tests.createDeployment(ConnectionProducerDefaultTestWithName.class); | ||
35 | + deployment.addAsResource(Tests.createFileAsset(PATH + "/default-producer-with-name.properties"), "default-producer-with-name.properties"); | ||
36 | + return deployment; | ||
37 | + } | ||
38 | + | ||
39 | + @Test | ||
40 | + public void createDefaultConnectionWithoutName(){ | ||
41 | + try { | ||
42 | + assertNotNull(connection); | ||
43 | + //verificar se retorna realmente o nome da conexão | ||
44 | + assertEquals(connection.getCatalog(), config.getDefaultDataSourceName()); | ||
45 | + } catch (SQLException e) { | ||
46 | + e.printStackTrace(); | ||
47 | + fail(); | ||
48 | + } | ||
49 | + } | ||
50 | +} |
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerDefaultTestWithoutName.java
0 → 100644
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +package connection.producer; | ||
2 | + | ||
3 | +import static org.junit.Assert.assertNotNull; | ||
4 | +import static org.junit.Assert.fail; | ||
5 | + | ||
6 | +import java.sql.Connection; | ||
7 | +import java.sql.SQLException; | ||
8 | + | ||
9 | +import javax.inject.Inject; | ||
10 | + | ||
11 | +import org.junit.Test; | ||
12 | + | ||
13 | +import br.gov.frameworkdemoiselle.internal.configuration.JDBCConfig; | ||
14 | + | ||
15 | + | ||
16 | +public class ConnectionProducerDefaultTestWithoutName { | ||
17 | + | ||
18 | + @Inject | ||
19 | + private JDBCConfig config; | ||
20 | + | ||
21 | + private String PATH = "src/test/resources/producer"; | ||
22 | + | ||
23 | + @Inject | ||
24 | + private Connection connection; | ||
25 | + | ||
26 | + @Test | ||
27 | + public void createDefaultConnectionWithoutName(){ | ||
28 | + //utilizar o arquivo de propriedade sem o name | ||
29 | + try { | ||
30 | + assertNotNull(connection); | ||
31 | + //verificar se retorna realmente o nome da conexão | ||
32 | + assertNotNull(connection.getCatalog()); | ||
33 | + } catch (SQLException e) { | ||
34 | + // TODO Auto-generated catch block | ||
35 | + e.printStackTrace(); | ||
36 | + fail(); | ||
37 | + } | ||
38 | + } | ||
39 | +} |
@@ -0,0 +1,100 @@ | @@ -0,0 +1,100 @@ | ||
1 | +<!-- | ||
2 | + Demoiselle Framework | ||
3 | + Copyright (C) 2010 SERPRO | ||
4 | + ============================================================================ | ||
5 | + This file is part of Demoiselle Framework. | ||
6 | + | ||
7 | + Demoiselle Framework is free software; you can redistribute it and/or | ||
8 | + modify it under the terms of the GNU Lesser General Public License version 3 | ||
9 | + as published by the Free Software Foundation. | ||
10 | + | ||
11 | + This program is distributed in the hope that it will be useful, | ||
12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | + GNU General Public License for more details. | ||
15 | + | ||
16 | + You should have received a copy of the GNU Lesser General Public License version 3 | ||
17 | + along with this program; if not, see <http://www.gnu.org/licenses /> | ||
18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
19 | + Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | + ============================================================================ | ||
21 | + Este arquivo é parte do Framework Demoiselle. | ||
22 | + | ||
23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
25 | + do Software Livre (FSF). | ||
26 | + | ||
27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
30 | + para maiores detalhes. | ||
31 | + | ||
32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses /> | ||
34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
36 | +--> | ||
37 | +<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
38 | + xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | ||
39 | + | ||
40 | + <!-- | ||
41 | + --> | ||
42 | + <engine> | ||
43 | + <property name="deploymentExportPath">target/deployments</property> | ||
44 | + </engine> | ||
45 | + | ||
46 | + <container qualifier="jbossas-managed" default="true"> | ||
47 | + <protocol type="Servlet 3.0" /> | ||
48 | + | ||
49 | + <configuration> | ||
50 | + <property name="jbossHome">target/jboss-as-7.1.1.Final</property> | ||
51 | + <property name="javaHome">/usr/lib/jvm/java-6-sun/</property> | ||
52 | + <!-- | ||
53 | + <property name="serverConfig">../../../../src/test/resources/standalone.xml</property> | ||
54 | + --> | ||
55 | + </configuration> | ||
56 | + </container> | ||
57 | + <!-- | ||
58 | + <container qualifier="jbossas-managed" default="true"> | ||
59 | + <configuration> | ||
60 | + <property name="jbossHome">target/jboss-as-${jbossas.version}</property> | ||
61 | + <property name="javaVmArguments">-Djboss.socket.binding.port-offset=10000 -Xmx512m -XX:MaxPermSize=128m</property> | ||
62 | + </configuration> | ||
63 | + </container> | ||
64 | + --> | ||
65 | + <!-- | ||
66 | + <container qualifier="jbossas-managed" default="true"> | ||
67 | + <configuration> | ||
68 | + <property name="javaHome">/usr/lib/jvm/java-6-serpro/</property> | ||
69 | + <property name="jbossHome">/opt/demoiselle/server/jboss-7.1/</property> | ||
70 | + </configuration> | ||
71 | + </container> | ||
72 | + --> | ||
73 | + | ||
74 | + <!-- | ||
75 | + <container qualifier="glassfish-embedded" default="true"> | ||
76 | + <configuration> | ||
77 | + <property name="resourcesXml">src/test/resources/glassfish-resources.xml</property> | ||
78 | + </configuration> | ||
79 | + </container> | ||
80 | + --> | ||
81 | + | ||
82 | + <!-- | ||
83 | + <container qualifier="tomee" default="true"> | ||
84 | + <configuration> | ||
85 | + <property name="httpPort">-1</property> | ||
86 | + <property name="stopPort">-1</property> | ||
87 | + </configuration> | ||
88 | + </container> | ||
89 | + --> | ||
90 | + | ||
91 | + <!-- | ||
92 | + <container qualifier="jbossas-embedded" default="true"> | ||
93 | + <configuration> | ||
94 | + <property name="bindaddress">127.0.0.1</property> | ||
95 | + <property name="httpport">8081</property> | ||
96 | + </configuration> | ||
97 | + </container> | ||
98 | + --> | ||
99 | + | ||
100 | +</arquillian> | ||
0 | \ No newline at end of file | 101 | \ No newline at end of file |
impl/extension/jdbc/src/test/resources/producer/default-producer-with-name.properties
0 → 100644
@@ -0,0 +1,5 @@ | @@ -0,0 +1,5 @@ | ||
1 | +frameworkdemoiselle.persistence.driver.class=org.h2.jdbcx.JdbcDataSource | ||
2 | +frameworkdemoiselle.persistence.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 | ||
3 | +frameworkdemoiselle.persistence.username=sa | ||
4 | +frameworkdemoiselle.persistence.password=sa | ||
5 | +frameworkdemoiselle.persistence.default.datasource.name=databasename | ||
0 | \ No newline at end of file | 6 | \ No newline at end of file |
impl/extension/jdbc/src/test/resources/producer/default-producer-without-name.properties
0 → 100644
@@ -0,0 +1,4 @@ | @@ -0,0 +1,4 @@ | ||
1 | +frameworkdemoiselle.persistence.driver.class=org.h2.jdbcx.JdbcDataSource | ||
2 | +frameworkdemoiselle.persistence.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 | ||
3 | +frameworkdemoiselle.persistence.username=sa | ||
4 | +frameworkdemoiselle.persistence.password=sa | ||
0 | \ No newline at end of file | 5 | \ No newline at end of file |