Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
language: java
jdk: oraclejdk8
jdk: oraclejdk8
jdk: oraclejdk7

services:
- mysql

before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS hello_test;'

env:
- DATABASE=jdbc:mysql://localhost:3306/hello_test DB_USERNAME=travis DB_PASSWORD=""
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
</parent>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/hello/GreetingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import hello.GreetingTranslator ;

@Controller
public class GreetingController {
public class GreetingController{

@RequestMapping("/greeting")
@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name,
@RequestParam(value="lang", required=false, defaultValue="en") String lang,
Model model) {
model.addAttribute("hello", GreetingTranslator.sayHelloIn(lang));
model.addAttribute("name", name);
return "greeting";
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/hello/GreetingTranslator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package hello;

public class GreetingTranslator {

public static String sayHelloIn(String lang) {
String hello;
if ("en".equals(lang)) {
hello = "hello";
} else if ("es".equals(lang)) {
hello = "hola";
} else {
hello = "no hablo tu idioma";
}
return hello;
}

}
2 changes: 1 addition & 1 deletion src/main/resources/templates/greeting.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
<p th:text="${hello} + ', ' + ${name} + '!'" />
</body>
</html>
23 changes: 23 additions & 0 deletions src/test/java/hello/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package hello.Applicacion;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class Application
extends TestCase
{



/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue(true);
}
}