Merge remote-tracking branch 'upstream/master' into craedel-spring-security-x509
This commit is contained in:
+75
-36
@@ -1,38 +1,77 @@
|
||||
<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>com.baeldung</groupId>
|
||||
<artifactId>mutation-testing</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>mutation-testing</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-parent</artifactId>
|
||||
<version>1.1.10</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.1.10</version>
|
||||
<configuration>
|
||||
<targetClasses>
|
||||
<param>com.baeldung.testing.mutation.*</param>
|
||||
</targetClasses>
|
||||
<targetTests>
|
||||
<param>com.baeldung.mutation.test.*</param>
|
||||
</targetTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>mutation-testing</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>mutation-testing</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-parent</artifactId>
|
||||
<version>1.1.10</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.1.10</version>
|
||||
<configuration>
|
||||
<targetClasses>
|
||||
<param>com.baeldung.testing.mutation.*</param>
|
||||
</targetClasses>
|
||||
<targetTests>
|
||||
<param>com.baeldung.mutation.test.*</param>
|
||||
</targetTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.7.201606060606</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jacoco-check</id>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<rule>
|
||||
<element>PACKAGE</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>LINE</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>0.50</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -8,21 +8,26 @@ import org.junit.Test;
|
||||
import com.baeldung.testing.mutation.Palindrome;
|
||||
|
||||
public class TestPalindrome {
|
||||
@Test
|
||||
public void whenEmptyString_thanAccept() {
|
||||
Palindrome palindromeTester = new Palindrome();
|
||||
assertTrue(palindromeTester.isPalindrome("noon"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptsPalindrome() {
|
||||
public void whenPalindrom_thanAccept() {
|
||||
Palindrome palindromeTester = new Palindrome();
|
||||
assertTrue(palindromeTester.isPalindrome("noon"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsNonPalindrome(){
|
||||
public void whenNotPalindrom_thanReject(){
|
||||
Palindrome palindromeTester = new Palindrome();
|
||||
assertFalse(palindromeTester.isPalindrome("box"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsNearPalindrome(){
|
||||
public void whenNearPalindrom_thanReject(){
|
||||
Palindrome palindromeTester = new Palindrome();
|
||||
assertFalse(palindromeTester.isPalindrome("neon"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>orika</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<properties>
|
||||
<slf4j-api.version>1.7.5</slf4j-api.version>
|
||||
<jcl-over-slf4j.version>1.7.5</jcl-over-slf4j.version>
|
||||
<orika-core.version>1.4.6</orika-core.version>
|
||||
<junit.version>4.3</junit.version>
|
||||
</properties>
|
||||
|
||||
<name>Orika</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j-api.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${jcl-over-slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ma.glasnost.orika</groupId>
|
||||
<artifactId>orika-core</artifactId>
|
||||
<version>${orika-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>7</source>
|
||||
<target>7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Dest {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dest [name=" + name + ", age=" + age + "]";
|
||||
}
|
||||
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public Dest() {
|
||||
|
||||
}
|
||||
|
||||
public Dest(String name, int age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Name {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public Name(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Person {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person [name=" + name + ", nickname=" + nickname + ", age="
|
||||
+ age + "]";
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String nickname;
|
||||
private int age;
|
||||
|
||||
public Person() {
|
||||
|
||||
}
|
||||
|
||||
public Person(String name, String nickname, int age) {
|
||||
this.name = name;
|
||||
this.nickname = nickname;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Person3 {
|
||||
private String name;
|
||||
private String dtob;
|
||||
|
||||
public Person3() {
|
||||
|
||||
}
|
||||
|
||||
public Person3(String name, String dtob) {
|
||||
this.name = name;
|
||||
this.dtob = dtob;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDtob() {
|
||||
return dtob;
|
||||
}
|
||||
|
||||
public void setDtob(String dtob) {
|
||||
this.dtob = dtob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person3 [name=" + name + ", dtob=" + dtob + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class PersonContainer {
|
||||
private Name name;
|
||||
|
||||
public PersonContainer(Name name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Name getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(Name name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
import ma.glasnost.orika.CustomMapper;
|
||||
import ma.glasnost.orika.MappingContext;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
class PersonCustomMapper extends CustomMapper<Personne3, Person3> {
|
||||
|
||||
@Override
|
||||
public void mapAtoB(Personne3 a, Person3 b, MappingContext context) {
|
||||
Date date = new Date(a.getDtob());
|
||||
DateFormat format = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
String isoDate = format.format(date);
|
||||
b.setDtob(isoDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapBtoA(Person3 b, Personne3 a, MappingContext context) {
|
||||
DateFormat format = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
Date date = null;
|
||||
try {
|
||||
date = format.parse(b.getDtob());
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long timestamp = date.getTime();
|
||||
a.setDtob(timestamp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PersonListContainer {
|
||||
private List<Name> names;
|
||||
|
||||
public PersonListContainer(List<Name> names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public List<Name> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
public void setNames(List<Name> names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class PersonNameArray {
|
||||
private String[] nameArray;
|
||||
|
||||
public PersonNameArray(String[] nameArray) {
|
||||
this.nameArray = nameArray;
|
||||
}
|
||||
|
||||
public String[] getNameArray() {
|
||||
return nameArray;
|
||||
}
|
||||
|
||||
public void setNameArray(String[] nameArray) {
|
||||
this.nameArray = nameArray;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PersonNameList {
|
||||
private List<String> nameList;
|
||||
|
||||
public PersonNameList(List<String> nameList) {
|
||||
this.nameList = nameList;
|
||||
}
|
||||
|
||||
public List<String> getNameList() {
|
||||
return nameList;
|
||||
}
|
||||
|
||||
public void setNameList(List<String> nameList) {
|
||||
this.nameList = nameList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PersonNameMap {
|
||||
private Map<String, String> nameMap;
|
||||
|
||||
public PersonNameMap(Map<String, String> nameMap) {
|
||||
this.nameMap = nameMap;
|
||||
}
|
||||
|
||||
public Map<String, String> getNameMap() {
|
||||
return nameMap;
|
||||
}
|
||||
|
||||
public void setNameMap(Map<String, String> nameList) {
|
||||
this.nameMap = nameList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class PersonNameParts {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public PersonNameParts(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Personne {
|
||||
private String nom;
|
||||
private String surnom;
|
||||
private int age;
|
||||
|
||||
public Personne(String nom, String surnom, int age) {
|
||||
this.nom = nom;
|
||||
this.surnom = surnom;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getSurnom() {
|
||||
return surnom;
|
||||
}
|
||||
|
||||
public void setSurnom(String surnom) {
|
||||
this.surnom = surnom;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Personne [nom=" + nom + ", surnom=" + surnom + ", age=" + age
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Personne3 {
|
||||
private String name;
|
||||
private long dtob;
|
||||
|
||||
public Personne3() {
|
||||
|
||||
}
|
||||
|
||||
public Personne3(String name, long dtob) {
|
||||
this.name = name;
|
||||
this.dtob = dtob;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getDtob() {
|
||||
return dtob;
|
||||
}
|
||||
|
||||
public void setDtob(long dtob) {
|
||||
this.dtob = dtob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Personne3 [name=" + name + ", dtob=" + dtob + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.baeldung.orika;
|
||||
|
||||
public class Source {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Source [name=" + name + ", age=" + age + "]";
|
||||
}
|
||||
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public Source() {
|
||||
}
|
||||
|
||||
public Source(String name, int age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -83,6 +83,7 @@
|
||||
<module>spring-spel</module>
|
||||
<module>spring-rest</module>
|
||||
<module>spring-rest-docs</module>
|
||||
<module>spring-cloud-config</module>
|
||||
|
||||
<module>spring-security-basic-auth</module>
|
||||
<module>spring-security-custom-permission</module>
|
||||
@@ -109,6 +110,7 @@
|
||||
<module>spring-mvc-velocity</module>
|
||||
<module>xstream</module>
|
||||
<module>dozer</module>
|
||||
<module>orika</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
+135
-135
@@ -1,156 +1,156 @@
|
||||
<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>com.baeldung</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>Spring Boot Actuator</name>
|
||||
<description>This is simple boot application for Spring boot actuator test</description>
|
||||
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>com.baeldung</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>Spring Boot Actuator</name>
|
||||
<description>This is simple boot application for Spring boot actuator test</description>
|
||||
|
||||
<!-- Inherit defaults from Spring Boot -->
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.0.RC1</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<!-- Inherit defaults from Spring Boot -->
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.0.RC1</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<!-- The main class to start by executing java -jar -->
|
||||
<start-class>org.baeldung.boot.DemoApplication</start-class>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- <spring.version>4.3.0.RELEASE</spring.version> -->
|
||||
</properties>
|
||||
<properties>
|
||||
<!-- The main class to start by executing java -jar -->
|
||||
<start-class>org.baeldung.boot.DemoApplication</start-class>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring.version>4.3.1.RELEASE</spring.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.subethamail</groupId>
|
||||
<artifactId>subethasmtp</artifactId>
|
||||
<version>3.1.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.subethamail</groupId>
|
||||
<artifactId>subethasmtp</artifactId>
|
||||
<version>3.1.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>spring-boot</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<build>
|
||||
<finalName>spring-boot</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.baeldung.session.exception;
|
||||
|
||||
import org.baeldung.boot.model.Foo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaSessionFactoryBean;
|
||||
|
||||
@EntityScan(basePackageClasses = Foo.class)
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("spring.config.name", "exception");
|
||||
System.setProperty("spring.profiles.active", "exception");
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HibernateJpaSessionFactoryBean sessionFactory() {
|
||||
return new HibernateJpaSessionFactoryBean();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package org.baeldung.session.exception.repository;
|
||||
|
||||
import org.baeldung.boot.model.Foo;
|
||||
|
||||
public interface FooRepository {
|
||||
|
||||
void save(Foo foo);
|
||||
|
||||
Foo get(Integer id);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.baeldung.session.exception.repository;
|
||||
|
||||
import org.baeldung.boot.model.Foo;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Profile("exception")
|
||||
@Repository
|
||||
public class FooRepositoryImpl implements FooRepository {
|
||||
@Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Override
|
||||
public void save(Foo foo) {
|
||||
sessionFactory.getCurrentSession().saveOrUpdate(foo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Foo get(Integer id) {
|
||||
return sessionFactory.getCurrentSession().get(Foo.class, id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.baeldung.boot;
|
||||
|
||||
import org.baeldung.session.exception.Application;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@TestPropertySource("classpath:exception.properties")
|
||||
public class ApplicationTests {
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@ package org.baeldung.boot;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = DemoApplication.class)
|
||||
@SpringBootTest(classes = DemoApplication.class)
|
||||
@WebAppConfiguration
|
||||
public class DemoApplicationTests {
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.baeldung.boot.repository;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.baeldung.boot.ApplicationTests;
|
||||
import org.baeldung.boot.model.Foo;
|
||||
import org.baeldung.session.exception.repository.FooRepository;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Transactional
|
||||
@TestPropertySource("classpath:exception-hibernate.properties")
|
||||
public class HibernateSessionTest extends ApplicationTests {
|
||||
@Autowired
|
||||
private FooRepository fooRepository;
|
||||
|
||||
@Test
|
||||
public void whenSavingWithCurrentSession_thenThrowNoException() {
|
||||
Foo foo = new Foo("Exception Solved");
|
||||
fooRepository.save(foo);
|
||||
foo = null;
|
||||
foo = fooRepository.get(1);
|
||||
|
||||
assertThat(foo, notNullValue());
|
||||
assertThat(foo.getId(), is(1));
|
||||
assertThat(foo.getName(), is("Exception Solved"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.baeldung.boot.repository;
|
||||
|
||||
import org.baeldung.boot.ApplicationTests;
|
||||
import org.baeldung.boot.model.Foo;
|
||||
import org.baeldung.session.exception.repository.FooRepository;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Transactional
|
||||
public class NoHibernateSessionTest extends ApplicationTests {
|
||||
@Autowired
|
||||
private FooRepository fooRepository;
|
||||
|
||||
@Test(expected = HibernateException.class)
|
||||
public void whenSavingWithoutCurrentSession_thenThrowException() {
|
||||
Foo foo = new Foo("Exception Thrown");
|
||||
fooRepository.save(foo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
spring.profiles.active=exception
|
||||
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
|
||||
@@ -0,0 +1,6 @@
|
||||
# Security
|
||||
security.user.name=admin
|
||||
security.user.password=password
|
||||
|
||||
spring.dao.exceptiontranslation.enabled=false
|
||||
spring.profiles.active=exception
|
||||
@@ -0,0 +1,2 @@
|
||||
user.role=Developer
|
||||
user.password=pass
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user