Merge pull request #5881 from eugenp/BAEL-10844-v2

fix test names, missing templates
This commit is contained in:
Loredana Crusoveanu 2018-12-09 21:13:40 +02:00 committed by GitHub
commit a42b156ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 277 additions and 33 deletions

View File

@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = AutoconfigurationApplication.class)
@EnableJpaRepositories(basePackages = { "com.baeldung.autoconfiguration.example" })
public class AutoconfigurationIntegrationTest {
public class AutoconfigurationLiveTest {
@Autowired
private MyUserRepository userRepository;

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung.autoconfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -11,7 +11,7 @@ import com.baeldung.autoconfiguration.example.AutoconfigurationApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = AutoconfigurationApplication.class)
@EnableJpaRepositories(basePackages = { "com.baeldung.autoconfiguration.example" })
public class SpringContextIntegrationTest {
public class SpringContextLiveTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {

View File

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId>
<groupId>com.baeldung</groupId>
<artifactId>spring-boot-bootstrap</artifactId>
<packaging>jar</packaging>
<name>spring-boot-bootstrap</name>

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -9,9 +9,9 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@ServletComponentScan
@SpringBootApplication
@ComponentScan("org.baeldung")
@EnableJpaRepositories("org.baeldung.persistence.repo")
@EntityScan("org.baeldung.persistence.model")
@ComponentScan("com.baeldung")
@EnableJpaRepositories("com.baeldung.persistence.repo")
@EntityScan("com.baeldung.persistence.model")
public class Application {
public static void main(String[] args) {

View File

@ -1,4 +1,4 @@
package org.baeldung.cloud.config;
package com.baeldung.cloud.config;
import org.springframework.cloud.config.java.AbstractCloudConfig;
import org.springframework.context.annotation.Bean;

View File

@ -1,4 +1,4 @@
package org.baeldung.config;
package com.baeldung.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;

View File

@ -1,4 +1,4 @@
package org.baeldung.persistence.model;
package com.baeldung.persistence.model;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -1,8 +1,9 @@
package org.baeldung.persistence.repo;
package com.baeldung.persistence.repo;
import org.baeldung.persistence.model.Book;
import org.springframework.data.repository.CrudRepository;
import com.baeldung.persistence.model.Book;
import java.util.List;
import java.util.Optional;

View File

@ -1,9 +1,5 @@
package org.baeldung.web;
package com.baeldung.web;
import org.baeldung.persistence.model.Book;
import org.baeldung.persistence.repo.BookRepository;
import org.baeldung.web.exception.BookIdMismatchException;
import org.baeldung.web.exception.BookNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.CrossOrigin;
@ -17,6 +13,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.persistence.model.Book;
import com.baeldung.persistence.repo.BookRepository;
import com.baeldung.web.exception.BookIdMismatchException;
import com.baeldung.web.exception.BookNotFoundException;
import java.util.List;
@RestController

View File

@ -1,7 +1,5 @@
package org.baeldung.web;
package com.baeldung.web;
import org.baeldung.web.exception.BookIdMismatchException;
import org.baeldung.web.exception.BookNotFoundException;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpHeaders;
@ -12,6 +10,9 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import com.baeldung.web.exception.BookIdMismatchException;
import com.baeldung.web.exception.BookNotFoundException;
@ControllerAdvice
public class RestExceptionHandler extends ResponseEntityExceptionHandler {

View File

@ -1,4 +1,4 @@
package org.baeldung.web;
package com.baeldung.web;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.exception;
package com.baeldung.web.exception;
public class BookIdMismatchException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.exception;
package com.baeldung.web.exception;
public class BookNotFoundException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric;
@ -7,15 +7,16 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.baeldung.persistence.model.Book;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import com.baeldung.persistence.model.Book;
import io.restassured.RestAssured;
import io.restassured.response.Response;
public class SpringBootBootstrapIntegrationTest {
public class SpringBootBootstrapLiveTest {
private static final String API_ROOT = "http://localhost:8080/api/books";

View File

@ -1,4 +1,4 @@
package org.baeldung;
package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -3,11 +3,11 @@ package com.baeldung.annotations;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
// @SpringBootApplication
@SpringBootApplication
public class VehicleFactoryApplication {
// public static void main(String[] args) {
// SpringApplication.run(VehicleFactoryApplication.class, args);
// }
public static void main(String[] args) {
SpringApplication.run(VehicleFactoryApplication.class, args);
}
}

View File

@ -16,7 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class SpringBootMvcApplicationUnitTest {
public class SpringBootMvcApplicationIntegrationTest {
@Autowired
private MockMvc mockMvc;

View File

@ -0,0 +1,16 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Customer Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
</head>
<body>
<br />
<form action="customer" method="POST">
Contact Info: <input type="text" name="contactInfo" /> <br />
<input type="submit" value="Submit" />
</form>
<br /><br />
<span th:text="${message}"></span><br />
</body>
</html>

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="layout :: headerFragment">
</head>
<body>
<div id="container">
<h1>
Hello, <span th:text="${username}">--name--</span>.
</h1>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Service Rendered</th>
</tr>
</thead>
<tbody>
<tr th:each="customer : ${customers}">
<td th:text="${customer.id}">Text ...</td>
<td th:text="${customer.name}">Text ...</td>
<td th:text="${customer.address}">Text ...</td>
<td th:text="${customer.serviceRendered}">Text...</td>
</tr>
</tbody>
</table>
<div id="pagefoot" th:include="layout :: footerFragment">Footer
</div>
</div>
<!-- container -->
</body>
</html>

View File

@ -0,0 +1,10 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Baeldung</title>
</head>
<body>
<h2 th:text="${header}"></h2>
<p th:text="${message}"></p>
</body>
</html>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, we couldn't find the page you were looking for. </h1>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, something went wrong! </h1>
<h2 class="text-center">We're fixing it.</h2>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Something went wrong! </h1>
<h2 class="text-center">Our Engineers are on it.</h2>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>

View File

@ -0,0 +1,8 @@
<html>
<head>
<title>RESOURCE NOT FOUND</title>
</head>
<body>
<h1>404 RESOURCE NOT FOUND</h1>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="layout :: headerFragment">
</head>
<body>
<div class="container">
<div class="jumbotron text-center">
<h1>Customer Portal</h1>
</div>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
erat lectus, vehicula feugiat ultricies at, tempus sed ante. Cras
arcu erat, lobortis vitae quam et, mollis pharetra odio. Nullam sit
amet congue ipsum. Nunc dapibus odio ut ligula venenatis porta non
id dui. Duis nec tempor tellus. Suspendisse id blandit ligula, sit
amet varius mauris. Nulla eu eros pharetra, tristique dui quis,
vehicula libero. Aenean a neque sit amet tellus porttitor rutrum nec
at leo.</p>
<h2>Existing Customers</h2>
<div class="well">
<b>Enter the intranet: </b><a th:href="@{/customers}">customers</a>
</div>
</div>
<div id="pagefoot" th:include="layout :: footerFragment">Footer
</div>
</div>
<!-- container -->
</body>
</html>

View File

@ -0,0 +1,19 @@
<html>
<head>
<title>WebJars Demo</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css" />
</head>
<body>
<h1>Welcome Home</h1>
<div class="container"><br/>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Success!</strong> It is working as we expected.
</div>
</div>
<script src="/webjars/jquery/3.1.1/jquery.min.js"></script>
<script src="/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1" />
<title>Home</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="internationalization.js"></script>
</head>
<body>
<h1 th:text="#{greeting}"></h1>
<br /><br />
<span th:text="#{lang.change}"></span>:
<select id="locales">
<option value=""></option>
<option value="en" th:text="#{lang.eng}"></option>
<option value="fr" th:text="#{lang.fr}"></option>
</select>
</body>
</html>

View File

@ -0,0 +1,18 @@
<head th:fragment="headerFragment">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Customer Portal</title>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"></link>
<link
href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"
rel="stylesheet"></link>
</head>
<div id="pagefoot" th:fragment="footerFragment">
<p>Document last modified 2017/10/23.</p>
<p>Copyright: Lorem Ipsum</p>
</div>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>Spring Utils Demo</title>
<style type="text/css">
.param{
color:green;
font-style: italic;
}
</style>
</head>
<body>
Parameter set by you: <p th:text="${parameter}" class="param"/>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>Spring Utils Demo</title>
<style type="text/css">
.param{
color:green;
font-style: italic;
}
</style>
</head>
<body>
<form action="setParam" method="POST">
<h3>Set Parameter: </h3>
<p th:text="${parameter}" class="param"/>
<input type="text" name="param" id="param"/>
<input type="submit" value="SET"/>
</form>
<br/>
<a href="other">Another Page</a>
</body>
</html>