Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rubén Ramírez
/
MangAffinity
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f7a0fe63
authored
Feb 20, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [Test]: Añadidas configuraciones y etiquetas para poder hacer los tests
parent
5c9aabed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
1 deletions
pom.xml
src/main/java/com/ujaen/tfg/mangaffinity/MangAffinityApplication.java
src/test/java/com/ujaen/tfg/mangaffinity/config/JpaTestConfig.java
src/test/resources/application-test.yml
pom.xml
View file @
f7a0fe63
...
@@ -53,6 +53,21 @@
...
@@ -53,6 +53,21 @@
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-validation
</artifactId>
<artifactId>
spring-boot-starter-validation
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<version>
2.2.224
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/com/ujaen/tfg/mangaffinity/MangAffinityApplication.java
View file @
f7a0fe63
...
@@ -2,8 +2,15 @@ package com.ujaen.tfg.mangaffinity;
...
@@ -2,8 +2,15 @@ package com.ujaen.tfg.mangaffinity;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
@SpringBootApplication
@SpringBootApplication
(
scanBasePackages
={
"com.ujaen.tfg.mangaffinity.servicios"
,
"com.ujaen.tfg.mangaffinity.repositorios"
,
"com.ujaen.tfg.mangaffinity.rest"
,
// "com.ujaen.tfg.mangaffinity.seguridad"
})
@EntityScan
(
basePackages
=
"com.ujaen.tfg.mangaffinity"
)
public
class
MangAffinityApplication
{
public
class
MangAffinityApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/test/java/com/ujaen/tfg/mangaffinity/config/JpaTestConfig.java
0 → 100644
View file @
f7a0fe63
package
com
.
ujaen
.
tfg
.
mangaffinity
.
config
;
import
org.springframework.boot.test.context.TestConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
;
import
javax.sql.DataSource
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
java.util.Properties
;
@TestConfiguration
public
class
JpaTestConfig
{
@Bean
public
DataSource
dataSource
()
{
return
DataSourceBuilder
.
create
()
.
driverClassName
(
"org.h2.Driver"
)
.
url
(
"jdbc:h2:mem:mangaffinity;MODE=MYSQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1"
)
.
username
(
"sa"
)
.
password
(
""
)
.
build
();
}
@Bean
public
LocalContainerEntityManagerFactoryBean
entityManagerFactory
(
DataSource
dataSource
)
{
LocalContainerEntityManagerFactoryBean
em
=
new
LocalContainerEntityManagerFactoryBean
();
em
.
setDataSource
(
dataSource
);
em
.
setPackagesToScan
(
"com.ujaen.tfg.mangaffinity.entidades"
);
HibernateJpaVendorAdapter
vendorAdapter
=
new
HibernateJpaVendorAdapter
();
em
.
setJpaVendorAdapter
(
vendorAdapter
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"hibernate.hbm2ddl.auto"
,
"create-drop"
);
properties
.
setProperty
(
"hibernate.dialect"
,
"org.hibernate.dialect.H2Dialect"
);
properties
.
setProperty
(
"hibernate.show_sql"
,
"true"
);
em
.
setJpaProperties
(
properties
);
return
em
;
}
}
src/test/resources/application-test.yml
0 → 100644
View file @
f7a0fe63
spring
:
datasource
:
url
:
jdbc:h2:mem:mangaffinity;DB_CLOSE_DELAY=-1
driver-class-name
:
org.h2.Driver
username
:
sa
password
:
jpa
:
database-platform
:
org.hibernate.dialect.H2Dialect
hibernate
:
ddl-auto
:
update
properties
:
hibernate
:
format_sql
:
true
show_sql
:
true
sql
:
init
:
mode
:
always
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment