added source for 'A Guide to Spring Boot in Eclipse'
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package org.baeldung.boot;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = DemoApplication.class)
|
||||
@WebAppConfiguration
|
||||
public class DemoApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.baeldung.boot.repository;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.baeldung.boot.DemoApplicationTests;
|
||||
import org.baeldung.boot.model.Foo;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Transactional
|
||||
public class FooRepositoryTest extends DemoApplicationTests {
|
||||
@Autowired
|
||||
private FooRepository fooRepository;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
fooRepository.save(new Foo("Foo"));
|
||||
fooRepository.save(new Foo("Bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindByName() {
|
||||
Foo foo = fooRepository.findByName("Bar");
|
||||
assertThat(foo, notNullValue());
|
||||
assertThat(foo.getId(), is(2));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user