[BAEL-10128] Updated spring JPA article
This commit is contained in:
parent
0811b20096
commit
d36107b8c0
|
@ -156,13 +156,13 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
<org.springframework.version>5.1.5.RELEASE</org.springframework.version>
|
||||||
<javassist.version>3.21.0-GA</javassist.version>
|
<javassist.version>3.21.0-GA</javassist.version>
|
||||||
|
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
<hibernate.version>5.2.10.Final</hibernate.version>
|
<hibernate.version>5.2.17.Final</hibernate.version>
|
||||||
<mysql-connector-java.version>6.0.6</mysql-connector-java.version>
|
<mysql-connector-java.version>6.0.6</mysql-connector-java.version>
|
||||||
<spring-data-jpa.version>1.11.3.RELEASE</spring-data-jpa.version>
|
<spring-data-jpa.version>2.1.5.RELEASE</spring-data-jpa.version>
|
||||||
<h2.version>1.4.195</h2.version>
|
<h2.version>1.4.195</h2.version>
|
||||||
|
|
||||||
<!-- web -->
|
<!-- web -->
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
<javax.servlet.servlet-api.version>2.5</javax.servlet.servlet-api.version>
|
<javax.servlet.servlet-api.version>2.5</javax.servlet.servlet-api.version>
|
||||||
|
|
||||||
<!-- various -->
|
<!-- various -->
|
||||||
<hibernate-validator.version>5.4.1.Final</hibernate-validator.version>
|
<hibernate-validator.version>6.0.15.Final</hibernate-validator.version>
|
||||||
<xml-apis.version>1.4.01</xml-apis.version>
|
<xml-apis.version>1.4.01</xml-apis.version>
|
||||||
<javax.el-api.version>2.2.5</javax.el-api.version>
|
<javax.el-api.version>2.2.5</javax.el-api.version>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.baeldung;
|
||||||
import org.baeldung.config.PersistenceJPAConfigL2Cache;
|
import org.baeldung.config.PersistenceJPAConfigL2Cache;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
@ -11,6 +12,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
|
@DirtiesContext
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class InMemoryDBIntegrationTest {
|
||||||
Student student = new Student(ID, NAME);
|
Student student = new Student(ID, NAME);
|
||||||
studentRepository.save(student);
|
studentRepository.save(student);
|
||||||
|
|
||||||
Student student2 = studentRepository.findOne(ID);
|
Student student2 = studentRepository.findById(ID).get();
|
||||||
assertEquals("name incorrect", NAME, student2.getName());
|
assertEquals("name incorrect", NAME, student2.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue