Skip to content

Spring boot 2 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/
*.idea/
*.iml
*.log
out/
8 changes: 7 additions & 1 deletion multi-module/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
buildscript {
repositories {
maven {
url "http://repo.spring.io/milestone/"
}
mavenCentral()
}
dependencies {
Expand All @@ -8,7 +11,7 @@ buildscript {
}

task wrapper(type: Wrapper) {
gradleVersion = '2.0'
gradleVersion = '4.4'
}

subprojects {
Expand All @@ -17,6 +20,9 @@ subprojects {
targetCompatibility = 1.8

repositories {
maven {
url "http://repo.spring.io/milestone/"
}
mavenCentral()
jcenter()
eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } }
Expand Down
2 changes: 1 addition & 1 deletion multi-module/common-hateoas/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
compile("org.springframework.hateoas:spring-hateoas:$springHateoasVersion")
compile "org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion"

testCompile 'junit:junit:4.11'
}
1 change: 1 addition & 0 deletions multi-module/common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'java'

dependencies {
compile 'org.apache.commons:commons-io:1.3.2'
compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion"
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
Expand Down
8 changes: 5 additions & 3 deletions multi-module/docker-compose-eventuate-local-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
zookeeper:
image: eventuateio/eventuateio-local-zookeeper:0.15.0
image: eventuateio/eventuateio-local-zookeeper:0.17.0.RELEASE
ports:
- 2181:2181
- 2888:2888
- 3888:3888

kafka:
image: eventuateio/eventuateio-local-kafka:0.15.0
image: eventuateio/eventuateio-local-kafka:0.17.0.RELEASE
ports:
- 9092:9092
links:
Expand All @@ -25,7 +25,9 @@ postgres:
POSTGRES_PASSWORD: eventuate

cdcservice:
image: eventuateio/eventuateio-local-cdc-service:0.15.0
image: eventuateio/eventuateio-local-cdc-service:0.17.0.RELEASE
ports:
- "8099:8080"
links:
- postgres
- kafka
Expand Down
6 changes: 3 additions & 3 deletions multi-module/docker-compose-eventuate-local.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
zookeeper:
image: eventuateio/eventuateio-local-zookeeper:0.15.0
image: eventuateio/eventuateio-local-zookeeper:0.17.0.RELEASE
ports:
- 2181:2181
- 2888:2888
- 3888:3888


kafka:
image: eventuateio/eventuateio-local-kafka:0.15.0
image: eventuateio/eventuateio-local-kafka:0.17.0.RELEASE
ports:
- 9092:9092
links:
Expand All @@ -18,7 +18,7 @@ kafka:
- ZOOKEEPER_SERVERS=zookeeper:2181

cdcservice:
image: eventuateio/eventuateio-local-cdc-service:0.15.0
image: eventuateio/eventuateio-local-cdc-service:0.17.0.RELEASE
ports:
- "8099:8080"
links:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import net.chrisrichardson.eventstore.examples.todolist.AbstractTodoRestAPITest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.context.SpringBootTest;


@SpringApplicationConfiguration(classes = {E2ETestConfiguration.class})
@IntegrationTest
@SpringBootTest(classes = E2ETestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class EndToEndTest extends AbstractTodoRestAPITest {

@Value("#{systemEnvironment['DOCKER_HOST_IP']}")
Expand Down
8 changes: 3 additions & 5 deletions multi-module/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ org.gradle.jvmargs=-XX:MaxPermSize=512m

eventuateMavenRepoUrl=

springHateoasVersion=0.17.0.RELEASE
springBootVersion=2.0.0.RELEASE

springBootVersion=1.3.5.RELEASE

eventuateClientVersion=0.19.0.RELEASE
eventuateLocalVersion=0.15.0.RELEASE
eventuateClientVersion=0.20.1.RELEASE
eventuateLocalVersion=0.17.0.RELEASE
2 changes: 1 addition & 1 deletion multi-module/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
2 changes: 1 addition & 1 deletion multi-module/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM eventuateio/eventuateio-local-mysql:0.15.0
FROM eventuateio/eventuateio-local-mysql:0.17.0.RELEASE
COPY schema-mysql.sql /docker-entrypoint-initdb.d
2 changes: 1 addition & 1 deletion multi-module/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM eventuateio/eventuateio-local-postgres:0.14.0
FROM eventuateio/eventuateio-local-postgres:0.17.0.RELEASE
COPY schema-postgres.sql /docker-entrypoint-initdb.d
13 changes: 0 additions & 13 deletions multi-module/rest-api-integration-tests/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion multi-module/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include 'common-swagger'
include 'todo-service'
include 'todo-view-service'
include 'test-utils'
include 'rest-api-integration-tests'
include 'e2etest'

rootProject.name = 'eventuate-examples-java-spring-todo-list-multi-module'
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
Expand All @@ -15,16 +14,13 @@
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import static net.chrisrichardson.eventstore.examples.todolist.testutil.TestUtil.awaitSuccessfulRequest;
import static net.chrisrichardson.eventstore.examples.todolist.testutil.TestUtil.awaitNotFoundResponse;
import static net.chrisrichardson.eventstore.examples.todolist.testutil.TestUtil.awaitSuccessfulRequest;


@RunWith(SpringJUnit4ClassRunner.class)
@IntegrationTest({"server.port=0"})
public abstract class AbstractTodoRestAPITest {

protected int port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
Expand All @@ -14,6 +14,7 @@
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.Collections;


Expand All @@ -26,7 +27,7 @@ public RestTemplate restTemplate(HttpMessageConverters converters) {

// we have to define Apache HTTP client to use the PATCH verb
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json"));
converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM));
converter.setObjectMapper(new ObjectMapper());

HttpClient httpClient = HttpClients.createDefault();
Expand Down
7 changes: 2 additions & 5 deletions multi-module/todo-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apply plugin: 'org.springframework.boot'
apply plugin: VerifyEventStoreEnvironmentPlugin
apply plugin: EventuateDependencyPlugin

apply plugin: 'spring-boot'

dependencies {
compile project(":common")
compile project(":common-hateoas")
Expand All @@ -13,7 +12,5 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
compile("org.springframework.hateoas:spring-hateoas:$springHateoasVersion")

testCompile project(":test-utils")
compile "org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import net.chrisrichardson.eventstore.examples.todolist.todoservice.backend.domain.TodoBulkDeleteAggregate;
import net.chrisrichardson.eventstore.examples.todolist.todoservice.backend.domain.TodoEventSubscriber;
import net.chrisrichardson.eventstore.examples.todolist.todoservice.backend.domain.TodoService;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.persistence.EntityNotFoundException;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.CompletableFuture;


Expand All @@ -27,11 +28,10 @@ public List<Todo> getAll() {

@Override
public CompletableFuture<Todo> findById(String todoId) {
Todo res = repository.findOne(todoId);
if (res != null) {
return CompletableFuture.completedFuture(res);
}
return CompletableFutureUtil.failedFuture(new EntityNotFoundException("No todo found for given id"));
return repository
.findById(todoId)
.map(CompletableFuture::completedFuture)
.orElse(CompletableFutureUtil.failedFuture(new NoSuchElementException("No todo with given id found")));
}

}
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package net.chrisrichardson.eventstore.examples.todolist.todoservice.web;

import net.chrisrichardson.eventstore.examples.todolist.todoservice.backend.TodoBackendConfiguration;
import org.springframework.boot.context.embedded.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@Import({TodoBackendConfiguration.class})
@ComponentScan({ "net.chrisrichardson.eventstore.examples.todolist.common",
"net.chrisrichardson.eventstore.examples.todolist.todoservice.web",
"net.chrisrichardson.eventstore.examples.todolist.hateoas"})
public class TodoWebConfiguration extends WebMvcConfigurerAdapter {

@Bean
public ServletListenerRegistrationBean<RequestContextListener> httpRequestContextListener() {
return new ServletListenerRegistrationBean<RequestContextListener>(new RequestContextListener());
}

public class TodoWebConfiguration {
}
6 changes: 2 additions & 4 deletions multi-module/todo-view-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'org.springframework.boot'
apply plugin: VerifyEventStoreEnvironmentPlugin
apply plugin: EventuateDependencyPlugin
apply plugin: 'spring-boot'

dependencies {
compile project(":common")
Expand All @@ -12,7 +12,5 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
compile("org.springframework.hateoas:spring-hateoas:$springHateoasVersion")

testCompile project(":test-utils")
compile "org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion"
}
Loading