Commit 6819fe580e7cbfcc39bf627bc4c778d40b8bfacf
1 parent
dbe2f02c
Exists in
master
Ajustes nos testes de Jdbc
Showing
8 changed files
with
91 additions
and
4 deletions
Show diff stats
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerNoConnectionDriverTest.java
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerNoConnectionUrlTest.java
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithJndiTest.java
0 → 100644
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +package connection.producer; | |
| 2 | + | |
| 3 | +import static org.junit.Assert.assertEquals; | |
| 4 | + | |
| 5 | +import java.sql.Connection; | |
| 6 | +import java.sql.SQLException; | |
| 7 | + | |
| 8 | +import javax.inject.Inject; | |
| 9 | + | |
| 10 | +import org.jboss.arquillian.container.test.api.Deployment; | |
| 11 | +import org.jboss.arquillian.junit.Arquillian; | |
| 12 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | |
| 13 | +import org.junit.Test; | |
| 14 | +import org.junit.runner.RunWith; | |
| 15 | + | |
| 16 | +import test.Tests; | |
| 17 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 18 | + | |
| 19 | +@RunWith(Arquillian.class) | |
| 20 | +public class ConnectionProducerWithJndiTest { | |
| 21 | + | |
| 22 | + private static String PATH = "src/test/resources/producer/with-jndi"; | |
| 23 | + | |
| 24 | + @Inject | |
| 25 | + @Name("conn1") | |
| 26 | + private Connection conn1; | |
| 27 | + | |
| 28 | + @Deployment | |
| 29 | + public static WebArchive createDeployment() { | |
| 30 | + WebArchive deployment = Tests.createDeployment(ConnectionProducerWithJndiTest.class); | |
| 31 | + deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); | |
| 32 | + return deployment; | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Test | |
| 36 | + public void createConnection() throws SQLException { | |
| 37 | + assertEquals(conn1.getMetaData().getURL(), "jdbc:derby:target/databases/derby"); | |
| 38 | + } | |
| 39 | + | |
| 40 | +} | |
| 0 | 41 | \ No newline at end of file | ... | ... |
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithNameTest.java
| ... | ... | @@ -3,8 +3,6 @@ package connection.producer; |
| 3 | 3 | import static org.junit.Assert.assertNotNull; |
| 4 | 4 | |
| 5 | 5 | import java.sql.Connection; |
| 6 | -import java.sql.ResultSet; | |
| 7 | -import java.sql.SQLException; | |
| 8 | 6 | |
| 9 | 7 | import javax.inject.Inject; |
| 10 | 8 | |
| ... | ... | @@ -24,7 +22,7 @@ public class ConnectionProducerWithNameTest { |
| 24 | 22 | |
| 25 | 23 | @Inject |
| 26 | 24 | @Name("conn1") |
| 27 | - private Connection connection; | |
| 25 | + private Connection conn1; | |
| 28 | 26 | |
| 29 | 27 | @Deployment |
| 30 | 28 | public static WebArchive createDeployment() { |
| ... | ... | @@ -35,7 +33,7 @@ public class ConnectionProducerWithNameTest { |
| 35 | 33 | |
| 36 | 34 | @Test |
| 37 | 35 | public void createConnection() { |
| 38 | - assertNotNull(connection); | |
| 36 | + assertNotNull(conn1); | |
| 39 | 37 | } |
| 40 | 38 | |
| 41 | 39 | } | ... | ... |
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithoutJndiTest.java
0 → 100644
| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | +package connection.producer; | |
| 2 | + | |
| 3 | +import static org.junit.Assert.assertEquals; | |
| 4 | + | |
| 5 | +import java.sql.Connection; | |
| 6 | +import java.sql.SQLException; | |
| 7 | + | |
| 8 | +import javax.enterprise.inject.Instance; | |
| 9 | +import javax.inject.Inject; | |
| 10 | + | |
| 11 | +import org.jboss.arquillian.container.test.api.Deployment; | |
| 12 | +import org.jboss.arquillian.junit.Arquillian; | |
| 13 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | |
| 14 | +import org.junit.Test; | |
| 15 | +import org.junit.runner.RunWith; | |
| 16 | + | |
| 17 | +import test.Tests; | |
| 18 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 19 | + | |
| 20 | +@RunWith(Arquillian.class) | |
| 21 | +public class ConnectionProducerWithoutJndiTest { | |
| 22 | + | |
| 23 | + private static String PATH = "src/test/resources/producer/without-jndi"; | |
| 24 | + | |
| 25 | + @Inject | |
| 26 | + @Name("conn1") | |
| 27 | + private Instance<Connection> conn1; | |
| 28 | + | |
| 29 | + @Deployment | |
| 30 | + public static WebArchive createDeployment() { | |
| 31 | + WebArchive deployment = Tests.createDeployment(ConnectionProducerWithoutJndiTest.class); | |
| 32 | + deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); | |
| 33 | + return deployment; | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Test(expected=Exception.class) | |
| 37 | + public void createConnection() throws SQLException { | |
| 38 | + conn1.get(); | |
| 39 | + } | |
| 40 | + | |
| 41 | +} | |
| 0 | 42 | \ No newline at end of file | ... | ... |
impl/extension/jdbc/src/test/java/connection/producer/ConnectionProducerWithoutNameTest.java
| ... | ... | @@ -9,6 +9,7 @@ import javax.inject.Inject; |
| 9 | 9 | import org.jboss.arquillian.container.test.api.Deployment; |
| 10 | 10 | import org.jboss.arquillian.junit.Arquillian; |
| 11 | 11 | import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 12 | +import org.junit.Ignore; | |
| 12 | 13 | import org.junit.Test; |
| 13 | 14 | import org.junit.runner.RunWith; |
| 14 | 15 | ... | ... |
impl/extension/jdbc/src/test/resources/producer/with-jndi/demoiselle.properties
0 → 100644
impl/extension/jdbc/src/test/resources/producer/without-jndi/demoiselle.properties
0 → 100644