Skip to content

Commit

Permalink
JDK 11 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
anair-it committed Oct 31, 2019
1 parent 84bc531 commit 10eb6d4
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 51 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Spring-boot based Microservice platform with
- Distributed tracing ([Jaeger](https://www.jaegertracing.io/))
- Metrics collection and visualization ([Prometheus](https://prometheus.io/), [Loki](https://grafana.com/oss/loki/), [Grafana](https://grafana.com/))

# Pre-requisite
- JDK 11 compiler
- Docker > 1.18 (Docker desktop on Windows and MacOS will work)
- Docker compose (latest version. Comes with Docker desktop)

# Understanding components in this project
## Spring boot parent pom (anair-parent-pom)
- anair-parent-pom is the parent pom that manages commonly used dependencies and plugins.
Expand Down
68 changes: 26 additions & 42 deletions anair-parent-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
<spring-boot.version>2.2.0.RELEASE</spring-boot.version>

<commons-io.version>2.6</commons-io.version>
<commons-lang3.version>3.9</commons-lang3.version>
Expand All @@ -37,8 +39,9 @@
<swagger.version>2.9.2</swagger.version>
<hikari.version>3.4.1</hikari.version>
<spring-boot-admin.version>2.1.6</spring-boot-admin.version>
<asm.version>7.2</asm.version>

<jacoco-plugin.version>0.8.4</jacoco-plugin.version>
<jacoco-plugin.version>0.8.5</jacoco-plugin.version>
<docker-maven-plugin.version>0.31.0</docker-maven-plugin.version>
<spring-boot-thin-maven-plugin.version>1.0.22.RELEASE</spring-boot-thin-maven-plugin.version>

Expand Down Expand Up @@ -230,6 +233,9 @@
<exclude>**/*IntegTest.java</exclude>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
Expand All @@ -241,45 +247,9 @@
<include>**/*IntegTest</include>
<include>**/*IntegrationTest</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
<version>1.3.7</version>
<configuration>
<swaggerInput>${project.build.directory}/generated-sources/swagger.json</swaggerInput>
<outputDir>${swagger.output.dir}</outputDir>
<config>
<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
</config>
</configuration>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.6</version>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>1.5.0-alpha.18</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>9.2.7.0</version>
</dependency>
</dependencies>
<configuration>
<sourceDocumentName>anair.adoc</sourceDocumentName>
<outputDirectory>${project.build.directory}/swaggerreport</outputDirectory>
<attributes>
<doctype>book</doctype>
<toc>left</toc>
<toclevels>3</toclevels>
<generated>${swagger.output.dir}</generated>
</attributes>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -359,6 +329,20 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${java.version}</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
FROM openjdk:8-jre-alpine
FROM adoptopenjdk/openjdk11:alpine-jre

LABEL maintainer="Anoop Nair"

Expand Down
2 changes: 1 addition & 1 deletion anair-service-a/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jre-alpine
FROM adoptopenjdk/openjdk11:alpine-jre

LABEL maintainer="Anoop Nair"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public ResponseEntity<String> echo(@RequestHeader final HttpHeaders headers, @Ap
public ResponseEntity<String> publish(@ApiParam(value = "userId", required = true) @NotBlank @PathVariable("userId") final String userId) {
publishService.publish(userId);
ResponseEntity<Books.Book> book = protoRestTemplate.getForEntity(baseurlServiceC+"/book/1", Books.Book.class);

if(book.getStatusCode().is2xxSuccessful()){
logger.info("Received book for id: 1 -> {}", book.getBody().toString());
return ResponseEntity.status(HttpStatus.OK).body(book.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public void publish_200() throws Exception {
.setLastName("lname1"))
.build();
Mockito.when(bookEntity.getBody()).thenReturn(book);
Mockito.when(restTemplate.getForEntity("http://localhost:8082/anair-service-c/book/1", Books.Book.class)).thenReturn(bookEntity);
Mockito.when(restTemplate.getForEntity("http://localhost:8083/anair-service-c/book/1", Books.Book.class)).thenReturn(bookEntity);

mockMvc.perform(get("/publish/anair"))
.andExpect(status().isOk())
.andReturn();

Mockito.verify(publishService).publish("anair");
Mockito.verify(restTemplate).getForEntity("http://localhost:8082/anair-service-c/book/1", Books.Book.class);
Mockito.verify(restTemplate).getForEntity("http://localhost:8083/anair-service-c/book/1", Books.Book.class);
Mockito.verify(bookEntity).getStatusCode();
Mockito.verify(bookEntity).getBody();
}
Expand All @@ -83,14 +83,14 @@ public void publish_grpc_error_500() throws Exception {
ResponseEntity bookEntity = Mockito.mock(ResponseEntity.class);
Mockito.doNothing().when(publishService).publish("anair");
Mockito.when(bookEntity.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
Mockito.when(restTemplate.getForEntity("http://localhost:8082/anair-service-c/book/1", Books.Book.class)).thenReturn(bookEntity);
Mockito.when(restTemplate.getForEntity("http://localhost:8083/anair-service-c/book/1", Books.Book.class)).thenReturn(bookEntity);

mockMvc.perform(get("/publish/anair"))
.andExpect(status().is5xxServerError())
.andReturn();

Mockito.verify(publishService).publish("anair");
Mockito.verify(restTemplate).getForEntity("http://localhost:8082/anair-service-c/book/1", Books.Book.class);
Mockito.verify(restTemplate).getForEntity("http://localhost:8083/anair-service-c/book/1", Books.Book.class);
Mockito.verify(bookEntity).getStatusCode();
}

Expand Down
2 changes: 1 addition & 1 deletion anair-service-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jre-alpine
FROM adoptopenjdk/openjdk11:alpine-jre

LABEL maintainer="Anoop Nair"

Expand Down
2 changes: 1 addition & 1 deletion anair-service-b/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jre-alpine
FROM adoptopenjdk/openjdk11:alpine-jre

LABEL maintainer="Anoop Nair"

Expand Down
2 changes: 1 addition & 1 deletion anair-service-c/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jre-alpine
FROM adoptopenjdk/openjdk11:alpine-jre

LABEL maintainer="Anoop Nair"

Expand Down

0 comments on commit 10eb6d4

Please sign in to comment.