Skip to content
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 jenkins/currency-exchange-microservice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion jenkins/currency-exchange-microservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jdk-alpine
FROM openjdk:21-jdk-slim
VOLUME /tmp
EXPOSE 8000
ADD target/*.jar app.jar
Expand Down
64 changes: 44 additions & 20 deletions jenkins/currency-exchange-microservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<version>3.2.5</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.directory>null</project.build.directory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>21</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>

<surefire.version>2.22.1</surefire.version>
<failsafe.version>2.22.1</failsafe.version>
<surefire.version>3.1.2</surefire.version>
<failsafe.version>3.1.2</failsafe.version>

<jacoco.version>0.8.3</jacoco.version>
<jacoco.path>${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar</jacoco.path>
Expand Down Expand Up @@ -64,22 +65,17 @@
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.2</version>
</dependency>

<dependency>
Expand All @@ -91,25 +87,36 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured-all</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>4.2.0</version>
<version>7.17.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
<version>7.17.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
<version>7.17.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.17.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -119,6 +126,24 @@
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
Expand All @@ -133,7 +158,6 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ExchangeValue retrieveExchangeValue(@PathVariable String from, @PathVaria

private void printAllHeaders(Map<String, String> headers) {
headers.forEach((key, value) -> {
LOGGER.info(String.format("Header '%s' = %s", key, value));
LOGGER.info("Header '%s' = %s".formatted(key, value));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class ExchangeValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ server.port=8000
spring.jpa.show-sql=true
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
spring.jpa.defer-datasource-initialization=true

#logging.level.org.springframework=debug
management.endpoints.web.base-path=/manage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.in28minutes.microservices.currencyexchangeservice;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
@ExtendWith(MockitoExtension.class)
public class CurrencyExchangeServiceApplicationTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.in28minutes.microservices.currencyexchangeservice.cucumber;

import org.junit.jupiter.api.BeforeEach;
import org.springframework.boot.test.context.SpringBootContextLoader;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.ContextConfiguration;

import com.in28minutes.microservices.currencyexchangeservice.CurrencyExchangeServiceApplicationH2;

import cucumber.api.java.Before;

@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@ContextConfiguration(classes = CurrencyExchangeServiceApplicationH2.class, loader = SpringBootContextLoader.class)
public class CucumberSpringContextConfiguration {

@Before
@BeforeEach
public void setUp() {
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@

package com.in28minutes.microservices.currencyexchangeservice.cucumber;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.http.Method;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;

import static io.restassured.RestAssured.when;

Expand Down Expand Up @@ -42,7 +41,7 @@ public void the_system_is_asked_to_provide_the_conversion_rate() throws Exceptio

@Then("^It should output (.*)$")
public void thenCheckOutput(float response) {
Assert.assertEquals(output, response,0.5);
Assertions.assertEquals(output, response,0.5);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.in28minutes.microservices.currencyexchangeservice.cucumber;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.junit.Assert;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

import org.junit.jupiter.api.Assertions;

import com.in28minutes.microservices.currencyexchangeservice.HelloWorld;

Expand All @@ -20,16 +21,17 @@ public class HelloWorldSteps {
public void givenInput(String name) {
this.name = name;
}

@When("^sayHello method of HelloWorld.java is called$")
public void whenBusinessLogicCalled() {
output = helloWorld.sayHello(name);
}

@Then("^It should return (.*)$")
public void thenCheckOutput(String response) {
Assert.assertEquals(output, response);
Assertions.assertEquals(output, response);
}


public static void main(String[] args) {
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.in28minutes.microservices.currencyexchangeservice.cucumber;

import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.platform.engine.Cucumber;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@Cucumber
@CucumberOptions(monochrome = true, features = "src/test/resources", plugin = { "pretty" })
public class RunCucumberIntegrationTestCase {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@

import java.math.BigDecimal;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import com.in28minutes.microservices.currencyexchangeservice.util.environment.InstanceInformationService;


@RunWith(SpringRunner.class)
@WebMvcTest(CurrencyExchangeController.class)
public class CurrencyExchangeControllerTest {
@Autowired
Expand Down
1 change: 1 addition & 0 deletions kubernetes/01-hello-world-rest-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion kubernetes/01-hello-world-rest-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jdk-alpine
FROM openjdk:21-jdk-slim
VOLUME /tmp
EXPOSE 8080
ADD target/*.jar app.jar
Expand Down
5 changes: 2 additions & 3 deletions kubernetes/01-hello-world-rest-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<version>3.2.5</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>21</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<!-- Needed by io.fabric8 docker-maven-plugin -->
<jar>${project.build.directory}/${project.build.finalName}.jar</jar>
Expand Down Expand Up @@ -70,7 +70,6 @@
<configuration>
<repository>in28min/${project.name}</repository>
<tag>${project.version}</tag>
<skipDockerInfo>true</skipDockerInfo>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.in28minutes.rest.webservices.restfulwebservices;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@ExtendWith(MockitoExtension.class)
@SpringBootTest
public class RestfulWebServicesApplicationTests {

Expand Down
1 change: 1 addition & 0 deletions projects/hello-world/hello-world-java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
4 changes: 2 additions & 2 deletions projects/hello-world/hello-world-java/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Build a JAR File
FROM maven:3.8.2-jdk-8-slim AS stage1
FROM maven:3.9.6-amazoncorretto-21-al2023 AS stage1
WORKDIR /home/app
COPY . /home/app/
RUN mvn -f /home/app/pom.xml clean package

# Create an Image
FROM openjdk:8-jdk-alpine
FROM openjdk:21-jdk-slim
EXPOSE 5000
COPY --from=stage1 /home/app/target/hello-world-java.jar hello-world-java.jar
ENTRYPOINT ["sh", "-c", "java -jar /hello-world-java.jar"]
4 changes: 2 additions & 2 deletions projects/hello-world/hello-world-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<version>3.2.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>21</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

Expand Down
Loading