Last active
September 7, 2017 17:14
-
-
Save domingogallardo/951c4814377ce64023cc40132b3647d2 to your computer and use it in GitHub Desktop.
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
# Incluimos application.conf | |
include "application.conf" | |
# Y sobreescribimos las variables de entorno que nos interesan | |
# MySQL database | |
jpa.default = mySqlPersistenceUnit | |
db { | |
# MySQL database | |
default.driver=com.mysql.jdbc.Driver | |
default.url="jdbc:mysql://localhost:3306/mads" | |
default.username=root | |
default.password="mads" | |
# You can expose this datasource via JNDI if needed (Useful for JPA) | |
default.jndiName=DefaultDS | |
} |
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
import org.junit.*; | |
import static org.junit.Assert.*; | |
import javax.inject.*; | |
import play.test.*; | |
import static play.test.Helpers.*; | |
import play.Application; | |
import play.Mode; | |
import play.inject.guice.GuiceApplicationBuilder; | |
import play.inject.Injector; | |
import play.inject.guice.GuiceInjectorBuilder; | |
import play.Environment; | |
import java.io.File; | |
import java.lang.ClassLoader; | |
import models.Usuario; | |
import models.UsuarioRepository; | |
import services.UsuarioService; | |
import services.UsuarioServiceException; | |
public class IntegrationUsuarioServiceTest { | |
static private Injector injector; | |
@BeforeClass | |
static public void setUpInjector() { | |
GuiceApplicationBuilder guiceApplicationBuilder = | |
new GuiceApplicationBuilder().in(Environment.simple()); | |
injector = guiceApplicationBuilder.injector(); | |
} | |
@Test | |
public void crearNuevoUsuarioCorrectoTest(){ | |
UsuarioService usuarioService = injector.instanceOf(UsuarioService.class); | |
Usuario usuario = usuarioService.creaUsuario("luciaruiz", "[email protected]", "123456"); | |
assertNotNull(usuario.getId()); | |
assertEquals("luciaruiz", usuario.getLogin()); | |
assertEquals("[email protected]", usuario.getEmail()); | |
assertEquals("123456", usuario.getPassword()); | |
} | |
} |
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
# Lanzamos run o test, cambiando el fichero de configuración: | |
$ sbt '; set javaOptions += "-Dconfig.file=conf/integration.conf"; run' | |
$ sbt '; set javaOptions += "-Dconfig.file=conf/integration.conf"; test' | |
$ sbt '; set javaOptions += "-Dconfig.file=conf/integration.conf"; testOnly Integration*' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment