-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* consertando typo * criando classe de teste, erro encontrado em variavelEnvExists * removendo teste com instancia invalida * removendo sysout * adicionando construtor * adicionando visualizacao das classes de teste detectadas * mudando privacidade do construtor * corrigindo maven.yml * inicializando variaveis no construtor tambem
- Loading branch information
1 parent
9068135
commit 3ab75d3
Showing
3 changed files
with
96 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/test/java/com/casaculturaqxd/sgec/jdbc/TestDatabasePostgres.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.casaculturaqxd.sgec.jdbc; | ||
|
||
import java.sql.Connection; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
||
public class TestDatabasePostgres { | ||
DatabasePostgres database; | ||
String INVALID_ENV = ""; | ||
|
||
public TestDatabasePostgres() { | ||
database = DatabasePostgres.getInstance("URL_TEST", "USER_NAME_TEST", "PASSWORD_TEST"); | ||
INVALID_ENV = ""; | ||
} | ||
|
||
@BeforeEach | ||
public void setUp() throws IncorrectEnvironmentVariableException { | ||
database = DatabasePostgres.getInstance("URL_TEST", "USER_NAME_TEST", "PASSWORD_TEST"); | ||
} | ||
|
||
|
||
@Test | ||
public void testUniqueInstance() { | ||
Connection firstConnection = database.getConnection(); | ||
Connection secondConnection = database.getConnection(); | ||
assertEquals(firstConnection, secondConnection); | ||
} | ||
|
||
|
||
@Test | ||
public void testDesconectarOnValidConnection() { | ||
database.getConnection(); | ||
assertDoesNotThrow(() -> { | ||
database.desconectar(database.getConnection()); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testSetInvalidUrlDataBase() throws IncorrectEnvironmentVariableException { | ||
assertThrows(IncorrectEnvironmentVariableException.class, () -> { | ||
database.setUrlDataBase(INVALID_ENV); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testSetInvalidNomeUsuario() { | ||
assertThrows(IncorrectEnvironmentVariableException.class, () -> { | ||
database.setNomeUsuario(INVALID_ENV); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testSetInvalidSenha() { | ||
assertThrows(IncorrectEnvironmentVariableException.class, () -> { | ||
database.setSenha(INVALID_ENV); | ||
}); | ||
} | ||
|
||
} |