© 2015 Robert Thurnher
-------------------------------------------------------------------------------- /src/main/resources/public/views/home.html: -------------------------------------------------------------------------------- 1 |# | Body | Last Modified |
---|
10 | There was an unexpected error of type "Type". 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/java/net/robi42/boot/TestApplication.java: -------------------------------------------------------------------------------- 1 | package net.robi42.boot; 2 | 3 | import net.robi42.boot.dao.RepositoryRoot; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Import; 7 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 8 | 9 | @Import(TestBeanConfig.class) 10 | @EnableElasticsearchRepositories(basePackageClasses = RepositoryRoot.class) 11 | public @SpringBootApplication class TestApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(TestApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/net/robi42/boot/TestBeanConfig.java: -------------------------------------------------------------------------------- 1 | package net.robi42.boot; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import net.robi42.boot.dao.MessageRepository; 5 | import net.robi42.boot.rest.ObjectMapperProvider; 6 | import net.robi42.boot.util.MessageFactory; 7 | import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; 8 | import org.glassfish.jersey.client.ClientConfig; 9 | import org.springframework.boot.CommandLineRunner; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import javax.inject.Inject; 14 | import javax.ws.rs.client.Client; 15 | 16 | import static javax.ws.rs.client.ClientBuilder.newClient; 17 | import static org.glassfish.jersey.client.ClientProperties.CONNECT_TIMEOUT; 18 | import static org.glassfish.jersey.client.ClientProperties.READ_TIMEOUT; 19 | 20 | @Configuration class TestBeanConfig extends BeanConfig { 21 | @Inject MessageFactory fixtures; 22 | 23 | @Bean CommandLineRunner populateMessageIndex(MessageRepository repository) { 24 | return args -> { 25 | repository.deleteAll(); 26 | repository.save(ImmutableList.of( 27 | fixtures.newMessage("Foo"), 28 | fixtures.newMessage("Bar"))); 29 | Thread.sleep(1000); 30 | repository.save(fixtures.newMessage("Baz")); 31 | }; 32 | } 33 | 34 | @Bean Client webClient() { 35 | return newClient(new ClientConfig() 36 | .property(READ_TIMEOUT, 2000) 37 | .property(CONNECT_TIMEOUT, 500) 38 | .connectorProvider(new ApacheConnectorProvider())) 39 | .register(new ObjectMapperProvider(objectMapper)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/net/robi42/boot/rest/MessageResourceTest.java: -------------------------------------------------------------------------------- 1 | package net.robi42.boot.rest; 2 | 3 | import lombok.val; 4 | import net.robi42.boot.domain.MessageDto; 5 | import net.robi42.boot.util.IntegrationTestBase; 6 | import org.junit.Test; 7 | 8 | import javax.ws.rs.core.GenericType; 9 | import javax.ws.rs.core.Response; 10 | import java.util.List; 11 | 12 | import static java.util.stream.Collectors.toList; 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | 15 | public class MessageResourceTest extends IntegrationTestBase { 16 | 17 | @Test 18 | public void respondsSuccessfully() throws Exception { 19 | val response = restApi.path(MessageResource.BASE_PATH).request().get(); 20 | 21 | assertThat(response.getStatusInfo().getFamily()).isEqualTo(Response.Status.Family.SUCCESSFUL); 22 | response.close(); 23 | } 24 | 25 | @Test 26 | public void respondsWithMessages() throws Exception { 27 | val messages = restApi.path(MessageResource.BASE_PATH).request().get(new GenericType© 2015 Robert Thurnher
3 | -------------------------------------------------------------------------------- /src/webapp/app/views/home.html: -------------------------------------------------------------------------------- 1 |# | 36 |Body | 37 |Last Modified | 38 |39 | |
---|