Skip to content

Commit

Permalink
test: ajustes para testes com H2 #64
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed May 1, 2023
1 parent a5beda7 commit 7d41888
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/test/java/br/ufrn/dct/apf/APFApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.testng.annotations.Test;

@SpringBootTest
public class APFApplicationTests extends AbstractTestNGSpringContextTests{
public class APFApplicationTests extends AbstractTestNGSpringContextTests {

@Test
public void contextLoads() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package br.ufrn.dct.apf.controller;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
Expand All @@ -11,11 +9,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.testng.annotations.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
Expand Down
56 changes: 56 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ===============================
# = DATA SOURCE
# ===============================
#spring.datasource.url=jdbc:h2:mem:apf_db;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS apf
spring.datasource.url=jdbc:h2:mem:apf_db;DB_CLOSE_DELAY=-1;MODE=Postgres;
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.data.jpa.repositories.bootstrap-mode=default

# ===============================
# = JPA / HIBERNATE
# ===============================
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.defer-datasource-initialization=true
# spring.jpa.properties.hibernate.default_schema=apf
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

# Enabling H2 Console
spring.h2.console.enabled=true

# By default enabled for Embedded Databases
spring.sql.init.mode=always
spring.sql.init.continue-on-error=true

logging.level.br.ufrn.dct.apf=DEBUG

# ===============================
# = Thymeleaf configurations
# ===============================
spring.thymeleaf.mode=HTML
spring.thymeleaf.cache=false

# ----------------------------------------
# WEB PROPERTIES
# ----------------------------------------

# Context path of the application.
server.servlet.context-path=/apf
# Display name of the application.
server.servlet.application-display-name=Analisador de Pontos de Função
# Define server port.
server.port=8080

# ==============================================================
# = Spring Security / Queries for AuthenticationManagerBuilder
# ==============================================================
spring.queries.users-query=select email, password, active from apf.user where email=?
spring.queries.roles-query=select u.email, r.role_name from apf.user u inner join apf.user_role ur on(u.user_id=ur.user_id) inner join apf.role r on(ur.role_id=r.role_id) where u.email=?

# =============================================================
# = Spring General
# =============================================================
spring.main.allow-bean-definition-overriding=true
5 changes: 0 additions & 5 deletions src/test/resources/data.sql

This file was deleted.

0 comments on commit 7d41888

Please sign in to comment.