added source for 'A Guide to Spring Boot in Eclipse'

This commit is contained in:
Julius Krah
2016-07-06 16:09:24 +00:00
parent 024b4f8f61
commit fff769ed9d
8 changed files with 204 additions and 59 deletions
@@ -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));
}
}