JAVA-32410: Update mockito-core to version 5.11.0 (#16199)
* JAVA-32410: Update mockito-core to version 5.11.0 * Fix rollback mockito upgrade. * wip * WIP: Update jee-7 wildfly versions * WIP: Fix jersey tests * WIP: rollback powermock module * wip: fix test in spring-data-dynamodb * wip: fix test in spring-security-legacy-oidc * wip: rollback quarkus * wip: fix greeter-spring-boot-autoconfigure * JAVA-33535: Fix spring-core module integration test JAVA-33535: rollback junit-5 module mockito version. * Fix byte-buddy * Fix log4j dependency in apache-poi
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@@ -100,11 +100,10 @@
|
||||
<jakartaee-api.version>9.0.0</jakartaee-api.version>
|
||||
<krazo.version>2.0.0</krazo.version>
|
||||
<jakarta.mvc-api.version>2.0.0</jakarta.mvc-api.version>
|
||||
<junit.jupiter.version>5.8.2</junit.jupiter.version>
|
||||
<junit.jupiter.version>5.10.2</junit.jupiter.version>
|
||||
<local.glassfish.home>C:/glassfish6</local.glassfish.home>
|
||||
<local.glassfish.user>admin</local.glassfish.user>
|
||||
<local.glassfish.domain>mvn-domain</local.glassfish.domain>
|
||||
<mockito.version>1.10.19</mockito.version>
|
||||
<local.glassfish.passfile>
|
||||
${local.glassfish.home}\\domains\\${local.glassfish.domain}\\config\\domain-passwords
|
||||
</local.glassfish.passfile>
|
||||
|
||||
+13
-15
@@ -1,25 +1,23 @@
|
||||
package com.baeldung.eclipse.krazo;
|
||||
|
||||
import com.baeldung.eclipse.krazo.User;
|
||||
import com.baeldung.eclipse.krazo.UserController;
|
||||
import jakarta.mvc.Models;
|
||||
import jakarta.mvc.binding.BindingResult;
|
||||
import org.eclipse.krazo.core.ModelsImpl;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.eclipse.krazo.core.ModelsImpl;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import jakarta.mvc.Models;
|
||||
import jakarta.mvc.binding.BindingResult;
|
||||
|
||||
/**
|
||||
* The class contains unit tests. We do only unit tests. Most of the classes are mocked
|
||||
*/
|
||||
|
||||
@@ -112,7 +112,6 @@
|
||||
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
||||
<jetty-maven-plugin.version>10.0.4</jetty-maven-plugin.version>
|
||||
<commons-text.version>1.10.0</commons-text.version>
|
||||
<mockito.version>5.6.0</mockito.version>
|
||||
<uap.version>1.5.4</uap.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<groupId>org.wildfly.arquillian</groupId>
|
||||
<artifactId>wildfly-arquillian-container-managed</artifactId>
|
||||
<version>${wildfly.version}</version>
|
||||
<scope>test</scope>
|
||||
@@ -345,7 +345,7 @@
|
||||
<artifactItem>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-dist</artifactId>
|
||||
<version>${wildfly.version}</version>
|
||||
<version>${wildfly-dist.version}</version>
|
||||
<type>zip</type>
|
||||
<overWrite>false</overWrite>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
@@ -395,7 +395,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<groupId>org.wildfly.arquillian</groupId>
|
||||
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
||||
<version>${wildfly.version}</version>
|
||||
<scope>test</scope>
|
||||
@@ -520,7 +520,8 @@
|
||||
<maven.min.version>3.0.0</maven.min.version>
|
||||
<javaee_api.version>7.0</javaee_api.version>
|
||||
<arquillian_core.version>1.1.11.Final</arquillian_core.version>
|
||||
<wildfly.version>8.2.1.Final</wildfly.version>
|
||||
<wildfly-dist.version>31.0.1.Final</wildfly-dist.version>
|
||||
<wildfly.version>5.0.1.Final</wildfly.version>
|
||||
<awaitility.version>1.7.0</awaitility.version>
|
||||
<undertow-websockets-jsr.version>1.4.6.Final</undertow-websockets-jsr.version>
|
||||
<resteasy.version>3.0.19.Final</resteasy.version>
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baeldung.jersey.server.config.HelloBinding;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/greetings")
|
||||
@@ -17,6 +18,7 @@ public class Greetings {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces("text/html")
|
||||
@Path("/hi")
|
||||
public String getHiGreeting() {
|
||||
return "hi";
|
||||
|
||||
+7
-7
@@ -1,18 +1,18 @@
|
||||
package com.baeldung.jersey.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.glassfish.jersey.test.TestProperties;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.ws.rs.core.Application;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
public class GreetingsResourceIntegrationTest extends JerseyTest {
|
||||
class GreetingsResourceIntegrationTest extends JerseyTest {
|
||||
|
||||
@Override
|
||||
protected Application configure() {
|
||||
@@ -21,14 +21,14 @@ public class GreetingsResourceIntegrationTest extends JerseyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenGetHiGreeting_whenCorrectRequest_thenResponseIsOkAndContainsHi() {
|
||||
void givenGetHiGreeting_whenCorrectRequest_thenResponseIsOkAndContainsHi() {
|
||||
Response response = target("/greetings/hi").request()
|
||||
.get();
|
||||
|
||||
assertEquals("Http Response should be 200: ", Response.Status.OK.getStatusCode(), response.getStatus());
|
||||
assertEquals("Http Content-Type should be: ", MediaType.TEXT_HTML, response.getHeaderString(HttpHeaders.CONTENT_TYPE));
|
||||
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
|
||||
assertEquals(MediaType.TEXT_HTML, response.getHeaderString(HttpHeaders.CONTENT_TYPE));
|
||||
|
||||
String content = response.readEntity(String.class);
|
||||
assertEquals("Content of ressponse is: ", "hi", content);
|
||||
assertEquals("hi", content);
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -2,12 +2,12 @@ package com.baeldung.jersey.server.rest;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.glassfish.jersey.test.TestProperties;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.baeldung.jersey.server.config.ViewApplicationConfig;
|
||||
import com.baeldung.jersey.server.model.Fruit;
|
||||
@@ -19,7 +19,7 @@ import jakarta.ws.rs.core.Form;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
public class FruitResourceIntegrationTest extends JerseyTest {
|
||||
class FruitResourceIntegrationTest extends JerseyTest {
|
||||
|
||||
@Override
|
||||
protected Application configure() {
|
||||
@@ -33,80 +33,80 @@ public class FruitResourceIntegrationTest extends JerseyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenGetAllFruit_whenCorrectRequest_thenAllTemplateInvoked() {
|
||||
void givenGetAllFruit_whenCorrectRequest_thenAllTemplateInvoked() {
|
||||
final String response = target("/fruit/all").request()
|
||||
.get(String.class);
|
||||
assertThat(response, allOf(containsString("banana"), containsString("apple"), containsString("kiwi")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenGetFruit_whenCorrectRequest_thenIndexTemplateInvoked() {
|
||||
void givenGetFruit_whenCorrectRequest_thenIndexTemplateInvoked() {
|
||||
final String response = target("/fruit").request()
|
||||
.get(String.class);
|
||||
assertThat(response, containsString("Welcome Fruit Index Page!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenGetFruitByName_whenFruitUnknown_thenErrorTemplateInvoked() {
|
||||
void givenGetFruitByName_whenFruitUnknown_thenErrorTemplateInvoked() {
|
||||
final String response = target("/fruit/orange").request()
|
||||
.get(String.class);
|
||||
assertThat(response, containsString("Error - Fruit not found: orange!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenCreateFruit_whenFormContainsNullParam_thenResponseCodeIsBadRequest() {
|
||||
void givenCreateFruit_whenFormContainsNullParam_thenResponseCodeIsBadRequest() {
|
||||
Form form = new Form();
|
||||
form.param("name", "apple");
|
||||
form.param("colour", null);
|
||||
Response response = target("fruit/create").request(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
.post(Entity.form(form));
|
||||
|
||||
assertEquals("Http Response should be 400 ", 400, response.getStatus());
|
||||
assertEquals(400, response.getStatus());
|
||||
assertThat(response.readEntity(String.class), containsString("Fruit colour must not be null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenCreateFruit_whenJsonIsCorrect_thenResponseCodeIsCreated() {
|
||||
void givenCreateFruit_whenJsonIsCorrect_thenResponseCodeIsCreated() {
|
||||
Response response = target("fruit/created").request()
|
||||
.post(Entity.json("{\"name\":\"strawberry\",\"weight\":20}"));
|
||||
|
||||
assertEquals("Http Response should be 201 ", Response.Status.CREATED.getStatusCode(), response.getStatus());
|
||||
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
|
||||
assertThat(response.readEntity(String.class), containsString("Fruit saved : Fruit [name: strawberry colour: null]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUpdateFruit_whenFormContainsBadSerialParam_thenResponseCodeIsBadRequest() {
|
||||
void givenUpdateFruit_whenFormContainsBadSerialParam_thenResponseCodeIsBadRequest() {
|
||||
Form form = new Form();
|
||||
form.param("serial", "2345-2345");
|
||||
|
||||
Response response = target("fruit/update").request(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
.put(Entity.form(form));
|
||||
|
||||
assertEquals("Http Response should be 400 ", 400, response.getStatus());
|
||||
assertEquals(400, response.getStatus());
|
||||
assertThat(response.readEntity(String.class), containsString("Fruit serial number is not valid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenCreateFruit_whenFruitIsInvalid_thenResponseCodeIsBadRequest() {
|
||||
void givenCreateFruit_whenFruitIsInvalid_thenResponseCodeIsBadRequest() {
|
||||
Fruit fruit = new Fruit("Blueberry", "purple");
|
||||
fruit.setWeight(1);
|
||||
|
||||
Response response = target("fruit/create").request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.post(Entity.entity(fruit, MediaType.APPLICATION_JSON_TYPE));
|
||||
|
||||
assertEquals("Http Response should be 400 ", 400, response.getStatus());
|
||||
assertEquals(400, response.getStatus());
|
||||
assertThat(response.readEntity(String.class), containsString("Fruit weight must be 10 or greater"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenFruitExists_whenSearching_thenResponseContainsFruit() {
|
||||
void givenFruitExists_whenSearching_thenResponseContainsFruit() {
|
||||
Fruit fruit = new Fruit();
|
||||
fruit.setName("strawberry");
|
||||
fruit.setWeight(20);
|
||||
Response response = target("fruit/create").request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.post(Entity.entity(fruit, MediaType.APPLICATION_JSON_TYPE));
|
||||
|
||||
assertEquals("Http Response should be 204 ", 204, response.getStatus());
|
||||
assertEquals(204, response.getStatus());
|
||||
|
||||
final String json = target("fruit/search/strawberry").request()
|
||||
.get(String.class);
|
||||
@@ -114,28 +114,28 @@ public class FruitResourceIntegrationTest extends JerseyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenFruitExists_whenSearching_thenResponseContainsFruitEntity() {
|
||||
void givenFruitExists_whenSearching_thenResponseContainsFruitEntity() {
|
||||
Fruit fruit = new Fruit();
|
||||
fruit.setName("strawberry");
|
||||
fruit.setWeight(20);
|
||||
Response response = target("fruit/create").request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.post(Entity.entity(fruit, MediaType.APPLICATION_JSON_TYPE));
|
||||
|
||||
assertEquals("Http Response should be 204 ", 204, response.getStatus());
|
||||
assertEquals(204, response.getStatus());
|
||||
|
||||
final Fruit entity = target("fruit/search/strawberry").request()
|
||||
.get(Fruit.class);
|
||||
|
||||
assertEquals("Fruit name: ", "strawberry", entity.getName());
|
||||
assertEquals("Fruit weight: ", Integer.valueOf(20), entity.getWeight());
|
||||
assertEquals("strawberry", entity.getName());
|
||||
assertEquals(Integer.valueOf(20), entity.getWeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenFruit_whenFruitIsInvalid_thenReponseContainsCustomExceptions() {
|
||||
void givenFruit_whenFruitIsInvalid_thenReponseContainsCustomExceptions() {
|
||||
final Response response = target("fruit/exception").request()
|
||||
.get();
|
||||
|
||||
assertEquals("Http Response should be 400 ", 400, response.getStatus());
|
||||
assertEquals(400, response.getStatus());
|
||||
String responseString = response.readEntity(String.class);
|
||||
assertThat(responseString, containsString("exception.<return value>.colour size must be between 5 and 200"));
|
||||
assertThat(responseString, containsString("exception.<return value>.name size must be between 5 and 200"));
|
||||
|
||||
Reference in New Issue
Block a user