BAEL-2350 - DataJpaTest Configuration not found (#7996)
* BAEL-2350 - DataJpaTest Configuration not found Add a simple example to show how the correct (package) structure is for using @DataJpaTest * Removed link as requested
This commit is contained in:
committed by
maibin
parent
9fe4a4d6dd
commit
2f9e9d90c7
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.data.jpa.libarary.model;
|
||||
|
||||
public class Example {
|
||||
private String example;
|
||||
|
||||
public String getExample() {
|
||||
return example;
|
||||
}
|
||||
|
||||
public void setExample(String example) {
|
||||
this.example = example;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.baeldung.data.jpa;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TestApplication {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.data.jpa.libarary;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest
|
||||
public class DataJpaUnitTest {
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void givenACorrectSetup_thenAnEntityManagerWillBeAvailable() {
|
||||
assertNotNull(entityManager);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user