Skip to content

Commit

Permalink
Ajuste nos testes e criação de novo modulo.
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrogiacom committed Jan 22, 2020
1 parent 8dce4ec commit c76fe65
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 47 deletions.
18 changes: 0 additions & 18 deletions .classpath

This file was deleted.

17 changes: 0 additions & 17 deletions .project

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ CREATE TABLE USUARIO
NOME VARCHAR(255) NOT NULL,
SOBRENOME VARCHAR(255) NOT NULL
);
INSERT INTO USUARIO VALUE ('1', 'SANDRO', 'GIACOMOZZI');
INSERT INTO USUARIO VALUE ('1', 'ADMIN', 'MASTER');
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ public void testeMySQL() {
}

public void verificaTabelaMigracao(MySQLContainer mysql) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
fail();
}

try (Connection conn = DriverManager.getConnection(mysql.getJdbcUrl()
, mysql.getUsername(), mysql.getPassword());
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM USUARIO")) {
rs.next();

assertEquals(rs.getString("NOME"), "SANDRO");

rs.next(); //Precisamos mover o ponteiro para o primeiro registro
assertEquals(rs.getString("NOME"), "ADMIN");
} catch (SQLException ex) {
fail();
fail(); // houve algum erro. Avise o Junit que o teste falhou
}
}

Expand Down
24 changes: 24 additions & 0 deletions Parte 09 - Testes/case 02-testcontainers/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.jornadajava</groupId>
<artifactId>case-02-testcontainers</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jornadajava.testcontainers;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Case02 {

public static void main(String[] args) {
SpringApplication.run(Case02.class, args);
}

}
1 change: 1 addition & 0 deletions Parte 09 - Testes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<modules>
<module>testcontainers</module>
<module>case 01-testcontainers</module>
<module>case 02-testcontainers</module>
</modules>

<dependencies>
Expand Down

0 comments on commit c76fe65

Please sign in to comment.