Skip to content
Draft
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
18 changes: 17 additions & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@
<javaparser.version>3.27.1</javaparser.version>
<hibernate-quarkus-local-cache.version>0.3.1</hibernate-quarkus-local-cache.version>
<flapdoodle.mongo.version>4.21.0</flapdoodle.mongo.version>
<quarkus-spring-api.version>6.2.SP1</quarkus-spring-api.version>
<quarkus-spring-api.version>6.2.SP2-SNAPSHOT</quarkus-spring-api.version>
<quarkus-spring-data-api.version>3.5</quarkus-spring-data-api.version>
<quarkus-spring-security-api.version>6.4</quarkus-spring-security-api.version>
<quarkus-spring-boot-api.version>3.4</quarkus-spring-boot-api.version>
<quarkus-spring-test-api.version>3.5.Alpha1-SNAPSHOT</quarkus-spring-test-api.version>
<mockito.version>5.20.0</mockito.version>
<jna.version>5.8.0</jna.version><!-- should satisfy both testcontainers and mongodb -->
<quarkus-security.version>2.2.1</quarkus-security.version>
Expand Down Expand Up @@ -3563,6 +3564,11 @@
<artifactId>quarkus-junit5-mockito-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-spring</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-vertx</artifactId>
Expand Down Expand Up @@ -6223,6 +6229,16 @@
<artifactId>quarkus-spring-boot-properties-api</artifactId>
<version>${quarkus-spring-boot-api.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-test-core-api</artifactId>
<version>${quarkus-spring-test-api.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-boot-test-api</artifactId>
<version>${quarkus-spring-test-api.version}</version>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
Expand Down
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
<module>spring-boot-properties</module>
<module>spring-cloud-config-client</module>
<module>spring-data-rest</module>
<module>spring-test</module>
<module>infinispan-cache-jpa</module>
<module>elytron-security</module>
<module>elytron-security-oauth2</module>
Expand Down
190 changes: 190 additions & 0 deletions integration-tests/spring-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>quarkus-integration-tests-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-integration-test-spring-test</artifactId>
<name>Quarkus - Integration Tests - Spring Web</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-web</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-undertow</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-di</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>
<!--TEST LIBs-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-web-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-undertow-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-di-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>tpt</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<quarkus.test.profile.tags>test1,whatever</quarkus.test.profile.tags>
<profiles.check>true</profiles.check>
</systemPropertyVariables>
</configuration>
</execution>
<execution>
<id>prod-mode</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>**/*PMT.java</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.quarkus.it.spring.web;

public class Greeting {

private final String message;

public Greeting(String message) {
this.message = message;
}

public String getMessage() {
return message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.it.spring.web;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/greeting")
public class GreetingController {

final GreetingService greetingService;

public GreetingController(GreetingService greetingService) {
this.greetingService = greetingService;
}

@GetMapping(path = "/json/{message}")
public Greeting greet(@PathVariable String message, @RequestParam String suffix) {
return greetingService.greet(message + suffix);
}

@GetMapping(path = "/re/json/{message}")
public ResponseEntity<Greeting> responseEntityGreeting(@PathVariable String message, @RequestParam String suffix) {
return ResponseEntity.ok(greetingService.greet(message + suffix));
}
//
// @PostMapping(path = "/person")
// public Greeting newGreeting(@RequestBody Person person) {
// return new Greeting("hello " + person.getName());
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.it.spring.web;

import org.springframework.stereotype.Service;

@Service
public class GreetingService {

public Greeting greet(String message) {
return new Greeting(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
junit.jupiter.extensions.autodetection.enabled=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.it.spring.web;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import io.quarkus.arc.Arc;

@SpringBootTest(properties = { "mi.propiedad.test=valor123" })
public class SpringBootExampleTest {

@Test
public void testQuarkusIsRunning() {
// Verifica que Quarkus está corriendo
assertNotNull(Arc.container(), "Quarkus container should be running");

// Verifica que la propiedad de @SpringBootTest se aplicó
String value = System.getProperty("mi.propiedad.test");
assertEquals("valor123", value, "Property from @SpringBootTest should be set");

System.out.println("✅ Test ejecutado correctamente con Quarkus!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkus.it.spring.web;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class SpringControllerIT extends SpringControllerTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.quarkus.it.spring.web;

import static org.hamcrest.Matchers.containsString;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;

@QuarkusTest
public class SpringControllerTest {

@Test
public void testJsonResult() {
RestAssured.when().get("/greeting/json/hello").then()
.contentType("application/json")
.body(containsString("hello"));
}

@Test
public void testJsonResultFromResponseEntity() {
RestAssured.when().get("/greeting/re/json/hello").then()
.contentType("application/json")
.body(containsString("hello"));
}

@Test
public void testJsonResult2() {
RestAssured.when().get("/greeting/json/hello?suffix=000").then()
.contentType("application/json")
.body(containsString("hello000"));
}

@Test
public void testInvalidJsonInputAndResult() {
RestAssured.given().contentType("application/json").body("{\"name\":\"\"}").post("/greeting/person").then()
.statusCode(400);
}

@Test
public void testJsonInputAndResult() {
RestAssured.given().contentType("application/json").body("{\"name\":\"George\"}").post("/greeting/person").then()
.contentType("application/json")
.body(containsString("hello George"));
}

@Test
public void testRestControllerWithoutRequestMapping() {
RestAssured.when().get("/hello").then()
.body(containsString("hello"));
}

@Test
public void testMethodReturningXmlContent() {
RestAssured.when().get("/book")
.then()
.statusCode(200)
.contentType("application/xml")
.body(containsString("steel"));
}
}
Loading