From ac30817a2365e294a2d9fb2a453bd22182f73c45 Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Fri, 2 Apr 2021 12:51:43 +0200 Subject: [PATCH 001/551] Evaluation Article: A quick and practical example of Hexagonal Architecture in Java --- .../hexagonal/HexagonalSpringApplication.java | 20 +++ .../adapter/BookingPersistenceAdapter.java | 18 +++ .../adapter/RestAPIEndpointAdapter.java | 38 ++++++ .../adapter/TheatreServiceAdapter.java | 31 +++++ .../adapter/WalletServiceAdapter.java | 23 ++++ .../baeldung/hexagonal/domain/Booking.java | 84 +++++++++++++ .../service/CustomerWalletService.java | 8 ++ .../service/MockCustomerWalletService.java | 11 ++ .../external/service/MockTheatreService.java | 21 ++++ .../external/service/TheatreService.java | 24 ++++ .../port/BookingPersistencePort.java | 7 ++ .../hexagonal/port/BookingServicePort.java | 73 +++++++++++ .../hexagonal/port/TheatreServicePort.java | 9 ++ .../hexagonal/port/WalletServicePort.java | 5 + .../repository/BookingRepository.java | 8 ++ .../repository/MockBookingRepository.java | 11 ++ .../hexagonal/usecase/BookTicketUseCase.java | 67 ++++++++++ .../RestAPIEndpointAdapterUnitTest.java | 88 +++++++++++++ .../usecase/BookTicketUseCaseUnitTest.java | 119 ++++++++++++++++++ 19 files changed, 665 insertions(+) create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java create mode 100644 ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java create mode 100644 ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java create mode 100644 ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java diff --git a/ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java b/ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java new file mode 100644 index 0000000000..c679d459f0 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java @@ -0,0 +1,20 @@ +package com.baeldung.hexagonal; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; +import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; +import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; + + +@SpringBootApplication(exclude={ + CassandraAutoConfiguration.class, + MongoDataAutoConfiguration.class, + MongoAutoConfiguration.class +}) +public class HexagonalSpringApplication { + + public static void main(final String[] args) { + SpringApplication.run(HexagonalSpringApplication.class, args); + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java new file mode 100644 index 0000000000..e6d4dbbe36 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java @@ -0,0 +1,18 @@ +package com.baeldung.hexagonal.adapter; + +import com.baeldung.hexagonal.domain.Booking; +import com.baeldung.hexagonal.port.BookingPersistencePort; +import com.baeldung.hexagonal.repository.BookingRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class BookingPersistenceAdapter implements BookingPersistencePort { + + @Autowired + private BookingRepository bookingRepository; + + public boolean persist(Booking booking) { + return bookingRepository.save(booking); + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java new file mode 100644 index 0000000000..7c35f302c0 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java @@ -0,0 +1,38 @@ +package com.baeldung.hexagonal.adapter; + +import com.baeldung.hexagonal.port.BookingServicePort; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import static com.baeldung.hexagonal.port.BookingServicePort.BookingRequest; +import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse; +import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; + +@RestController +public class RestAPIEndpointAdapter { + + private BookingServicePort bookingServicePort; + + @Autowired + public RestAPIEndpointAdapter(BookingServicePort bookingServicePort) { + this.bookingServicePort = bookingServicePort; + } + + @PostMapping(path = "/booking") + public ResponseEntity createBooking(@RequestBody BookingRequest request) { + BookingResponse response = bookingServicePort.book(request); + + if (response.getStatusCode() == SEAT_NOT_AVAILABLE + || response.getStatusCode() == PAYMENT_FAILED){ + return new ResponseEntity(response, HttpStatus.PRECONDITION_FAILED); + } else if (response.getStatusCode() == UNKNOWN_ERROR) { + return new ResponseEntity(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + return new ResponseEntity(response, HttpStatus.CREATED); + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java new file mode 100644 index 0000000000..d644f5eee0 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java @@ -0,0 +1,31 @@ +package com.baeldung.hexagonal.adapter; + +import com.baeldung.hexagonal.external.service.TheatreService; +import com.baeldung.hexagonal.port.TheatreServicePort; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Optional; +import java.util.Set; + +@Component +public class TheatreServiceAdapter implements TheatreServicePort { + + @Autowired + private TheatreService theatreService; + + public Optional reserveSeats(String theatreId, String movieShowId, Set seats) { + ResponseEntity response = theatreService.postReservation(theatreId, movieShowId, seats); + if (response.getStatusCode() == HttpStatus.CREATED) { + return Optional.of(response.getBody().getId()); + } + return Optional.empty(); + } + + public boolean releaseSeats(String resrevationId) { + ResponseEntity response = theatreService.deleteReservation(resrevationId); + return response.getStatusCode() == HttpStatus.NO_CONTENT; + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java new file mode 100644 index 0000000000..930b9c1cf6 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java @@ -0,0 +1,23 @@ +package com.baeldung.hexagonal.adapter; + +import com.baeldung.hexagonal.external.service.CustomerWalletService; +import com.baeldung.hexagonal.port.WalletServicePort; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +@Component +public class WalletServiceAdapter implements WalletServicePort { + + private final CustomerWalletService customerWalletService; + + @Autowired + public WalletServiceAdapter(CustomerWalletService customerWalletService) { + this.customerWalletService = customerWalletService; + } + + public boolean debit(String customerId, Double amount) { + HttpStatus response = customerWalletService.postDebit(customerId, amount); + return response == HttpStatus.CREATED; + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java b/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java new file mode 100644 index 0000000000..34e3f3b81b --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java @@ -0,0 +1,84 @@ +package com.baeldung.hexagonal.domain; + +import java.util.Set; + +public class Booking { + private String bookingId; + private String movieShowId; + private String theatreId; + private String customerId; + private Set seats; + private Double amount; + private Status status; + + public enum Status { + INITIAL, SUCCESS, FAILURE + } + + public Booking( + String bookingId, String movieShowId, String theatreId, String customerId, Set seats, Double amount, Status status) { + this.bookingId = bookingId; + this.movieShowId = movieShowId; + this.theatreId = theatreId; + this.customerId = customerId; + this.seats = seats; + this.amount = amount; + this.status = Status.INITIAL; + } + + public String getMovieShowId() { + return movieShowId; + } + + public String getTheatreId() { + return theatreId; + } + + public Set getSeats() { + return seats; + } + + public String getCustomerId() { + return customerId; + } + + public String getBookingId() { + return bookingId; + } + + public Double getAmount() { + return amount; + } + + public Status getStatus() { + return status; + } + + public void setBookingId(String bookingId) { + this.bookingId = bookingId; + } + + public void setMovieShowId(String movieShowId) { + this.movieShowId = movieShowId; + } + + public void setTheatreId(String theatreId) { + this.theatreId = theatreId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public void setSeats(Set seats) { + this.seats = seats; + } + + public void setAmount(Double amount) { + this.amount = amount; + } + + public void setStatus(Status status) { + this.status = status; + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java new file mode 100644 index 0000000000..102cef788e --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java @@ -0,0 +1,8 @@ +package com.baeldung.hexagonal.external.service; + +import org.springframework.http.HttpStatus; + +public interface CustomerWalletService { + + HttpStatus postDebit(String customerId, Double amount); +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java new file mode 100644 index 0000000000..4a76368b19 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java @@ -0,0 +1,11 @@ +package com.baeldung.hexagonal.external.service; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; + +@Service +public class MockCustomerWalletService implements CustomerWalletService { + public HttpStatus postDebit(String customerId, Double amount) { + return HttpStatus.CREATED; + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java new file mode 100644 index 0000000000..333cbee889 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal.external.service; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import java.util.Set; +import java.util.UUID; + +@Service +public class MockTheatreService implements TheatreService { + + public ResponseEntity postReservation(String theatreId, String movieShowId, Set seats) { + return new ResponseEntity( + new Reservation(UUID.randomUUID().toString()), HttpStatus.CREATED); + } + + public ResponseEntity deleteReservation(String reservationId) { + return new ResponseEntity(HttpStatus.NO_CONTENT); + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java new file mode 100644 index 0000000000..48f0c5e15d --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java @@ -0,0 +1,24 @@ +package com.baeldung.hexagonal.external.service; + +import org.springframework.http.ResponseEntity; + +import java.util.Set; + +public interface TheatreService { + + ResponseEntity postReservation(String theatreId, String movieShowId, Set seats); + + ResponseEntity deleteReservation(String reservationId); + + class Reservation { + private final String id; + + public Reservation(String id) { + this.id = id; + } + + public String getId() { + return id; + } + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java new file mode 100644 index 0000000000..0deffb42e0 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java @@ -0,0 +1,7 @@ +package com.baeldung.hexagonal.port; + +import com.baeldung.hexagonal.domain.Booking; + +public interface BookingPersistencePort { + boolean persist(Booking booking); +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java new file mode 100644 index 0000000000..3b444df4f6 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java @@ -0,0 +1,73 @@ +package com.baeldung.hexagonal.port; + +import java.util.Set; + +public interface BookingServicePort { + + BookingResponse book(BookingRequest request); + + class BookingRequest { + private String movieShowId; + private String customerId; + private String theatreId; + private Set seats; + private Double amount; + + public String getMovieShowId() { + return movieShowId; + } + + public void setMovieShowId(String movieShowId) { + this.movieShowId = movieShowId; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getTheatreId() { + return theatreId; + } + + public void setTheatreId(String theatreId) { + this.theatreId = theatreId; + } + + public Set getSeats() { + return seats; + } + + public void setSeats(Set seats) { + this.seats = seats; + } + + public Double getAmount() { + return amount; + } + + public void setAmount(Double amount) { + this.amount = amount; + } + } + + class BookingResponse { + public static final int SUCCESS = 0; + public static final int SEAT_NOT_AVAILABLE = 1; + public static final int PAYMENT_FAILED = 2; + public static final int UNKNOWN_ERROR = 3; + + private final int statusCode; + + public BookingResponse(int statusCode) { + this.statusCode = statusCode; + } + + public int getStatusCode() { + return statusCode; + } + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java new file mode 100644 index 0000000000..dac517c724 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java @@ -0,0 +1,9 @@ +package com.baeldung.hexagonal.port; + +import java.util.Optional; +import java.util.Set; + +public interface TheatreServicePort { + Optional reserveSeats(String theatreId, String movieShowId, Set seats); + boolean releaseSeats(String resrevationId); +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java new file mode 100644 index 0000000000..102bb619e8 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java @@ -0,0 +1,5 @@ +package com.baeldung.hexagonal.port; + +public interface WalletServicePort { + boolean debit(String customerId, Double amount); +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java b/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java new file mode 100644 index 0000000000..c56ffe1308 --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.hexagonal.repository; + +import com.baeldung.hexagonal.domain.Booking; + +public interface BookingRepository { + + boolean save(Booking booking); +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java b/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java new file mode 100644 index 0000000000..d378cff0af --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java @@ -0,0 +1,11 @@ +package com.baeldung.hexagonal.repository; + +import com.baeldung.hexagonal.domain.Booking; +import org.springframework.stereotype.Repository; + +@Repository +public class MockBookingRepository implements BookingRepository { + public boolean save(Booking booking) { + return true; + } +} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java b/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java new file mode 100644 index 0000000000..7d9db9724e --- /dev/null +++ b/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java @@ -0,0 +1,67 @@ +package com.baeldung.hexagonal.usecase; + +import com.baeldung.hexagonal.domain.Booking; +import com.baeldung.hexagonal.port.BookingPersistencePort; +import com.baeldung.hexagonal.port.BookingServicePort; +import com.baeldung.hexagonal.port.TheatreServicePort; +import com.baeldung.hexagonal.port.WalletServicePort; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Optional; +import java.util.UUID; + +import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; + +@Component +public class BookTicketUseCase implements BookingServicePort { + + private BookingPersistencePort bookingPersistencePort; + private TheatreServicePort theatreServicePort; + private WalletServicePort walletServicePort; + + @Autowired + public BookTicketUseCase(BookingPersistencePort bookingPersistencePort, TheatreServicePort theatreServicePort, WalletServicePort walletServicePort) { + this.bookingPersistencePort = bookingPersistencePort; + this.theatreServicePort = theatreServicePort; + this.walletServicePort = walletServicePort; + } + + public BookingResponse book(BookingRequest request) { + + Booking booking = new Booking( + UUID.randomUUID().toString(), + request.getMovieShowId(), + request.getTheatreId(), + request.getCustomerId(), + request.getSeats(), + request.getAmount(), + Booking.Status.INITIAL); + + if (!bookingPersistencePort.persist(booking)) { + return new BookingResponse(UNKNOWN_ERROR); + } + + Optional reservationIdOptional = theatreServicePort.reserveSeats( + booking.getTheatreId(), + booking.getMovieShowId(), + booking.getSeats()); + if (!reservationIdOptional.isPresent()) { + booking.setStatus(Booking.Status.FAILURE); + bookingPersistencePort.persist(booking); + return new BookingResponse(SEAT_NOT_AVAILABLE); + } + + if (!walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) { + reservationIdOptional.ifPresent(reservationId -> theatreServicePort.releaseSeats(reservationId)); + booking.setStatus(Booking.Status.FAILURE); + bookingPersistencePort.persist(booking); + return new BookingResponse(PAYMENT_FAILED); + } + + booking.setStatus(Booking.Status.SUCCESS); + bookingPersistencePort.persist(booking); + + return new BookingResponse(SUCCESS); + } +} diff --git a/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java b/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java new file mode 100644 index 0000000000..76d853fdda --- /dev/null +++ b/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java @@ -0,0 +1,88 @@ +package com.baeldung.hexagonal.adapter; + +import com.baeldung.hexagonal.port.BookingServicePort; +import com.baeldung.hexagonal.port.BookingServicePort.BookingRequest; +import com.baeldung.hexagonal.port.BookingServicePort.BookingResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.Arrays; +import java.util.HashSet; + +import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +class RestAPIEndpointAdapterUnitTest { + + private BookingServicePort bookingServicePort; + private RestAPIEndpointAdapter restAPIEndpointAdapter; + + @BeforeEach + void setUp() { + bookingServicePort = mock(BookingServicePort.class); + restAPIEndpointAdapter = new RestAPIEndpointAdapter(bookingServicePort); + } + + private BookingServicePort.BookingRequest getBookingRequest() { + BookingServicePort.BookingRequest request = new BookingServicePort.BookingRequest(); + request.setTheatreId("theatre-id"); + request.setMovieShowId("movie-show-id"); + request.setCustomerId("customer-id"); + request.setSeats(new HashSet<>(Arrays.asList("A1", "A2"))); + request.setAmount(100.00); + return request; + } + + @Test + void whenBookingServicePortReturnsUnknownError_thenReturnInternalServerError() { + BookingServicePort.BookingRequest request = getBookingRequest(); + when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(UNKNOWN_ERROR)); + + ResponseEntity response = restAPIEndpointAdapter.createBooking(request); + + verify(bookingServicePort).book(any(BookingRequest.class)); + assertNotNull(response); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); + } + + @Test + void whenBookingServicePortReturnsSeatUnavailable_thenReturnPreconditionFailed() { + BookingServicePort.BookingRequest request = getBookingRequest(); + when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(SEAT_NOT_AVAILABLE)); + + ResponseEntity response = restAPIEndpointAdapter.createBooking(request); + + verify(bookingServicePort).book(any(BookingRequest.class)); + assertNotNull(response); + assertEquals(HttpStatus.PRECONDITION_FAILED, response.getStatusCode()); + } + + @Test + void whenBookingServicePortReturnsPaymentFailed_thenReturnPreconditionFailed() { + BookingServicePort.BookingRequest request = getBookingRequest(); + when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(PAYMENT_FAILED)); + + ResponseEntity response = restAPIEndpointAdapter.createBooking(request); + + verify(bookingServicePort).book(any(BookingRequest.class)); + assertNotNull(response); + assertEquals(HttpStatus.PRECONDITION_FAILED, response.getStatusCode()); + } + + @Test + void whenBookingServicePortReturnsSuccess_thenReturnCreated() { + BookingServicePort.BookingRequest request = getBookingRequest(); + when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(SUCCESS)); + + ResponseEntity response = restAPIEndpointAdapter.createBooking(request); + + verify(bookingServicePort).book(any(BookingRequest.class)); + assertNotNull(response); + assertEquals(HttpStatus.CREATED, response.getStatusCode()); + } +} \ No newline at end of file diff --git a/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java b/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java new file mode 100644 index 0000000000..eec2b65609 --- /dev/null +++ b/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java @@ -0,0 +1,119 @@ +package com.baeldung.hexagonal.usecase; + +import com.baeldung.hexagonal.domain.Booking; +import com.baeldung.hexagonal.port.BookingPersistencePort; +import com.baeldung.hexagonal.port.BookingServicePort; +import com.baeldung.hexagonal.port.TheatreServicePort; +import com.baeldung.hexagonal.port.WalletServicePort; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +class BookTicketUseCaseUnitTest { + + private BookingPersistencePort bookingPersistencePort; + private TheatreServicePort theatreServicePort; + private WalletServicePort walletServicePort; + private BookTicketUseCase bookTicketUseCase; + + @BeforeEach + void setUp() { + bookingPersistencePort = mock(BookingPersistencePort.class); + theatreServicePort = mock(TheatreServicePort.class); + walletServicePort = mock(WalletServicePort.class); + bookTicketUseCase = new BookTicketUseCase(bookingPersistencePort, theatreServicePort, walletServicePort); + } + + private BookingServicePort.BookingRequest getBookingRequest() { + BookingServicePort.BookingRequest request = new BookingServicePort.BookingRequest(); + request.setTheatreId("theatre-id"); + request.setMovieShowId("movie-show-id"); + request.setCustomerId("customer-id"); + request.setSeats(new HashSet<>(Arrays.asList("A1", "A2"))); + request.setAmount(100.00); + return request; + } + + private Booking getBooking(BookingServicePort.BookingRequest request) { + return new Booking( + "booking-id", + request.getMovieShowId(), + request.getTheatreId(), + request.getCustomerId(), + request.getSeats(), + request.getAmount(), + Booking.Status.INITIAL); + } + + @Test + void whenErrorInInitialPersistence_thenReturnUnknownError() { + BookingServicePort.BookingRequest request = getBookingRequest(); + Booking booking = getBooking(request); + when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(false); + BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); + + verify(bookingPersistencePort, times(1)).persist(any(Booking.class)); + assertNotNull(response); + assertEquals(BookingServicePort.BookingResponse.UNKNOWN_ERROR, response.getStatusCode()); + } + + @Test + void whenErrorInReserveSeats_thenReturnSeatNotAvailable() { + BookingServicePort.BookingRequest request = getBookingRequest(); + Booking booking = getBooking(request); + when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); + when(theatreServicePort.reserveSeats(booking.getTheatreId(), booking.getMovieShowId(), booking.getSeats())) + .thenReturn(Optional.empty()); + BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); + + verify(bookingPersistencePort, times(2)).persist(any(Booking.class)); + verify(theatreServicePort).reserveSeats(any(String.class), any(String.class), any(HashSet.class)); + assertNotNull(response); + assertEquals(BookingServicePort.BookingResponse.SEAT_NOT_AVAILABLE, response.getStatusCode()); + } + + @Test + void whenErrorInWalletDebit_thenReturnPaymentFailed() { + BookingServicePort.BookingRequest request = getBookingRequest(); + Booking booking = getBooking(request); + when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); + when(theatreServicePort.reserveSeats(booking.getTheatreId(), booking.getMovieShowId(), booking.getSeats())) + .thenReturn(Optional.of("reservation-id")); + when(walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) + .thenReturn(false); + BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); + + verify(bookingPersistencePort, times(2)).persist(any(Booking.class)); + verify(theatreServicePort).reserveSeats(any(String.class), any(String.class), any(HashSet.class)); + verify(walletServicePort).debit(any(String.class), any(Double.class)); + verify(theatreServicePort).releaseSeats(any(String.class)); + assertNotNull(response); + assertEquals(BookingServicePort.BookingResponse.PAYMENT_FAILED, response.getStatusCode()); + } + + @Test + void whenNoErrorInAnyPorts_thenReturnSuccess() { + BookingServicePort.BookingRequest request = getBookingRequest(); + Booking booking = getBooking(request); + when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); + when(theatreServicePort.reserveSeats(booking.getTheatreId(), booking.getMovieShowId(), booking.getSeats())) + .thenReturn(Optional.of("reservation-id")); + when(walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) + .thenReturn(true); + BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); + + verify(bookingPersistencePort, times(2)).persist(any(Booking.class)); + verify(theatreServicePort).reserveSeats(any(String.class), any(String.class), any(HashSet.class)); + verify(walletServicePort).debit(any(String.class), any(Double.class)); + assertNotNull(response); + assertEquals(BookingServicePort.BookingResponse.SUCCESS, response.getStatusCode()); + } +} \ No newline at end of file From c5b651fca0334a707e3cd8cd443b52ec35b0011e Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Fri, 9 Apr 2021 20:31:53 +0200 Subject: [PATCH 002/551] Update code to be more compact --- .../adapter/BookingPersistenceAdapter.java | 4 ++ .../adapter/RestAPIEndpointAdapter.java | 16 +++----- .../adapter/TheatreServiceAdapter.java | 17 ++++---- .../adapter/WalletServiceAdapter.java | 12 ++---- .../baeldung/hexagonal/domain/Booking.java | 41 ++++++++++--------- .../external/service/MockTheatreService.java | 8 ++-- .../external/service/TheatreService.java | 4 +- .../port/BookingPersistencePort.java | 1 + .../hexagonal/port/BookingServicePort.java | 18 ++++---- .../hexagonal/port/TheatreServicePort.java | 2 +- .../repository/BookingRepository.java | 1 + .../repository/MockBookingRepository.java | 5 +++ .../hexagonal/usecase/BookTicketUseCase.java | 34 ++++++--------- .../RestAPIEndpointAdapterUnitTest.java | 7 ++-- .../usecase/BookTicketUseCaseUnitTest.java | 41 ++++++++----------- 15 files changed, 97 insertions(+), 114 deletions(-) diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java index e6d4dbbe36..1b191bde86 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java @@ -15,4 +15,8 @@ public class BookingPersistenceAdapter implements BookingPersistencePort { public boolean persist(Booking booking) { return bookingRepository.save(booking); } + + public boolean updateStatus(String bookingId, String status) { + return bookingRepository.updateStatus(bookingId, status); + } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java index 7c35f302c0..3e1b1fc90f 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java @@ -2,7 +2,6 @@ package com.baeldung.hexagonal.adapter; import com.baeldung.hexagonal.port.BookingServicePort; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -10,7 +9,9 @@ import org.springframework.web.bind.annotation.RestController; import static com.baeldung.hexagonal.port.BookingServicePort.BookingRequest; import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse; -import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; +import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.SUCCESS; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.FAILED_DEPENDENCY; @RestController public class RestAPIEndpointAdapter { @@ -25,14 +26,7 @@ public class RestAPIEndpointAdapter { @PostMapping(path = "/booking") public ResponseEntity createBooking(@RequestBody BookingRequest request) { BookingResponse response = bookingServicePort.book(request); - - if (response.getStatusCode() == SEAT_NOT_AVAILABLE - || response.getStatusCode() == PAYMENT_FAILED){ - return new ResponseEntity(response, HttpStatus.PRECONDITION_FAILED); - } else if (response.getStatusCode() == UNKNOWN_ERROR) { - return new ResponseEntity(response, HttpStatus.INTERNAL_SERVER_ERROR); - } - - return new ResponseEntity(response, HttpStatus.CREATED); + return new ResponseEntity<>(response, + response.getStatusCode() == SUCCESS ? CREATED : FAILED_DEPENDENCY); } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java index d644f5eee0..fa19483b13 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java @@ -3,29 +3,28 @@ package com.baeldung.hexagonal.adapter; import com.baeldung.hexagonal.external.service.TheatreService; import com.baeldung.hexagonal.port.TheatreServicePort; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import java.util.Optional; import java.util.Set; +import static com.baeldung.hexagonal.external.service.TheatreService.Reservation; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.NO_CONTENT; + @Component public class TheatreServiceAdapter implements TheatreServicePort { @Autowired private TheatreService theatreService; - public Optional reserveSeats(String theatreId, String movieShowId, Set seats) { - ResponseEntity response = theatreService.postReservation(theatreId, movieShowId, seats); - if (response.getStatusCode() == HttpStatus.CREATED) { - return Optional.of(response.getBody().getId()); - } - return Optional.empty(); + public Optional reserveSeats(String movieShowId, Set seats) { + ResponseEntity response = theatreService.postReservation(movieShowId, seats); + return response.getStatusCode() == CREATED ? Optional.of(response.getBody().getId()): Optional.empty(); } public boolean releaseSeats(String resrevationId) { - ResponseEntity response = theatreService.deleteReservation(resrevationId); - return response.getStatusCode() == HttpStatus.NO_CONTENT; + return theatreService.deleteReservation(resrevationId).getStatusCode() == NO_CONTENT; } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java index 930b9c1cf6..1d8db867b7 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java @@ -3,21 +3,17 @@ package com.baeldung.hexagonal.adapter; import com.baeldung.hexagonal.external.service.CustomerWalletService; import com.baeldung.hexagonal.port.WalletServicePort; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import static org.springframework.http.HttpStatus.CREATED; + @Component public class WalletServiceAdapter implements WalletServicePort { - private final CustomerWalletService customerWalletService; - @Autowired - public WalletServiceAdapter(CustomerWalletService customerWalletService) { - this.customerWalletService = customerWalletService; - } + private CustomerWalletService customerWalletService; public boolean debit(String customerId, Double amount) { - HttpStatus response = customerWalletService.postDebit(customerId, amount); - return response == HttpStatus.CREATED; + return customerWalletService.postDebit(customerId, amount) == CREATED; } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java b/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java index 34e3f3b81b..ed9b7281f2 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java @@ -1,39 +1,46 @@ package com.baeldung.hexagonal.domain; +import com.baeldung.hexagonal.port.BookingServicePort; + import java.util.Set; +import java.util.UUID; public class Booking { + + public static final String STATUS_INITIAL = "INITIAL"; + public static final String STATUS_SUCCESS = "SUCCESS"; + public static final String STATUS_FAILURE = "FAILED"; + private String bookingId; private String movieShowId; - private String theatreId; private String customerId; private Set seats; private Double amount; - private Status status; - - public enum Status { - INITIAL, SUCCESS, FAILURE - } + private String status; public Booking( - String bookingId, String movieShowId, String theatreId, String customerId, Set seats, Double amount, Status status) { + String bookingId, String movieShowId, String customerId, Set seats, Double amount, String status) { this.bookingId = bookingId; this.movieShowId = movieShowId; - this.theatreId = theatreId; this.customerId = customerId; this.seats = seats; this.amount = amount; - this.status = Status.INITIAL; + this.status = status; + } + + public Booking(BookingServicePort.BookingRequest request) { + this.bookingId = UUID.randomUUID().toString(); + this.movieShowId = request.getMovieShowId(); + this.customerId = request.getCustomerId(); + this.seats = request.getSeats(); + this.amount = request.getAmount(); + this.status = STATUS_INITIAL; } public String getMovieShowId() { return movieShowId; } - public String getTheatreId() { - return theatreId; - } - public Set getSeats() { return seats; } @@ -50,7 +57,7 @@ public class Booking { return amount; } - public Status getStatus() { + public String getStatus() { return status; } @@ -62,10 +69,6 @@ public class Booking { this.movieShowId = movieShowId; } - public void setTheatreId(String theatreId) { - this.theatreId = theatreId; - } - public void setCustomerId(String customerId) { this.customerId = customerId; } @@ -78,7 +81,7 @@ public class Booking { this.amount = amount; } - public void setStatus(Status status) { + public void setStatus(String status) { this.status = status; } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java index 333cbee889..eb018e69b2 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java @@ -10,12 +10,12 @@ import java.util.UUID; @Service public class MockTheatreService implements TheatreService { - public ResponseEntity postReservation(String theatreId, String movieShowId, Set seats) { - return new ResponseEntity( + public ResponseEntity postReservation(String movieShowId, Set seats) { + return new ResponseEntity<>( new Reservation(UUID.randomUUID().toString()), HttpStatus.CREATED); } - public ResponseEntity deleteReservation(String reservationId) { - return new ResponseEntity(HttpStatus.NO_CONTENT); + public ResponseEntity deleteReservation(String reservationId) { + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java index 48f0c5e15d..8107bfb418 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java @@ -6,9 +6,9 @@ import java.util.Set; public interface TheatreService { - ResponseEntity postReservation(String theatreId, String movieShowId, Set seats); + ResponseEntity postReservation(String movieShowId, Set seats); - ResponseEntity deleteReservation(String reservationId); + ResponseEntity deleteReservation(String reservationId); class Reservation { private final String id; diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java index 0deffb42e0..c1d1d73630 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java @@ -4,4 +4,5 @@ import com.baeldung.hexagonal.domain.Booking; public interface BookingPersistencePort { boolean persist(Booking booking); + public boolean updateStatus(String bookingId, String status); } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java index 3b444df4f6..12710a6014 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java @@ -9,7 +9,6 @@ public interface BookingServicePort { class BookingRequest { private String movieShowId; private String customerId; - private String theatreId; private Set seats; private Double amount; @@ -29,14 +28,6 @@ public interface BookingServicePort { this.customerId = customerId; } - public String getTheatreId() { - return theatreId; - } - - public void setTheatreId(String theatreId) { - this.theatreId = theatreId; - } - public Set getSeats() { return seats; } @@ -61,6 +52,12 @@ public interface BookingServicePort { public static final int UNKNOWN_ERROR = 3; private final int statusCode; + private String bookingId; + + public BookingResponse(String bookingId, int statusCode) { + this.bookingId = bookingId; + this.statusCode = statusCode; + } public BookingResponse(int statusCode) { this.statusCode = statusCode; @@ -69,5 +66,8 @@ public interface BookingServicePort { public int getStatusCode() { return statusCode; } + public String getBookingId() { + return bookingId; + } } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java index dac517c724..8e5fab8b46 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java @@ -4,6 +4,6 @@ import java.util.Optional; import java.util.Set; public interface TheatreServicePort { - Optional reserveSeats(String theatreId, String movieShowId, Set seats); + Optional reserveSeats(String movieShowId, Set seats); boolean releaseSeats(String resrevationId); } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java b/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java index c56ffe1308..7dd20290ba 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java @@ -5,4 +5,5 @@ import com.baeldung.hexagonal.domain.Booking; public interface BookingRepository { boolean save(Booking booking); + boolean updateStatus(String bookingId, String status); } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java b/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java index d378cff0af..1738e606d0 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java @@ -8,4 +8,9 @@ public class MockBookingRepository implements BookingRepository { public boolean save(Booking booking) { return true; } + + @Override + public boolean updateStatus(String bookingId, String status) { + return true; + } } diff --git a/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java b/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java index 7d9db9724e..8d3112bd37 100644 --- a/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java +++ b/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java @@ -9,8 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Optional; -import java.util.UUID; +import static com.baeldung.hexagonal.domain.Booking.STATUS_FAILURE; +import static com.baeldung.hexagonal.domain.Booking.STATUS_SUCCESS; import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; @Component @@ -29,39 +30,28 @@ public class BookTicketUseCase implements BookingServicePort { public BookingResponse book(BookingRequest request) { - Booking booking = new Booking( - UUID.randomUUID().toString(), - request.getMovieShowId(), - request.getTheatreId(), - request.getCustomerId(), - request.getSeats(), - request.getAmount(), - Booking.Status.INITIAL); + Booking booking = new Booking(request); if (!bookingPersistencePort.persist(booking)) { return new BookingResponse(UNKNOWN_ERROR); } - Optional reservationIdOptional = theatreServicePort.reserveSeats( - booking.getTheatreId(), - booking.getMovieShowId(), - booking.getSeats()); + String bookingId = booking.getBookingId(); + + Optional reservationIdOptional = theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats()); if (!reservationIdOptional.isPresent()) { - booking.setStatus(Booking.Status.FAILURE); - bookingPersistencePort.persist(booking); - return new BookingResponse(SEAT_NOT_AVAILABLE); + bookingPersistencePort.updateStatus(bookingId, STATUS_FAILURE); + return new BookingResponse(bookingId, SEAT_NOT_AVAILABLE); } if (!walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) { reservationIdOptional.ifPresent(reservationId -> theatreServicePort.releaseSeats(reservationId)); - booking.setStatus(Booking.Status.FAILURE); - bookingPersistencePort.persist(booking); - return new BookingResponse(PAYMENT_FAILED); + bookingPersistencePort.updateStatus(bookingId, STATUS_FAILURE); + return new BookingResponse(bookingId, PAYMENT_FAILED); } - booking.setStatus(Booking.Status.SUCCESS); - bookingPersistencePort.persist(booking); + bookingPersistencePort.updateStatus(bookingId, STATUS_SUCCESS); - return new BookingResponse(SUCCESS); + return new BookingResponse(bookingId, SUCCESS); } } diff --git a/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java b/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java index 76d853fdda..cb22f5f37a 100644 --- a/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java +++ b/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java @@ -30,7 +30,6 @@ class RestAPIEndpointAdapterUnitTest { private BookingServicePort.BookingRequest getBookingRequest() { BookingServicePort.BookingRequest request = new BookingServicePort.BookingRequest(); - request.setTheatreId("theatre-id"); request.setMovieShowId("movie-show-id"); request.setCustomerId("customer-id"); request.setSeats(new HashSet<>(Arrays.asList("A1", "A2"))); @@ -47,7 +46,7 @@ class RestAPIEndpointAdapterUnitTest { verify(bookingServicePort).book(any(BookingRequest.class)); assertNotNull(response); - assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); + assertEquals(HttpStatus.FAILED_DEPENDENCY, response.getStatusCode()); } @Test @@ -59,7 +58,7 @@ class RestAPIEndpointAdapterUnitTest { verify(bookingServicePort).book(any(BookingRequest.class)); assertNotNull(response); - assertEquals(HttpStatus.PRECONDITION_FAILED, response.getStatusCode()); + assertEquals(HttpStatus.FAILED_DEPENDENCY, response.getStatusCode()); } @Test @@ -71,7 +70,7 @@ class RestAPIEndpointAdapterUnitTest { verify(bookingServicePort).book(any(BookingRequest.class)); assertNotNull(response); - assertEquals(HttpStatus.PRECONDITION_FAILED, response.getStatusCode()); + assertEquals(HttpStatus.FAILED_DEPENDENCY, response.getStatusCode()); } @Test diff --git a/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java b/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java index eec2b65609..ffb4246f79 100644 --- a/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java +++ b/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java @@ -34,7 +34,6 @@ class BookTicketUseCaseUnitTest { private BookingServicePort.BookingRequest getBookingRequest() { BookingServicePort.BookingRequest request = new BookingServicePort.BookingRequest(); - request.setTheatreId("theatre-id"); request.setMovieShowId("movie-show-id"); request.setCustomerId("customer-id"); request.setSeats(new HashSet<>(Arrays.asList("A1", "A2"))); @@ -42,21 +41,10 @@ class BookTicketUseCaseUnitTest { return request; } - private Booking getBooking(BookingServicePort.BookingRequest request) { - return new Booking( - "booking-id", - request.getMovieShowId(), - request.getTheatreId(), - request.getCustomerId(), - request.getSeats(), - request.getAmount(), - Booking.Status.INITIAL); - } - @Test void whenErrorInInitialPersistence_thenReturnUnknownError() { BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = getBooking(request); + Booking booking = new Booking(request); when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(false); BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); @@ -68,14 +56,15 @@ class BookTicketUseCaseUnitTest { @Test void whenErrorInReserveSeats_thenReturnSeatNotAvailable() { BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = getBooking(request); + Booking booking = new Booking(request); when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); - when(theatreServicePort.reserveSeats(booking.getTheatreId(), booking.getMovieShowId(), booking.getSeats())) + when(theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats())) .thenReturn(Optional.empty()); BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - verify(bookingPersistencePort, times(2)).persist(any(Booking.class)); - verify(theatreServicePort).reserveSeats(any(String.class), any(String.class), any(HashSet.class)); + verify(bookingPersistencePort).persist(any(Booking.class)); + verify(bookingPersistencePort).updateStatus(any(String.class), any(String.class)); + verify(theatreServicePort).reserveSeats(any(String.class), any(HashSet.class)); assertNotNull(response); assertEquals(BookingServicePort.BookingResponse.SEAT_NOT_AVAILABLE, response.getStatusCode()); } @@ -83,16 +72,17 @@ class BookTicketUseCaseUnitTest { @Test void whenErrorInWalletDebit_thenReturnPaymentFailed() { BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = getBooking(request); + Booking booking = new Booking(request); when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); - when(theatreServicePort.reserveSeats(booking.getTheatreId(), booking.getMovieShowId(), booking.getSeats())) + when(theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats())) .thenReturn(Optional.of("reservation-id")); when(walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) .thenReturn(false); BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - verify(bookingPersistencePort, times(2)).persist(any(Booking.class)); - verify(theatreServicePort).reserveSeats(any(String.class), any(String.class), any(HashSet.class)); + verify(bookingPersistencePort).persist(any(Booking.class)); + verify(bookingPersistencePort).updateStatus(any(String.class), any(String.class)); + verify(theatreServicePort).reserveSeats(any(String.class), any(HashSet.class)); verify(walletServicePort).debit(any(String.class), any(Double.class)); verify(theatreServicePort).releaseSeats(any(String.class)); assertNotNull(response); @@ -102,16 +92,17 @@ class BookTicketUseCaseUnitTest { @Test void whenNoErrorInAnyPorts_thenReturnSuccess() { BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = getBooking(request); + Booking booking = new Booking(request); when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); - when(theatreServicePort.reserveSeats(booking.getTheatreId(), booking.getMovieShowId(), booking.getSeats())) + when(theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats())) .thenReturn(Optional.of("reservation-id")); when(walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) .thenReturn(true); BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - verify(bookingPersistencePort, times(2)).persist(any(Booking.class)); - verify(theatreServicePort).reserveSeats(any(String.class), any(String.class), any(HashSet.class)); + verify(bookingPersistencePort).persist(any(Booking.class)); + verify(bookingPersistencePort).updateStatus(any(String.class), any(String.class)); + verify(theatreServicePort).reserveSeats( any(String.class), any(HashSet.class)); verify(walletServicePort).debit(any(String.class), any(Double.class)); assertNotNull(response); assertEquals(BookingServicePort.BookingResponse.SUCCESS, response.getStatusCode()); From d5c2b68a44474c87894923e06a6dea50beee601f Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Sun, 27 Jun 2021 18:51:48 +0200 Subject: [PATCH 003/551] JPA Entities and the Serializable Interface --- .../hibernate/serializable/Account.java | 41 ++++++++++ .../hibernate/serializable/Email.java | 38 ++++++++++ .../baeldung/hibernate/serializable/User.java | 36 +++++++++ .../hibernate/serializable/UserId.java | 27 +++++++ .../main/resources/META-INF/persistence.xml | 19 +++++ .../JPASerializableIntegrationTest.java | 76 +++++++++++++++++++ 6 files changed, 237 insertions(+) create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java create mode 100644 persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java new file mode 100644 index 0000000000..b051809ee5 --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java @@ -0,0 +1,41 @@ +package com.baeldung.hibernate.serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +@Entity +public class Account { + + @Id + private long id; + private String type; + @ManyToOne + @JoinColumn(referencedColumnName = "email") + private User user; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java new file mode 100644 index 0000000000..11e7c6f159 --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java @@ -0,0 +1,38 @@ +package com.baeldung.hibernate.serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; +import java.io.Serializable; + +@Entity +public class Email implements Serializable { + + @Id + private long id; + private String name; + private String domain; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java new file mode 100644 index 0000000000..e7820fe52f --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java @@ -0,0 +1,36 @@ +package com.baeldung.hibernate.serializable; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +@Entity +public class User { + + @EmbeddedId private UserId userId; + private Email email; + + + public User() { + } + + public User(UserId userId, Email email) { + this.userId = userId; + this.email = email; + } + + public UserId getUserId() { + return userId; + } + + public void setUserId(UserId userId) { + this.userId = userId; + } + + public Email getEmail() { + return email; + } + + public void setEmail(Email email) { + this.email = email; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java new file mode 100644 index 0000000000..7d3d382f67 --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java @@ -0,0 +1,27 @@ +package com.baeldung.hibernate.serializable; + +import javax.persistence.Embeddable; +import java.io.Serializable; + +@Embeddable +public class UserId implements Serializable { + + private String name; + private String lastName; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml index c2d5bf59ab..3482414b9d 100644 --- a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml @@ -100,4 +100,23 @@ + + + EntityManager serializable persistence unit + com.baeldung.hibernate.serializable.Email + com.baeldung.hibernate.serializable.Account + com.baeldung.hibernate.serializable.User + com.baeldung.hibernate.serializable.UserId + true + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java new file mode 100644 index 0000000000..d3b5a6ae7a --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java @@ -0,0 +1,76 @@ +package com.baeldung.hibernate.serializable; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import java.io.IOException; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class JPASerializableIntegrationTest { + + private static EntityManager entityManager; + + @Before + public void setUp() throws IOException { + EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("com.baeldung.hibernate.serializable.h2_persistence_unit"); + entityManager = entityManagerFactory.createEntityManager(); + entityManager.getTransaction().begin(); + } + + @Test + public void givenUser_whenPersisted_thenUserWillBeFoundById() { + UserId userId = new UserId(); + userId.setName("John"); + userId.setLastName("Doe"); + Email email = new Email(); + email.setId(1); + email.setName("johndoe"); + email.setDomain("gmail.com"); + User user = new User(userId, email); + + entityManager.persist(user); + + User userDb = entityManager.find(User.class, userId); + assertEquals(userDb.getEmail().getName(), "johndoe"); + } + +@Test +public void givenAssociation_whenPersisted_thenMultipleAccountsWillBeFoundByEmail() { + UserId userId = new UserId(); + userId.setName("John"); + userId.setLastName("Doe"); + Email email = new Email(); + email.setId(1); + email.setName("johndoe"); + email.setDomain("gmail.com"); + User user = new User(userId, email); + Account account = new Account(); + account.setType("test"); + account.setId(10); + account.setUser(user); + Account account2 = new Account(); + account2.setType("main"); + account2.setId(11); + account2.setUser(user); + + entityManager.persist(user); + entityManager.persist(account); + entityManager.persist(account2); + + List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") + .setParameter("email", email).getResultList(); + assertEquals(userAccounts.size(), 2); +} + + @After + public void tearDown() { + entityManager.close(); + } + +} From 860605b3e9395806440a1cd07204767527419b0b Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Wed, 30 Jun 2021 17:50:17 +0200 Subject: [PATCH 004/551] JPA Entities and the Serializable Interface - edit after review --- .../serializable/JPASerializableIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java index d3b5a6ae7a..5bbb7495d7 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java @@ -37,7 +37,7 @@ public class JPASerializableIntegrationTest { entityManager.persist(user); User userDb = entityManager.find(User.class, userId); - assertEquals(userDb.getEmail().getName(), "johndoe"); + assertEquals("johndoe", userDb.getEmail().getName()); } @Test @@ -65,7 +65,7 @@ public void givenAssociation_whenPersisted_thenMultipleAccountsWillBeFoundByEmai List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") .setParameter("email", email).getResultList(); - assertEquals(userAccounts.size(), 2); + assertEquals(2, userAccounts.size()); } @After From ec09e1293f86984a935156425814a2c5cf184c4e Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Thu, 1 Jul 2021 19:43:04 +0200 Subject: [PATCH 005/551] JPA Entities and the Serializable Interface - formatting --- .../JPASerializableIntegrationTest.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java index 5bbb7495d7..7dc315082b 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java @@ -40,33 +40,33 @@ public class JPASerializableIntegrationTest { assertEquals("johndoe", userDb.getEmail().getName()); } -@Test -public void givenAssociation_whenPersisted_thenMultipleAccountsWillBeFoundByEmail() { - UserId userId = new UserId(); - userId.setName("John"); - userId.setLastName("Doe"); - Email email = new Email(); - email.setId(1); - email.setName("johndoe"); - email.setDomain("gmail.com"); - User user = new User(userId, email); - Account account = new Account(); - account.setType("test"); - account.setId(10); - account.setUser(user); - Account account2 = new Account(); - account2.setType("main"); - account2.setId(11); - account2.setUser(user); + @Test + public void givenAssociation_whenPersisted_thenMultipleAccountsWillBeFoundByEmail() { + UserId userId = new UserId(); + userId.setName("John"); + userId.setLastName("Doe"); + Email email = new Email(); + email.setId(1); + email.setName("johndoe"); + email.setDomain("gmail.com"); + User user = new User(userId, email); + Account account = new Account(); + account.setType("test"); + account.setId(10); + account.setUser(user); + Account account2 = new Account(); + account2.setType("main"); + account2.setId(11); + account2.setUser(user); - entityManager.persist(user); - entityManager.persist(account); - entityManager.persist(account2); + entityManager.persist(user); + entityManager.persist(account); + entityManager.persist(account2); - List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") - .setParameter("email", email).getResultList(); - assertEquals(2, userAccounts.size()); -} + List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") + .setParameter("email", email).getResultList(); + assertEquals(2, userAccounts.size()); + } @After public void tearDown() { From fe5ea96f7605dca511a49b4cbbafd8a41fe00ae1 Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Fri, 2 Jul 2021 09:15:43 +0200 Subject: [PATCH 006/551] JPA Entities and the Serializable Interface - indentation --- .../hibernate/serializable/JPASerializableIntegrationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java index 7dc315082b..696bc23ab0 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java @@ -64,7 +64,8 @@ public class JPASerializableIntegrationTest { entityManager.persist(account2); List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") - .setParameter("email", email).getResultList(); + .setParameter("email", email) + .getResultList(); assertEquals(2, userAccounts.size()); } From 69be42810394a67831c0fae190fd541ae5633863 Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Thu, 29 Jul 2021 15:41:01 +0200 Subject: [PATCH 007/551] EntityNotFoundException in Hibernate --- .../entitynotfoundexception/Category.java | 42 +++++++++++++++++ .../entitynotfoundexception/Item.java | 44 ++++++++++++++++++ .../entitynotfoundexception/User.java | 28 ++++++++++++ .../main/resources/META-INF/persistence.xml | 18 ++++++++ ...ntityNotFoundExceptionIntegrationTest.java | 45 +++++++++++++++++++ 5 files changed, 177 insertions(+) create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java create mode 100644 persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java create mode 100644 persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java new file mode 100644 index 0000000000..25d31d50c7 --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java @@ -0,0 +1,42 @@ +package com.baeldung.hibernate.entitynotfoundexception; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@Entity +public class Category implements Serializable { + + @Id + @Column(unique = true, nullable = false) + private long id; + private String name; + @OneToMany + @JoinColumn(name = "category_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) + private List items = new ArrayList<>(); + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java new file mode 100644 index 0000000000..ee6f677d7d --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java @@ -0,0 +1,44 @@ +package com.baeldung.hibernate.entitynotfoundexception; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +public class Item implements Serializable { + + @Id + @Column(unique = true, nullable = false) + private long id; + private String name; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "category_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) + @NotFound(action = NotFoundAction.IGNORE) + private Category category; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java new file mode 100644 index 0000000000..d89047195c --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java @@ -0,0 +1,28 @@ +package com.baeldung.hibernate.entitynotfoundexception; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class User { + + @Id + private long id; + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml index 3482414b9d..29cd4faf05 100644 --- a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml @@ -119,4 +119,22 @@ + + + EntityManager EntityNotFoundException persistence unit + com.baeldung.hibernate.entitynotfoundexception.Category + com.baeldung.hibernate.entitynotfoundexception.Item + com.baeldung.hibernate.entitynotfoundexception.User + true + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java new file mode 100644 index 0000000000..bcb4e3eb95 --- /dev/null +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java @@ -0,0 +1,45 @@ +package com.baeldung.hibernate.entitynotfoundexception; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Persistence; +import java.io.IOException; + +public class EntityNotFoundExceptionIntegrationTest { + + private static EntityManager entityManager; + + @Before + public void setUp() throws IOException { + EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("com.baeldung.hibernate.entitynotfoundexception.h2_persistence_unit"); + entityManager = entityManagerFactory.createEntityManager(); + entityManager.getTransaction().begin(); + + } + + + @Test(expected = EntityNotFoundException.class) + public void givenNonExistingUserId_whenGetReferenceIsUsed_thenExceptionIsThrown() { + User user = entityManager.getReference(User.class, 1L); + user.getName(); + } + + @Test(expected = EntityNotFoundException.class) + public void givenItem_whenManyToOneEntityIsMissing_thenExceptionIsThrown() { + entityManager.createNativeQuery("Insert into Item (category_id, name, id) values (1, 'test', 1)").executeUpdate(); + entityManager.flush(); + Item item = entityManager.find(Item.class, 1L); + item.getCategory().getName(); + } + + @After + public void tearDown() { + entityManager.close(); + } + +} From 0372e0fba525a3fed2c73e1a319870c06a326a5f Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Mon, 2 Aug 2021 10:52:05 +0200 Subject: [PATCH 008/551] EntityNotFoundException in Hibernate - fix persistence unit config to allow multiple test to run in conjunction. --- .../com/baeldung/hibernate/entitynotfoundexception/Item.java | 1 - .../hibernate-jpa/src/main/resources/META-INF/persistence.xml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java index ee6f677d7d..3abed00eb8 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java @@ -15,7 +15,6 @@ public class Item implements Serializable { private String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @NotFound(action = NotFoundAction.IGNORE) private Category category; public long getId() { diff --git a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml index 29cd4faf05..e895ac6ba9 100644 --- a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml @@ -114,7 +114,7 @@ - + @@ -132,7 +132,7 @@ - + From f30118469ce192f9c4ba8514b42d5adfe9acf84b Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Tue, 31 Aug 2021 20:44:43 +0200 Subject: [PATCH 009/551] Connecting to a Specific Schema in JDBC --- persistence-modules/java-jpa-3/pom.xml | 6 ++ .../jpa/postgresql_schema/Product.java | 30 +++++++ .../main/resources/META-INF/persistence.xml | 11 +++ .../PostgresqlSchemaLiveTest.java | 85 +++++++++++++++++++ .../PostgresqlTestContainer.java | 22 +++++ 5 files changed, 154 insertions(+) create mode 100644 persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/postgresql_schema/Product.java create mode 100644 persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlSchemaLiveTest.java create mode 100644 persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlTestContainer.java diff --git a/persistence-modules/java-jpa-3/pom.xml b/persistence-modules/java-jpa-3/pom.xml index cecabc10cc..aef35b0547 100644 --- a/persistence-modules/java-jpa-3/pom.xml +++ b/persistence-modules/java-jpa-3/pom.xml @@ -74,6 +74,12 @@ ${junit.version} test + + org.testcontainers + postgresql + 1.16.0 + test + diff --git a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/postgresql_schema/Product.java b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/postgresql_schema/Product.java new file mode 100644 index 0000000000..cf74e8bb6d --- /dev/null +++ b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/postgresql_schema/Product.java @@ -0,0 +1,30 @@ +package com.baeldung.jpa.postgresql_schema; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "product", schema = "store") +public class Product { + + @Id + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml index 1166aaca71..ef1c4fb3d3 100644 --- a/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml @@ -149,4 +149,15 @@ + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.postgresql_schema.Product + true + + + + + + + diff --git a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlSchemaLiveTest.java b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlSchemaLiveTest.java new file mode 100644 index 0000000000..e46ea2892c --- /dev/null +++ b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlSchemaLiveTest.java @@ -0,0 +1,85 @@ +package com.baeldung.jpa.postgresql_schema; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.postgresql.ds.PGSimpleDataSource; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +public class PostgresqlSchemaLiveTest { + //This tests require running Docker application with working internet connection to fetch + //Postgres image if the image is not available locally. + + @ClassRule + public static PostgresqlTestContainer container = PostgresqlTestContainer.getInstance(); + + + @BeforeClass + public static void setup() throws Exception { + Properties properties = new Properties(); + properties.setProperty("user", container.getUsername()); + properties.setProperty("password", container.getPassword()); + Connection connection = DriverManager.getConnection(container.getJdbcUrl(), properties); + connection.createStatement().execute("CREATE SCHEMA store"); + connection.createStatement().execute("CREATE TABLE store.product(id SERIAL PRIMARY KEY, name VARCHAR(20))"); + connection.createStatement().execute("INSERT INTO store.product VALUES(1, 'test product')"); + } + + @Test + public void settingUpSchemaUsingJdbcURL() throws Exception { + Properties properties = new Properties(); + properties.setProperty("user", container.getUsername()); + properties.setProperty("password", container.getPassword()); + Connection connection = DriverManager.getConnection(container.getJdbcUrl().concat("¤tSchema=store"), properties); + + ResultSet resultSet = connection.createStatement().executeQuery("SELECT * FROM product"); + resultSet.next(); + + assertThat(resultSet.getInt(1), equalTo(1)); + assertThat(resultSet.getString(2), equalTo("test product")); + } + + @Test + public void settingUpSchemaUsingPGSimpleDataSource() throws Exception { + int port = Integer.parseInt(container.getJdbcUrl().substring(container.getJdbcUrl().lastIndexOf(":") + 1, container.getJdbcUrl().lastIndexOf("/"))); + PGSimpleDataSource ds = new PGSimpleDataSource(); + ds.setServerNames(new String[]{container.getHost()}); + ds.setPortNumbers(new int[]{port}); + ds.setUser(container.getUsername()); + ds.setPassword(container.getPassword()); + ds.setDatabaseName("test"); + ds.setCurrentSchema("store"); + + ResultSet resultSet = ds.getConnection().createStatement().executeQuery("SELECT * FROM product"); + resultSet.next(); + + assertThat(resultSet.getInt(1), equalTo(1)); + assertThat(resultSet.getString(2), equalTo("test product")); + } + + @Test + public void settingUpSchemaUsingTableAnnotation() { + Map props = new HashMap<>(); + props.put("hibernate.connection.url", container.getJdbcUrl()); + props.put("hibernate.connection.user", container.getUsername()); + props.put("hibernate.connection.password", container.getPassword()); + EntityManagerFactory emf = Persistence.createEntityManagerFactory("postgresql_schema_unit", props); + EntityManager entityManager = emf.createEntityManager(); + + Product product = entityManager.find(Product.class, 1); + + assertThat(product.getName(), equalTo("test product")); + } +} diff --git a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlTestContainer.java b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlTestContainer.java new file mode 100644 index 0000000000..edc84845c6 --- /dev/null +++ b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/postgresql_schema/PostgresqlTestContainer.java @@ -0,0 +1,22 @@ +package com.baeldung.jpa.postgresql_schema; + +import org.testcontainers.containers.PostgreSQLContainer; + +public class PostgresqlTestContainer extends PostgreSQLContainer { + + private static final String IMAGE_VERSION = "postgres"; + + private static PostgresqlTestContainer container; + + + private PostgresqlTestContainer() { + super(IMAGE_VERSION); + } + + public static PostgresqlTestContainer getInstance() { + if (container == null) { + container = new PostgresqlTestContainer(); + } + return container; + } +} From 29194d18e1bdff5fe39ac9db3ce56b5f2001e8aa Mon Sep 17 00:00:00 2001 From: Azhwani Date: Sun, 12 Sep 2021 13:13:51 +0200 Subject: [PATCH 010/551] init commit --- .../spring-security-web-mvc-custom/pom.xml | 1 + .../web/interceptor/LoggerInterceptor.java | 19 +++++++----- .../interceptor/SessionTimerInterceptor.java | 7 +++-- .../web/interceptor/UserInterceptor.java | 31 ++++++++++++------- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/spring-security-modules/spring-security-web-mvc-custom/pom.xml b/spring-security-modules/spring-security-web-mvc-custom/pom.xml index 539f83d7b8..533a1bf83d 100644 --- a/spring-security-modules/spring-security-web-mvc-custom/pom.xml +++ b/spring-security-modules/spring-security-web-mvc-custom/pom.xml @@ -175,6 +175,7 @@ 19.0 + 3.2.2 1.6.1 diff --git a/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/LoggerInterceptor.java b/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/LoggerInterceptor.java index b54fda5a82..669e4cb3c5 100644 --- a/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/LoggerInterceptor.java +++ b/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/LoggerInterceptor.java @@ -1,16 +1,18 @@ package com.baeldung.web.interceptor; -import com.google.common.base.Strings; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import java.util.Enumeration; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.Enumeration; -public class LoggerInterceptor extends HandlerInterceptorAdapter { +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import com.google.common.base.Strings; + +public class LoggerInterceptor implements HandlerInterceptor { private static Logger log = LoggerFactory.getLogger(LoggerInterceptor.class); @@ -50,7 +52,8 @@ public class LoggerInterceptor extends HandlerInterceptorAdapter { if (posted.length() > 1) posted.append("&"); final String curr = (String) e.nextElement(); - posted.append(curr).append("="); + posted.append(curr) + .append("="); if (curr.contains("password") || curr.contains("answer") || curr.contains("pwd")) { posted.append("*****"); } else { diff --git a/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/SessionTimerInterceptor.java b/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/SessionTimerInterceptor.java index 38e852305c..e7decc262f 100644 --- a/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/SessionTimerInterceptor.java +++ b/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/SessionTimerInterceptor.java @@ -8,10 +8,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; -public class SessionTimerInterceptor extends HandlerInterceptorAdapter { +public class SessionTimerInterceptor implements HandlerInterceptor { private static Logger log = LoggerFactory.getLogger(SessionTimerInterceptor.class); @@ -30,7 +30,8 @@ public class SessionTimerInterceptor extends HandlerInterceptorAdapter { request.setAttribute("executionTime", startTime); if (UserInterceptor.isUserLogged()) { session = request.getSession(); - log.info("Time since last request in this session: {} ms", System.currentTimeMillis() - request.getSession().getLastAccessedTime()); + log.info("Time since last request in this session: {} ms", System.currentTimeMillis() - request.getSession() + .getLastAccessedTime()); if (System.currentTimeMillis() - session.getLastAccessedTime() > MAX_INACTIVE_SESSION_TIME) { log.warn("Logging out, due to inactive session"); SecurityContextHolder.clearContext(); diff --git a/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/UserInterceptor.java b/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/UserInterceptor.java index cd64a20842..ad80571be6 100644 --- a/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/UserInterceptor.java +++ b/spring-security-modules/spring-security-web-mvc-custom/src/main/java/com/baeldung/web/interceptor/UserInterceptor.java @@ -1,18 +1,18 @@ package com.baeldung.web.interceptor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.SmartView; -import org.springframework.web.servlet.View; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -public class UserInterceptor extends HandlerInterceptorAdapter { +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.SmartView; +import org.springframework.web.servlet.View; + +public class UserInterceptor implements HandlerInterceptor { private static Logger log = LoggerFactory.getLogger(UserInterceptor.class); @@ -44,7 +44,9 @@ public class UserInterceptor extends HandlerInterceptorAdapter { */ private void addToModelUserDetails(HttpSession session) { log.info("================= addToModelUserDetails ============================"); - String loggedUsername = SecurityContextHolder.getContext().getAuthentication().getName(); + String loggedUsername = SecurityContextHolder.getContext() + .getAuthentication() + .getName(); session.setAttribute("username", loggedUsername); log.info("user(" + loggedUsername + ") session : " + session); log.info("================= addToModelUserDetails ============================"); @@ -56,7 +58,9 @@ public class UserInterceptor extends HandlerInterceptorAdapter { */ private void addToModelUserDetails(ModelAndView model) { log.info("================= addToModelUserDetails ============================"); - String loggedUsername = SecurityContextHolder.getContext().getAuthentication().getName(); + String loggedUsername = SecurityContextHolder.getContext() + .getAuthentication() + .getName(); model.addObject("loggedUsername", loggedUsername); log.trace("session : " + model.getModel()); log.info("================= addToModelUserDetails ============================"); @@ -76,7 +80,10 @@ public class UserInterceptor extends HandlerInterceptorAdapter { public static boolean isUserLogged() { try { - return !SecurityContextHolder.getContext().getAuthentication().getName().equals("anonymousUser"); + return !SecurityContextHolder.getContext() + .getAuthentication() + .getName() + .equals("anonymousUser"); } catch (Exception e) { return false; } From 72f31df7645278d711e6b17413f513b36f57e03e Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 18 Sep 2021 00:37:04 +0200 Subject: [PATCH 011/551] JAVA-7244 Review log statements for projects --- .../algorithms/caesarcipher/CaesarCipher.java | 7 ++++++- .../src/main/resources/logback.xml | 13 +++++++++++++ .../BreadthFirstSearchAlgorithm.java | 4 ++-- .../algorithms/suffixtree/SuffixTree.java | 8 ++++---- .../quadtree/QuadTreeSearchUnitTest.java | 12 ++++++------ .../suffixtree/SuffixTreeUnitTest.java | 16 ++++++++-------- .../olingo2/src/main/resources/logback.xml | 13 +++++++++++++ apache-shiro/src/main/resources/logback.xml | 13 +++++++++++++ .../src/test/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ jta/src/main/resources/resources | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ libraries-3/src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/log4j.properties | 1 + .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ reactor-core/src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../spring-boot-1/src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ .../src/main/resources/logback.xml | 13 +++++++++++++ spring-caching/src/main/resources/logback.xml | 13 +++++++++++++ 33 files changed, 378 insertions(+), 21 deletions(-) create mode 100644 algorithms-miscellaneous-6/src/main/resources/logback.xml create mode 100644 apache-olingo/olingo2/src/main/resources/logback.xml create mode 100644 apache-shiro/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-jndi/src/test/resources/logback.xml create mode 100644 core-java-modules/core-java-lambdas/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-lang-syntax/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-networking-3/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-nio-2/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-reflection-2/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-string-operations-2/src/main/resources/logback.xml create mode 100644 jta/src/main/resources/resources create mode 100644 kubernetes/k8s-admission-controller/src/main/resources/logback.xml create mode 100644 libraries-3/src/main/resources/logback.xml create mode 100644 libraries-security/src/main/resources/logback.xml create mode 100644 persistence-modules/hibernate5/src/main/resources/log4j.properties create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/logback.xml create mode 100644 persistence-modules/spring-mybatis/src/main/resources/logback.xml create mode 100644 persistence-modules/spring-persistence-simple/src/main/resources/logback.xml create mode 100644 reactor-core/src/main/resources/logback.xml create mode 100644 software-security/sql-injection-samples/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-1/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-data-2/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/main/resources/logback.xml create mode 100644 spring-boot-modules/spring-boot-properties/src/main/resources/logback.xml create mode 100644 spring-caching/src/main/resources/logback.xml diff --git a/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java index 5ee913d251..f14aa2b0d2 100644 --- a/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java +++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java @@ -1,11 +1,16 @@ package com.baeldung.algorithms.caesarcipher; import org.apache.commons.math3.stat.inference.ChiSquareTest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.stream.IntStream; public class CaesarCipher { + + private final Logger log = LoggerFactory.getLogger(CaesarCipher.class); + private static final char LETTER_A = 'a'; private static final char LETTER_Z = 'z'; private static final int ALPHABET_SIZE = LETTER_Z - LETTER_A + 1; @@ -72,7 +77,7 @@ public class CaesarCipher { private int probableOffset(double[] chiSquares) { int probableOffset = 0; for (int offset = 0; offset < chiSquares.length; offset++) { - System.out.println(String.format("Chi-Square for offset %d: %.2f", offset, chiSquares[offset])); + log.debug(String.format("Chi-Square for offset %d: %.2f", offset, chiSquares[offset])); if (chiSquares[offset] < chiSquares[probableOffset]) { probableOffset = offset; } diff --git a/algorithms-miscellaneous-6/src/main/resources/logback.xml b/algorithms-miscellaneous-6/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/algorithms-miscellaneous-6/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/algorithms-searching/src/main/java/com/baeldung/algorithms/breadthfirstsearch/BreadthFirstSearchAlgorithm.java b/algorithms-searching/src/main/java/com/baeldung/algorithms/breadthfirstsearch/BreadthFirstSearchAlgorithm.java index 9d301f9578..ef1c7393c8 100644 --- a/algorithms-searching/src/main/java/com/baeldung/algorithms/breadthfirstsearch/BreadthFirstSearchAlgorithm.java +++ b/algorithms-searching/src/main/java/com/baeldung/algorithms/breadthfirstsearch/BreadthFirstSearchAlgorithm.java @@ -16,7 +16,7 @@ public class BreadthFirstSearchAlgorithm { Tree currentNode; while (!queue.isEmpty()) { currentNode = queue.remove(); - LOGGER.info("Visited node with value: {}", currentNode.getValue()); + LOGGER.debug("Visited node with value: {}", currentNode.getValue()); if (currentNode.getValue().equals(value)) { return Optional.of(currentNode); @@ -37,7 +37,7 @@ public class BreadthFirstSearchAlgorithm { while (!queue.isEmpty()) { currentNode = queue.remove(); - LOGGER.info("Visited node with value: {}", currentNode.getValue()); + LOGGER.debug("Visited node with value: {}", currentNode.getValue()); if (currentNode.getValue().equals(value)) { return Optional.of(currentNode); diff --git a/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java b/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java index eb58c2bfab..5f6410533c 100644 --- a/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java +++ b/algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java @@ -23,7 +23,7 @@ public class SuffixTree { } public List searchText(String pattern) { - LOGGER.info("Searching for pattern \"{}\"", pattern); + LOGGER.debug("Searching for pattern \"{}\"", pattern); List result = new ArrayList<>(); List nodes = getAllNodesInTraversePath(pattern, root, false); @@ -41,11 +41,11 @@ public class SuffixTree { } private void addSuffix(String suffix, int position) { - LOGGER.info(">>>>>>>>>>>> Adding new suffix {}", suffix); + LOGGER.debug(">>>>>>>>>>>> Adding new suffix {}", suffix); List nodes = getAllNodesInTraversePath(suffix, root, true); if (nodes.size() == 0) { addChildNode(root, suffix, position); - LOGGER.info("{}", printTree()); + LOGGER.debug("{}", printTree()); } else { Node lastNode = nodes.remove(nodes.size() - 1); String newText = suffix; @@ -58,7 +58,7 @@ public class SuffixTree { newText = newText.substring(existingSuffixUptoLastNode.length()); } extendNode(lastNode, newText, position); - LOGGER.info("{}", printTree()); + LOGGER.debug("{}", printTree()); } } diff --git a/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java b/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java index 0b58ae9f14..c85f9d9a99 100644 --- a/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java +++ b/algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java @@ -27,16 +27,16 @@ public class QuadTreeSearchUnitTest { Point point = new Point(points[i][0], points[i][1]); quadTree.addPoint(point); } - LOGGER.info("\n" + quadTree.printTree("")); - LOGGER.info("=============================================="); + LOGGER.debug("\n" + quadTree.printTree("")); + LOGGER.debug("=============================================="); } @Test public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() { Region searchArea = new Region(200, 200, 250, 250); List result = quadTree.search(searchArea, null, ""); - LOGGER.info(result.toString()); - LOGGER.info(quadTree.printSearchTraversePath()); + LOGGER.debug(result.toString()); + LOGGER.debug(quadTree.printSearchTraversePath()); Assert.assertEquals(1, result.size()); Assert.assertArrayEquals(new float[] { 245, 238 }, @@ -47,8 +47,8 @@ public class QuadTreeSearchUnitTest { public void givenQuadTree_whenSearchingForRange_thenReturn2MatchingItems() { Region searchArea = new Region(0, 0, 100, 100); List result = quadTree.search(searchArea, null, ""); - LOGGER.info(result.toString()); - LOGGER.info(quadTree.printSearchTraversePath()); + LOGGER.debug(result.toString()); + LOGGER.debug(quadTree.printSearchTraversePath()); Assert.assertEquals(2, result.size()); Assert.assertArrayEquals(new float[] { 21, 25 }, diff --git a/algorithms-searching/src/test/java/com/baeldung/algorithms/suffixtree/SuffixTreeUnitTest.java b/algorithms-searching/src/test/java/com/baeldung/algorithms/suffixtree/SuffixTreeUnitTest.java index ef4a05a9a1..d9a4f2962c 100644 --- a/algorithms-searching/src/test/java/com/baeldung/algorithms/suffixtree/SuffixTreeUnitTest.java +++ b/algorithms-searching/src/test/java/com/baeldung/algorithms/suffixtree/SuffixTreeUnitTest.java @@ -24,7 +24,7 @@ public class SuffixTreeUnitTest { public void givenSuffixTree_whenSearchingForA_thenReturn6Matches() { List matches = suffixTree.searchText("a"); matches.stream() - .forEach(m -> LOGGER.info(m)); + .forEach(m -> LOGGER.debug(m)); Assert.assertArrayEquals(new String[] { "h[a]vanabanana", "hav[a]nabanana", "havan[a]banana", "havanab[a]nana", "havanaban[a]na", "havanabanan[a]" }, matches.toArray()); } @@ -32,7 +32,7 @@ public class SuffixTreeUnitTest { public void givenSuffixTree_whenSearchingForNab_thenReturn1Match() { List matches = suffixTree.searchText("nab"); matches.stream() - .forEach(m -> LOGGER.info(m)); + .forEach(m -> LOGGER.debug(m)); Assert.assertArrayEquals(new String[] { "hava[nab]anana" }, matches.toArray()); } @@ -40,7 +40,7 @@ public class SuffixTreeUnitTest { public void givenSuffixTree_whenSearchingForNag_thenReturnNoMatches() { List matches = suffixTree.searchText("nag"); matches.stream() - .forEach(m -> LOGGER.info(m)); + .forEach(m -> LOGGER.debug(m)); Assert.assertArrayEquals(new String[] {}, matches.toArray()); } @@ -48,7 +48,7 @@ public class SuffixTreeUnitTest { public void givenSuffixTree_whenSearchingForBanana_thenReturn2Matches() { List matches = suffixTree.searchText("ana"); matches.stream() - .forEach(m -> LOGGER.info(m)); + .forEach(m -> LOGGER.debug(m)); Assert.assertArrayEquals(new String[] { "hav[ana]banana", "havanab[ana]na", "havanaban[ana]" }, matches.toArray()); } @@ -56,7 +56,7 @@ public class SuffixTreeUnitTest { public void givenSuffixTree_whenSearchingForNa_thenReturn4Matches() { List matches = suffixTree.searchText("na"); matches.stream() - .forEach(m -> LOGGER.info(m)); + .forEach(m -> LOGGER.debug(m)); Assert.assertArrayEquals(new String[] { "hava[na]banana", "havanaba[na]na", "havanabana[na]" }, matches.toArray()); } @@ -64,14 +64,14 @@ public class SuffixTreeUnitTest { public void givenSuffixTree_whenSearchingForX_thenReturnNoMatches() { List matches = suffixTree.searchText("x"); matches.stream() - .forEach(m -> LOGGER.info(m)); + .forEach(m -> LOGGER.debug(m)); Assert.assertArrayEquals(new String[] {}, matches.toArray()); } private static void printTree() { suffixTree.printTree(); - LOGGER.info("\n" + suffixTree.printTree()); - LOGGER.info("=============================================="); + LOGGER.debug("\n" + suffixTree.printTree()); + LOGGER.debug("=============================================="); } } diff --git a/apache-olingo/olingo2/src/main/resources/logback.xml b/apache-olingo/olingo2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/apache-olingo/olingo2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/apache-shiro/src/main/resources/logback.xml b/apache-shiro/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/apache-shiro/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-jndi/src/test/resources/logback.xml b/core-java-modules/core-java-jndi/src/test/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-jndi/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-lambdas/src/main/resources/logback.xml b/core-java-modules/core-java-lambdas/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-lambdas/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-syntax/src/main/resources/logback.xml b/core-java-modules/core-java-lang-syntax/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-lang-syntax/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-networking-3/src/main/resources/logback.xml b/core-java-modules/core-java-networking-3/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-nio-2/src/main/resources/logback.xml b/core-java-modules/core-java-nio-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-nio-2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-reflection-2/src/main/resources/logback.xml b/core-java-modules/core-java-reflection-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-2/src/main/resources/logback.xml b/core-java-modules/core-java-string-operations-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-string-operations-2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/jta/src/main/resources/resources b/jta/src/main/resources/resources new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/jta/src/main/resources/resources @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/kubernetes/k8s-admission-controller/src/main/resources/logback.xml b/kubernetes/k8s-admission-controller/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/kubernetes/k8s-admission-controller/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/libraries-3/src/main/resources/logback.xml b/libraries-3/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/libraries-3/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/libraries-security/src/main/resources/logback.xml b/libraries-security/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/libraries-security/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/hibernate5/src/main/resources/log4j.properties b/persistence-modules/hibernate5/src/main/resources/log4j.properties new file mode 100644 index 0000000000..2173c5d96f --- /dev/null +++ b/persistence-modules/hibernate5/src/main/resources/log4j.properties @@ -0,0 +1 @@ +log4j.rootLogger=INFO, stdout diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/logback.xml b/persistence-modules/spring-boot-persistence-h2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-mybatis/src/main/resources/logback.xml b/persistence-modules/spring-mybatis/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/persistence-modules/spring-mybatis/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml b/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/reactor-core/src/main/resources/logback.xml b/reactor-core/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/reactor-core/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/software-security/sql-injection-samples/src/main/resources/logback.xml b/software-security/sql-injection-samples/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/software-security/sql-injection-samples/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-1/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-1/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-1/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-annotations/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-annotations/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data-2/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-data-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-data-2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-caching/src/main/resources/logback.xml b/spring-caching/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-caching/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file From 8854bcc5b0aa148404baa338e3afcbc05cb884cb Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Fri, 1 Oct 2021 12:42:21 +0200 Subject: [PATCH 012/551] Parallel Test Execution for JUnit 5 --- junit5/README.md | 6 +++ junit5/pom.xml | 36 +++++++++++++++ .../java/com/baeldung/junit5/A_UnitTest.java | 21 +++++++++ .../java/com/baeldung/junit5/B_UnitTest.java | 23 ++++++++++ .../java/com/baeldung/junit5/C_UnitTest.java | 45 +++++++++++++++++++ .../test/resources/junit-platform.properties | 4 ++ pom.xml | 1 + 7 files changed, 136 insertions(+) create mode 100644 junit5/README.md create mode 100644 junit5/pom.xml create mode 100644 junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java create mode 100644 junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java create mode 100644 junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java create mode 100644 junit5/src/test/resources/junit-platform.properties diff --git a/junit5/README.md b/junit5/README.md new file mode 100644 index 0000000000..ad16ad164d --- /dev/null +++ b/junit5/README.md @@ -0,0 +1,6 @@ +## JUnit5 + +This module contains articles about the JUnit 5 + +### Relevant Articles: + diff --git a/junit5/pom.xml b/junit5/pom.xml new file mode 100644 index 0000000000..b9804408a2 --- /dev/null +++ b/junit5/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + junit5 + junit5 + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + 8 + 8 + + + + + org.junit.jupiter + junit-jupiter-api + 5.8.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.8.1 + test + + + + \ No newline at end of file diff --git a/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java new file mode 100644 index 0000000000..e4ba59b22d --- /dev/null +++ b/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.junit5; + +import org.junit.jupiter.api.Test; + +public class A_UnitTest { + + @Test + public void first() throws Exception{ + System.out.println("Test A first() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test A first() end => " + Thread.currentThread().getName()); + } + + @Test + public void second() throws Exception{ + System.out.println("Test A second() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test A second() end => " + Thread.currentThread().getName()); + } + +} diff --git a/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java new file mode 100644 index 0000000000..2b195d2551 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.junit5; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + +public class B_UnitTest { + + @Test + public void first() throws Exception{ + System.out.println("Test B first() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test B first() end => " + Thread.currentThread().getName()); + } + + @Test + public void second() throws Exception{ + System.out.println("Test B second() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test B second() end => " + Thread.currentThread().getName()); + } + +} diff --git a/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java new file mode 100644 index 0000000000..ce545f6bee --- /dev/null +++ b/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java @@ -0,0 +1,45 @@ +package com.baeldung.junit5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.ResourceLock; + +import java.util.ArrayList; +import java.util.List; + +public class C_UnitTest { + + private List resources; + + @BeforeEach + void before() { + resources = new ArrayList<>(); + resources.add("test"); + } + + @AfterEach + void after() { + resources.clear(); + } + + @Test + @ResourceLock(value = "resources") + public void first() throws Exception { + System.out.println("Test C first() start => " + Thread.currentThread().getName()); + resources.add("first"); + System.out.println(resources); + Thread.sleep(500); + System.out.println("Test C first() end => " + Thread.currentThread().getName()); + } + + @Test + @ResourceLock(value = "resources") + public void second() throws Exception { + System.out.println("Test C second() start => " + Thread.currentThread().getName()); + resources.add("second"); + System.out.println(resources); + Thread.sleep(500); + System.out.println("Test C second() end => " + Thread.currentThread().getName()); + } +} diff --git a/junit5/src/test/resources/junit-platform.properties b/junit5/src/test/resources/junit-platform.properties new file mode 100644 index 0000000000..42100f85da --- /dev/null +++ b/junit5/src/test/resources/junit-platform.properties @@ -0,0 +1,4 @@ +junit.jupiter.execution.parallel.enabled = true +junit.jupiter.execution.parallel.config.strategy=dynamic +junit.jupiter.execution.parallel.mode.default = concurrent +junit.jupiter.execution.parallel.mode.classes.default = concurrent diff --git a/pom.xml b/pom.xml index f5ac14a009..8d28669313 100644 --- a/pom.xml +++ b/pom.xml @@ -472,6 +472,7 @@ json-path jsoup jta + junit5 kubernetes ksqldb From ef8e084d6d540d2d01a73c15394e238f49c73589 Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Fri, 1 Oct 2021 13:04:07 +0200 Subject: [PATCH 013/551] Parallel Test Execution for JUnit 5 --- junit5/README.md | 6 +++ junit5/pom.xml | 36 +++++++++++++++ .../java/com/baeldung/junit5/A_UnitTest.java | 21 +++++++++ .../java/com/baeldung/junit5/B_UnitTest.java | 23 ++++++++++ .../java/com/baeldung/junit5/C_UnitTest.java | 45 +++++++++++++++++++ .../test/resources/junit-platform.properties | 4 ++ pom.xml | 1 + 7 files changed, 136 insertions(+) create mode 100644 junit5/README.md create mode 100644 junit5/pom.xml create mode 100644 junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java create mode 100644 junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java create mode 100644 junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java create mode 100644 junit5/src/test/resources/junit-platform.properties diff --git a/junit5/README.md b/junit5/README.md new file mode 100644 index 0000000000..ad16ad164d --- /dev/null +++ b/junit5/README.md @@ -0,0 +1,6 @@ +## JUnit5 + +This module contains articles about the JUnit 5 + +### Relevant Articles: + diff --git a/junit5/pom.xml b/junit5/pom.xml new file mode 100644 index 0000000000..b9804408a2 --- /dev/null +++ b/junit5/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + junit5 + junit5 + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + 8 + 8 + + + + + org.junit.jupiter + junit-jupiter-api + 5.8.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.8.1 + test + + + + \ No newline at end of file diff --git a/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java new file mode 100644 index 0000000000..e4ba59b22d --- /dev/null +++ b/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.junit5; + +import org.junit.jupiter.api.Test; + +public class A_UnitTest { + + @Test + public void first() throws Exception{ + System.out.println("Test A first() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test A first() end => " + Thread.currentThread().getName()); + } + + @Test + public void second() throws Exception{ + System.out.println("Test A second() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test A second() end => " + Thread.currentThread().getName()); + } + +} diff --git a/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java new file mode 100644 index 0000000000..2b195d2551 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.junit5; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + +public class B_UnitTest { + + @Test + public void first() throws Exception{ + System.out.println("Test B first() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test B first() end => " + Thread.currentThread().getName()); + } + + @Test + public void second() throws Exception{ + System.out.println("Test B second() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("Test B second() end => " + Thread.currentThread().getName()); + } + +} diff --git a/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java new file mode 100644 index 0000000000..ce545f6bee --- /dev/null +++ b/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java @@ -0,0 +1,45 @@ +package com.baeldung.junit5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.ResourceLock; + +import java.util.ArrayList; +import java.util.List; + +public class C_UnitTest { + + private List resources; + + @BeforeEach + void before() { + resources = new ArrayList<>(); + resources.add("test"); + } + + @AfterEach + void after() { + resources.clear(); + } + + @Test + @ResourceLock(value = "resources") + public void first() throws Exception { + System.out.println("Test C first() start => " + Thread.currentThread().getName()); + resources.add("first"); + System.out.println(resources); + Thread.sleep(500); + System.out.println("Test C first() end => " + Thread.currentThread().getName()); + } + + @Test + @ResourceLock(value = "resources") + public void second() throws Exception { + System.out.println("Test C second() start => " + Thread.currentThread().getName()); + resources.add("second"); + System.out.println(resources); + Thread.sleep(500); + System.out.println("Test C second() end => " + Thread.currentThread().getName()); + } +} diff --git a/junit5/src/test/resources/junit-platform.properties b/junit5/src/test/resources/junit-platform.properties new file mode 100644 index 0000000000..42100f85da --- /dev/null +++ b/junit5/src/test/resources/junit-platform.properties @@ -0,0 +1,4 @@ +junit.jupiter.execution.parallel.enabled = true +junit.jupiter.execution.parallel.config.strategy=dynamic +junit.jupiter.execution.parallel.mode.default = concurrent +junit.jupiter.execution.parallel.mode.classes.default = concurrent diff --git a/pom.xml b/pom.xml index f5ac14a009..8d28669313 100644 --- a/pom.xml +++ b/pom.xml @@ -472,6 +472,7 @@ json-path jsoup jta + junit5 kubernetes ksqldb From c85be323470cdd25d82de9ffad2cfd56543bec4a Mon Sep 17 00:00:00 2001 From: Shashank Date: Wed, 13 Oct 2021 09:54:36 +0530 Subject: [PATCH 014/551] Spring Boot 2.5.x compatible updates in spring-security-acl --- .../src/main/resources/com.baeldung.acl.datasource.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-modules/spring-security-acl/src/main/resources/com.baeldung.acl.datasource.properties b/spring-security-modules/spring-security-acl/src/main/resources/com.baeldung.acl.datasource.properties index 40f1e6ef38..7a08528f2d 100644 --- a/spring-security-modules/spring-security-acl/src/main/resources/com.baeldung.acl.datasource.properties +++ b/spring-security-modules/spring-security-acl/src/main/resources/com.baeldung.acl.datasource.properties @@ -8,5 +8,5 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect spring.h2.console.path=/myconsole spring.h2.console.enabled=true spring.datasource.initialize=true -spring.datasource.schema=classpath:acl-schema.sql -spring.datasource.data=classpath:acl-data.sql \ No newline at end of file +spring.sql.init.schema-locations=classpath:acl-schema.sql +spring.sql.init.data-locations=classpath:acl-data.sql \ No newline at end of file From d4dbc6a526ea171e895f7a8375746929dc1eb774 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 13 Oct 2021 23:45:08 +0800 Subject: [PATCH 015/551] Create README.md --- maven-modules/maven-generate-war/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 maven-modules/maven-generate-war/README.md diff --git a/maven-modules/maven-generate-war/README.md b/maven-modules/maven-generate-war/README.md new file mode 100644 index 0000000000..1e74a087ae --- /dev/null +++ b/maven-modules/maven-generate-war/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Generate a WAR File in Maven](https://www.baeldung.com/maven-generate-war-file) From 68e0a1a0940d860bd8be711bd2a802af77f64d1e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 13 Oct 2021 23:47:53 +0800 Subject: [PATCH 016/551] Update README.md --- quarkus-vs-springboot/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quarkus-vs-springboot/README.md b/quarkus-vs-springboot/README.md index 35fc8eb5eb..05eaabb923 100644 --- a/quarkus-vs-springboot/README.md +++ b/quarkus-vs-springboot/README.md @@ -92,4 +92,8 @@ Then, once again, you can also run both application and DB from docker, using: docker-compose -f src/main/docker/quarkus.yml up ``` -Now you have all you need to reproduce the tests with your machine. \ No newline at end of file +Now you have all you need to reproduce the tests with your machine. + +### Relevant Articles: + +- [Spring Boot vs Quarkus](https://www.baeldung.com/spring-boot-vs-quarkus) From d64b8f1b2cc5397a74a315f5c5815f2ecd6c1864 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 13 Oct 2021 23:55:55 +0800 Subject: [PATCH 017/551] Update README.md --- core-java-modules/core-java-annotations/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-annotations/README.md b/core-java-modules/core-java-annotations/README.md index 18f5589771..a8a9ac3b16 100644 --- a/core-java-modules/core-java-annotations/README.md +++ b/core-java-modules/core-java-annotations/README.md @@ -12,3 +12,4 @@ - [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency) - [Why Missing Annotations Don’t Cause ClassNotFoundException](https://www.baeldung.com/classnotfoundexception-missing-annotation) - [Valid @SuppressWarnings Warning Names](https://www.baeldung.com/java-suppresswarnings-valid-names) +- [Get a Field’s Annotations Using Reflection](https://www.baeldung.com/java-get-field-annotations) From 2dfdb515922a1f0be1be7af1fef7c03592d24b10 Mon Sep 17 00:00:00 2001 From: lucaCambi77 Date: Wed, 13 Oct 2021 18:21:35 +0200 Subject: [PATCH 018/551] feat: env variable prefixes spring boot app (#11323) --- .../baeldung/prefix/PrefixApplication.java | 14 ++++++++++++++ .../com/baeldung/prefix/PrefixController.java | 19 +++++++++++++++++++ .../src/main/resources/templates/prefix.html | 9 +++++++++ 3 files changed, 42 insertions(+) create mode 100644 spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixApplication.java create mode 100644 spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixController.java create mode 100644 spring-boot-modules/spring-boot-environment/src/main/resources/templates/prefix.html diff --git a/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixApplication.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixApplication.java new file mode 100644 index 0000000000..29fe3d8930 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixApplication.java @@ -0,0 +1,14 @@ +package com.baeldung.prefix; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PrefixApplication { + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(PrefixApplication.class); + application.setEnvironmentPrefix("prefix"); + application.run(args); + } +} diff --git a/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixController.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixController.java new file mode 100644 index 0000000000..00b728c7ae --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/prefix/PrefixController.java @@ -0,0 +1,19 @@ +package com.baeldung.prefix; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class PrefixController { + + @Value(value = "${server.port}") + private int serverPort; + + @GetMapping("/prefix") + public String getServerPortInfo(final Model model) { + model.addAttribute("serverPort", serverPort); + return "prefix"; + } +} diff --git a/spring-boot-modules/spring-boot-environment/src/main/resources/templates/prefix.html b/spring-boot-modules/spring-boot-environment/src/main/resources/templates/prefix.html new file mode 100644 index 0000000000..7bb5a76537 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/main/resources/templates/prefix.html @@ -0,0 +1,9 @@ + + + + Prefix Example Page + + +It is working as we expected. Your server is running at port : + + \ No newline at end of file From 1c38ab94a1d3c67c2fc47789401ee8c9d127a9ad Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Azam Khan Date: Thu, 14 Oct 2021 01:15:13 +0400 Subject: [PATCH 019/551] 415 Unsupported Media Type 1. Basic user controller added 2. POST API explains the how to support differnet content-type formats --- .../UnsupportedMediaTypeApplication.java | 13 ++++ .../baeldung/unsupportedmediatype/User.java | 61 +++++++++++++++++++ .../unsupportedmediatype/UserController.java | 29 +++++++++ 3 files changed, 103 insertions(+) create mode 100644 spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java create mode 100644 spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java create mode 100644 spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UserController.java diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java new file mode 100644 index 0000000000..ccc136ef86 --- /dev/null +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.unsupportedmediatype; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class UnsupportedMediaTypeApplication { + + public static void main(String[] args) { + SpringApplication.run(UnsupportedMediaTypeApplication.class, args); + } + +} diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java new file mode 100644 index 0000000000..74a6f4383b --- /dev/null +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java @@ -0,0 +1,61 @@ +package com.baeldung.unsupportedmediatype; + +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +@XmlRootElement +public class User implements Serializable { + private Integer id; + private String name; + private Integer age; + private String address; + + public User(Integer id, String name, Integer age, String address){ + this.id = id; + this.name = name; + this.age = age; + this.address = address; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + + ", name='" + name + '\'' + + ", age=" + age + + ", address='" + address + '\'' + + '}'; + } +} diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UserController.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UserController.java new file mode 100644 index 0000000000..a20043619a --- /dev/null +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UserController.java @@ -0,0 +1,29 @@ +package com.baeldung.unsupportedmediatype; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +import java.util.Collections; +import java.util.List; + +@RestController +@RequestMapping("/user") +public class UserController { + + @GetMapping(value = "/") + List getAllUsers(){ + return Collections.singletonList(new User(1, "Andy", 28, "14th Street")); + } + + @GetMapping(value = "/{user-id}") + User getUser(@PathVariable("user-id") Integer userId){ + return new User(userId, "Andy", 28, "14th Street"); + } + + @PostMapping(value = "/", consumes = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) + void AddUser(@RequestBody User user){ + // Adding the User in the repository + } + + +} \ No newline at end of file From bfde84589c28e90e6ac595d1df4f5c9424cc9959 Mon Sep 17 00:00:00 2001 From: Shashank Date: Wed, 13 Oct 2021 19:17:31 +0530 Subject: [PATCH 020/551] Spring Boot 2.5.x compatible updates in spring-security-web-boot-2 --- .../src/main/resources/application-mysql.properties | 5 ++--- .../src/main/resources/application-postgre.properties | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-mysql.properties b/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-mysql.properties index 568d0c5ca3..0b81b046fb 100644 --- a/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-mysql.properties +++ b/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-mysql.properties @@ -1,9 +1,8 @@ -spring.datasource.platform=mysql +spring.sql.init.platform=mysql spring.datasource.url=jdbc:mysql://localhost:3306/jdbc_authentication spring.datasource.username=root spring.datasource.password=pass -spring.datasource.initialization-mode=always +spring.sql.init.mode=always spring.jpa.hibernate.ddl-auto=none -spring.profiles.active=mysql diff --git a/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-postgre.properties b/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-postgre.properties index 69faece45e..e37aec231a 100644 --- a/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-postgre.properties +++ b/spring-security-modules/spring-security-web-boot-2/src/main/resources/application-postgre.properties @@ -1,7 +1,7 @@ -spring.datasource.platform=postgre +spring.sql.init.platform=postgre spring.datasource.url=jdbc:postgresql://localhost:5432/jdbc_authentication spring.datasource.username=postgres spring.datasource.password=pass -spring.datasource.initialization-mode=always +spring.sql.init.mode=always spring.jpa.hibernate.ddl-auto=none From 47abbf654b5bee31721b9d40d0115471b114142d Mon Sep 17 00:00:00 2001 From: psevestre Date: Thu, 14 Oct 2021 01:04:19 -0300 Subject: [PATCH 021/551] BAEL-772 Reactive Streams API with Ratpack (#11328) * [BAEL-4849] Article code * [BAEL-4968] Article code * [BAEL-4968] Article code * [BAEL-4968] Article code * [BAEL-4968] Remove extra comments * [BAEL-4020] Article code * [BAEL-722] Article code --- .../main/java/com/baeldung/model/Quote.java | 107 +++++++++ .../rxjava/service/QuotesService.java | 44 ++++ .../spring/EmbedRatpackStreamsApp.java | 206 ++++++++++++++++++ .../baeldung/ratpack/CompliantPublisher.java | 63 ++++++ .../baeldung/ratpack/LoggingSubscriber.java | 67 ++++++ .../ratpack/NonCompliantPublisher.java | 46 ++++ .../ratpack/RatpackStreamsUnitTest.java | 140 ++++++++++++ 7 files changed, 673 insertions(+) create mode 100644 ratpack/src/main/java/com/baeldung/model/Quote.java create mode 100644 ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java create mode 100644 ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java create mode 100644 ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java create mode 100644 ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java create mode 100644 ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java create mode 100644 ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java diff --git a/ratpack/src/main/java/com/baeldung/model/Quote.java b/ratpack/src/main/java/com/baeldung/model/Quote.java new file mode 100644 index 0000000000..009a85fa11 --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/model/Quote.java @@ -0,0 +1,107 @@ +package com.baeldung.model; + +import java.time.Instant; + +public class Quote { + + private Instant ts; + private String symbol; + private double value; + + public Quote() {} + + + public Quote(Instant ts, String symbol, double value) { + this.ts = ts; + this.symbol = symbol; + this.value = value; + } + + + /** + * @return the ts + */ + public Instant getTs() { + return ts; + } + + /** + * @param ts the ts to set + */ + public void setTs(Instant ts) { + this.ts = ts; + } + + /** + * @return the symbol + */ + public String getSymbol() { + return symbol; + } + + /** + * @param symbol the symbol to set + */ + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + /** + * @return the value + */ + public double getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(double value) { + this.value = value; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((symbol == null) ? 0 : symbol.hashCode()); + result = prime * result + ((ts == null) ? 0 : ts.hashCode()); + long temp; + temp = Double.doubleToLongBits(value); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Quote other = (Quote) obj; + if (symbol == null) { + if (other.symbol != null) + return false; + } else if (!symbol.equals(other.symbol)) + return false; + if (ts == null) { + if (other.ts != null) + return false; + } else if (!ts.equals(other.ts)) + return false; + if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) + return false; + return true; + } + + + @Override + public String toString() { + return "Quote [ts=" + ts + ", symbol=" + symbol + ", value=" + value + "]"; + } + + +} diff --git a/ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java b/ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java new file mode 100644 index 0000000000..7c073ee1de --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java @@ -0,0 +1,44 @@ +package com.baeldung.rxjava.service; + +import java.time.Duration; +import java.time.Instant; +import java.util.Random; +import java.util.concurrent.ScheduledExecutorService; + +import org.reactivestreams.Publisher; + +import com.baeldung.model.Quote; + +import ratpack.stream.Streams; + +public class QuotesService { + + private final ScheduledExecutorService executorService; + private static Random rnd = new Random(); + private static String[] symbols = new String[] { + "MSFT", + "ORCL", + "GOOG", + "AAPL", + "CSCO" + }; + + public QuotesService(ScheduledExecutorService executorService) { + this.executorService = executorService; + } + + public Publisher newTicker() { + return Streams.periodically(executorService, Duration.ofSeconds(2), (t) -> { + + return randomQuote(); + }); + } + + private static Quote randomQuote() { + return new Quote ( + Instant.now(), + symbols[rnd.nextInt(symbols.length)], + Math.round(rnd.nextDouble()*100) + ); + } +} diff --git a/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java b/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java new file mode 100644 index 0000000000..dc66efbecb --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java @@ -0,0 +1,206 @@ +package com.baeldung.spring; + +import java.util.Random; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicLong; + +import org.reactivestreams.Publisher; +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +import com.baeldung.model.Quote; +import com.baeldung.rxjava.service.QuotesService; + +import groovy.util.logging.Slf4j; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import ratpack.func.Action; +import ratpack.handling.Chain; +import ratpack.http.ResponseChunks; +import ratpack.http.Status; +import ratpack.server.ServerConfig; +import ratpack.spring.config.EnableRatpack; +import ratpack.sse.ServerSentEvents; +import ratpack.stream.Streams; +import ratpack.stream.TransformablePublisher; +import ratpack.websocket.WebSockets; +import rx.subscriptions.Subscriptions; + +/** + * @author psevestre + */ +@SpringBootApplication +@EnableRatpack +public class EmbedRatpackStreamsApp { + + private static final Logger log = LoggerFactory.getLogger(EmbedRatpackStreamsApp.class); + + @Autowired + private QuotesService quotesService; + + private AtomicLong idSeq = new AtomicLong(0); + + + @Bean + public ScheduledExecutorService executorService() { + return Executors.newScheduledThreadPool(1); + } + + @Bean + public QuotesService quotesService(ScheduledExecutorService executor) { + return new QuotesService(executor); + } + + @Bean + public Action quotes() { + ServerSentEvents sse = ServerSentEvents.serverSentEvents(quotesService.newTicker(), (evt) -> { + evt + .id(Long.toString(idSeq.incrementAndGet())) + .event("quote") + .data( q -> q.toString()); + }); + + return chain -> chain.get("quotes", ctx -> ctx.render(sse)); + } + + @Bean + public Action quotesWS() { + Publisher pub = Streams.transformable(quotesService.newTicker()) + .map(Quote::toString); + return chain -> chain.get("quotes-ws", ctx -> WebSockets.websocketBroadcast(ctx, pub)); + } + + @Bean + public Action uploadFile() { + + return chain -> chain.post("upload", ctx -> { + TransformablePublisher pub = ctx.getRequest().getBodyStream(); + pub.subscribe(new Subscriber() { + private Subscription sub; + @Override + public void onSubscribe(Subscription sub) { + this.sub = sub; + sub.request(1); + } + + @Override + public void onNext(ByteBuf t) { + try { + int len = t.readableBytes(); + log.info("Got {} bytes", len); + + // Do something useful with data + + // Request next chunk + sub.request(1); + } + finally { + // DO NOT FORGET to RELEASE ! + t.release(); + } + } + + @Override + public void onError(Throwable t) { + ctx.getResponse().status(500); + } + + @Override + public void onComplete() { + ctx.getResponse().status(202); + } + }); + }); + } + + @Bean + public Action download() { + return chain -> chain.get("download", ctx -> { + ctx.getResponse().sendStream(new RandomBytesPublisher(1024,512)); + }); + } + + @Bean + public Action downloadChunks() { + return chain -> chain.get("downloadChunks", ctx -> { + ctx.render(ResponseChunks.bufferChunks("application/octetstream", + new RandomBytesPublisher(1024,512))); + }); + } + + @Bean + public ServerConfig ratpackServerConfig() { + return ServerConfig + .builder() + .findBaseDir("public") + .build(); + } + + public static void main(String[] args) { + SpringApplication.run(EmbedRatpackStreamsApp.class, args); + } + + + public static class RandomBytesPublisher implements Publisher { + + private int bufCount; + private int bufSize; + private Random rnd = new Random(); + + + RandomBytesPublisher(int bufCount, int bufSize) { + this.bufCount = bufCount; + this.bufSize = bufSize; + } + + @Override + public void subscribe(Subscriber s) { + s.onSubscribe(new Subscription() { + + private boolean cancelled = false; + private boolean recurse; + private long requested = 0; + + @Override + public void request(long n) { + if ( bufCount == 0 ) { + s.onComplete(); + return; + } + + requested += n; + if ( recurse ) { + return; + } + + recurse = true; + try { + while ( requested-- > 0 && !cancelled && bufCount-- > 0 ) { + byte[] data = new byte[bufSize]; + rnd.nextBytes(data); + ByteBuf buf = Unpooled.wrappedBuffer(data); + s.onNext(buf); + } + } + finally { + recurse = false; + } + } + + @Override + public void cancel() { + cancelled = true; + } + }); + + } + } + +} diff --git a/ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java b/ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java new file mode 100644 index 0000000000..5526a630ff --- /dev/null +++ b/ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java @@ -0,0 +1,63 @@ +package com.baeldung.ratpack; + +import org.reactivestreams.Publisher; +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +// Non-thread safe !!! +class CompliantPublisher implements Publisher { + String name; + + private static final Logger log = LoggerFactory.getLogger(CompliantPublisher.class); + private long available; + + + public CompliantPublisher(long available) { + this.available = available; + } + + @Override + public void subscribe(Subscriber subscriber) { + log.info("subscribe"); + subscriber.onSubscribe(new CompliantSubscription(subscriber)); + + } + + + private class CompliantSubscription implements Subscription { + + private Subscriber subscriber; + private int recurseLevel; + private long requested; + private boolean cancelled; + + public CompliantSubscription(Subscriber subscriber) { + this.subscriber = subscriber; + } + + @Override + public void request(long n) { + log.info("request: requested={}, available={}", n, available); + requested += n; + if ( recurseLevel > 0 ) { + return; + } + + recurseLevel++; + for (int i = 0 ; i < (requested) && !cancelled && available > 0 ; i++, available-- ) { + subscriber.onNext(i); + } + subscriber.onComplete(); + } + + @Override + public void cancel() { + cancelled = true; + } + + } + +} \ No newline at end of file diff --git a/ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java b/ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java new file mode 100644 index 0000000000..0d58b7c05e --- /dev/null +++ b/ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java @@ -0,0 +1,67 @@ +package com.baeldung.ratpack; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class LoggingSubscriber implements Subscriber { + private static final Logger log = LoggerFactory.getLogger(LoggingSubscriber.class); + + private Subscription subscription; + private long requested; + private long received; + private CountDownLatch finished = new CountDownLatch(1); + + @Override + public void onComplete() { + log.info("onComplete: sub={}", subscription.hashCode()); + finished.countDown(); + } + + @Override + public void onError(Throwable t) { + log.error("Error: sub={}, message={}", subscription.hashCode(), t.getMessage(),t); + finished.countDown(); + } + + @Override + public void onNext(T value) { + log.info("onNext: sub={}, value={}", subscription.hashCode(), value); + this.received++; + this.requested++; + subscription.request(1); + } + + @Override + public void onSubscribe(Subscription sub) { + log.info("onSubscribe: sub={}", sub.hashCode()); + this.subscription = sub; + this.received = 0; + this.requested = 1; + sub.request(1); + } + + + public long getRequested() { + return requested; + } + + public long getReceived() { + return received; + } + + public void block() { + try { + finished.await(10, TimeUnit.SECONDS); + } + catch(InterruptedException iex) { + throw new RuntimeException(iex); + } + } + +} diff --git a/ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java b/ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java new file mode 100644 index 0000000000..03b94d429d --- /dev/null +++ b/ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java @@ -0,0 +1,46 @@ +package com.baeldung.ratpack; + +import org.reactivestreams.Publisher; +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class NonCompliantPublisher implements Publisher { + + private static final Logger log = LoggerFactory.getLogger(NonCompliantPublisher.class); + + @Override + public void subscribe(Subscriber subscriber) { + log.info("subscribe"); + subscriber.onSubscribe(new NonCompliantSubscription(subscriber)); + } + + private class NonCompliantSubscription implements Subscription { + private Subscriber subscriber; + private int recurseLevel = 0; + + public NonCompliantSubscription(Subscriber subscriber) { + this.subscriber = subscriber; + } + + @Override + public void request(long n) { + log.info("request: n={}", n); + if ( recurseLevel > 0 ) { + return; + } + + recurseLevel++; + for (int i = 0 ; i < (n + 5) ; i ++ ) { + subscriber.onNext(i); + } + subscriber.onComplete(); + } + + @Override + public void cancel() { + } + } +} \ No newline at end of file diff --git a/ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java b/ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java new file mode 100644 index 0000000000..54cc71c328 --- /dev/null +++ b/ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java @@ -0,0 +1,140 @@ +package com.baeldung.ratpack; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +import org.junit.jupiter.api.Test; +import org.reactivestreams.Publisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ratpack.exec.ExecResult; +import ratpack.func.Action; +import ratpack.stream.StreamEvent; +import ratpack.stream.Streams; +import ratpack.stream.TransformablePublisher; +import ratpack.test.exec.ExecHarness; + +public class RatpackStreamsUnitTest { + + private static Logger log = LoggerFactory.getLogger(RatpackStreamsUnitTest.class); + + @Test + public void whenPublish_thenSuccess() { + + Publisher pub = Streams.publish(Arrays.asList("hello", "hello again")); + LoggingSubscriber sub = new LoggingSubscriber(); + pub.subscribe(sub); + sub.block(); + } + + + @Test + public void whenYield_thenSuccess() { + + Publisher pub = Streams.yield((t) -> { + return t.getRequestNum() < 5 ? "hello" : null; + }); + + LoggingSubscriber sub = new LoggingSubscriber(); + pub.subscribe(sub); + sub.block(); + assertEquals(5, sub.getReceived()); + } + + @Test + public void whenPeriodic_thenSuccess() { + ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + Publisher pub = Streams.periodically(executor, Duration.ofSeconds(1), (t) -> { + return t < 5 ? String.format("hello %d",t): null; + }); + + LoggingSubscriber sub = new LoggingSubscriber(); + pub.subscribe(sub); + sub.block(); + assertEquals(5, sub.getReceived()); + } + + @Test + public void whenMap_thenSuccess() throws Exception { + + TransformablePublisher pub = Streams.yield( t -> { + return t.getRequestNum() < 5 ? t.getRequestNum() : null; + }) + .map(v -> String.format("item %d", v)); + + ExecResult> result = ExecHarness.yieldSingle((c) -> pub.toList() ); + assertTrue("should succeed", result.isSuccess()); + assertEquals("should have 5 items",5,result.getValue().size()); + } + + @Test + public void whenNonCompliantPublisherWithBuffer_thenSuccess() throws Exception { + + TransformablePublisher pub = Streams.transformable(new NonCompliantPublisher()) + .wiretap(new LoggingAction("before buffer")) + .buffer() + .wiretap(new LoggingAction("after buffer")) + .take(1); + + LoggingSubscriber sub = new LoggingSubscriber<>(); + pub.subscribe(sub); + sub.block(); + } + + @Test + public void whenNonCompliantPublisherWithoutBuffer_thenSuccess() throws Exception { + TransformablePublisher pub = Streams.transformable(new NonCompliantPublisher()) + .wiretap(new LoggingAction("")) + .take(1); + + LoggingSubscriber sub = new LoggingSubscriber<>(); + pub.subscribe(sub); + sub.block(); + } + +@Test +public void whenCompliantPublisherWithoutBatch_thenSuccess() throws Exception { + + TransformablePublisher pub = Streams.transformable(new CompliantPublisher(10)) + .wiretap(new LoggingAction("")); + + LoggingSubscriber sub = new LoggingSubscriber<>(); + pub.subscribe(sub); + sub.block(); +} + +@Test +public void whenCompliantPublisherWithBatch_thenSuccess() throws Exception { + + TransformablePublisher pub = Streams.transformable(new CompliantPublisher(10)) + .wiretap(new LoggingAction("before batch")) + .batch(5, Action.noop()) + .wiretap(new LoggingAction("after batch")); + + LoggingSubscriber sub = new LoggingSubscriber<>(); + pub.subscribe(sub); + sub.block(); +} + + private static class LoggingAction implements Action>{ + private final String label; + + public LoggingAction(String label) { + this.label = label; + } + + @Override + public void execute(StreamEvent e) throws Exception { + log.info("{}: event={}", label,e); + } + + } + +} From cd3868d8635de8c98e1ccdddafff0776982be62f Mon Sep 17 00:00:00 2001 From: Shashank Date: Thu, 14 Oct 2021 19:08:58 +0530 Subject: [PATCH 022/551] Spring Boot 2.5.x compatible updates in spring-boot-persistence --- .../src/test/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties index 07101ca2f5..d22bd38426 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties @@ -13,4 +13,4 @@ hibernate.cache.use_query_cache=true hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory spring.jpa.properties.hibernate.hbm2ddl.import_files=import_books.sql -spring.datasource.data=import_*_users.sql \ No newline at end of file +spring.sql.init.data-locations=import_*_users.sql \ No newline at end of file From 8c5391ca7534f68df0553f05050e36939ed9e210 Mon Sep 17 00:00:00 2001 From: Shashank Date: Thu, 14 Oct 2021 20:09:00 +0530 Subject: [PATCH 023/551] Spring Boot 2.5.x compatible updates in spring-data-jpa-repo --- .../com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java index 9e4b78dce3..fe02f79a56 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java @@ -21,7 +21,7 @@ import com.baeldung.boot.domain.Location; import com.baeldung.boot.domain.Store; @RunWith(SpringRunner.class) -@DataJpaTest(properties="spring.datasource.data=classpath:import_entities.sql") +@DataJpaTest(properties="spring.sql.init.data-locations=classpath:import_entities.sql") public class JpaRepositoriesIntegrationTest { @Autowired private LocationRepository locationRepository; From 47b27beae07d1fea2f1b4524a73dd9cb750aac43 Mon Sep 17 00:00:00 2001 From: Rafael Lopez Date: Thu, 14 Oct 2021 17:16:56 -0400 Subject: [PATCH 024/551] JAVA-2595: Update Cassandra articles --- .../spring-data-cassandra/pom.xml | 46 ++----------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index d21541abf8..e2b47ce024 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -16,46 +16,15 @@ - org.springframework.data - spring-data-cassandra - ${org.springframework.data.version} - - - org.springframework - spring-core - ${spring.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-context - ${spring.version} + org.springframework.boot + spring-boot-starter-data-cassandra + ${spring-boot-starter-data-cassandra.version} org.springframework spring-aop ${spring.version} - - org.springframework - spring-expression - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - org.springframework spring-test @@ -91,17 +60,10 @@ - - com.datastax.cassandra - cassandra-driver-core - ${cassandra-driver-core.version} - true - - 1.3.2.RELEASE - 2.1.5 + 1.3.2.RELEASE 2.1.9.2 2.1.9.2 2.0-0 From e2f8cdd817fb41f5cf9ece68e32151f4181139b0 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 15 Oct 2021 08:36:43 +0530 Subject: [PATCH 025/551] Serialization Validation initial commit Changes for Adding Tests Serialization Validation 1: Added utility Method. 2: Added Tests --- core-java-modules/core-java/pom.xml | 6 ++ .../com/baeldung/util/SerializationUtils.java | 29 +++++++ .../serialization/SerializationUnitTest.java | 79 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java create mode 100644 core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index db2b1edc70..00f26b0e0a 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -61,6 +61,11 @@ moneta ${javamoney.moneta.version} + + org.springframework + spring-core + ${spring.core.version} + @@ -187,6 +192,7 @@ 3.0.0-M1 1.8 1.8 + 4.3.20.RELEASE \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java new file mode 100644 index 0000000000..eb5eb6aac1 --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java @@ -0,0 +1,29 @@ +package com.baeldung.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class SerializationUtils { + + public static byte[] serialize(T obj) + throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(obj); + oos.close(); + return baos.toByteArray(); + } + + public static T deserialize(byte[] b, Class cl) + throws IOException, ClassNotFoundException { + ByteArrayInputStream bais = new ByteArrayInputStream(b); + ObjectInputStream ois = new ObjectInputStream(bais); + Object o = ois.readObject(); + return cl.cast(o); + } +} + diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java new file mode 100644 index 0000000000..9be174e42d --- /dev/null +++ b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java @@ -0,0 +1,79 @@ +package com.baeldung.serialization; + +import static org.junit.Assert.assertTrue; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.Test; + +public class SerializationUnitTest { + + @Test(expected = NotSerializableException.class) + public void whenSerializing_ThenThrowsError() throws IOException { + Address address = new Address(); + address.setHouseNumber(10); + FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt"); + try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { + objectOutputStream.writeObject(address); + } + } + + @Test(expected = ClassCastException.class) + public void whenSerializingUsingApacheCommons_ThenThrowsError() { + Address address = new Address(); + address.setHouseNumber(10); + SerializationUtils.serialize((Serializable) address); + } + + @Test + public void whenSerializingAndDeserializingUsingApacheCommons_ThenObjectIsTheSame() { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + byte[] serialize = SerializationUtils.serialize(p); + Person p2 = (Person) SerializationUtils.deserialize(serialize); + assertTrue(p2.getAge() == p.getAge()); + assertTrue(p2.getName().equals(p.getName())); + } + + @Test(expected = ClassCastException.class) + public void whenSerializingUsingSpringSerializationUtils_ThenThrowsError() { + Address address = new Address(); + address.setHouseNumber(10); + org.springframework.util.SerializationUtils.serialize((Serializable) address); + } + + @Test + public void whenSerializingAndDeserializingUsingSpringSerializationUtils_ThenObjectIsTheSame() { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + byte[] serialize = org.springframework.util.SerializationUtils.serialize(p); + Person p2 = (Person) org.springframework.util.SerializationUtils.deserialize(serialize); + assertTrue(p2.getAge() == p.getAge()); + assertTrue(p2.getName().equals(p.getName())); + } + + @Test(expected = ClassCastException.class) + public void whenSerializingUsingCustomSerializationUtils_ThenThrowsError() throws IOException { + Address address = new Address(); + address.setHouseNumber(10); + com.baeldung.util.SerializationUtils.serialize((Serializable) address); + } + + @Test + public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame() throws IOException, ClassNotFoundException { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + byte[] serialize = com.baeldung.util.SerializationUtils.serialize(p); + Person p2 = com.baeldung.util.SerializationUtils.deserialize(serialize, Person.class); + assertTrue(p2.getAge() == p.getAge()); + assertTrue(p2.getName().equals(p.getName())); + } +} From b63d7cc057c287b4c8ecb9b0ca384b9ac8886825 Mon Sep 17 00:00:00 2001 From: Shashank Date: Fri, 15 Oct 2021 08:56:39 +0530 Subject: [PATCH 026/551] autogen key code cleanup --- persistence-modules/spring-jdbc/README.md | 1 + persistence-modules/spring-jpa/README.md | 1 - .../MessageRepositoryJDBCTemplate.java | 38 ------------- .../MessageRepositorySimpleJDBCInsert.java | 29 ---------- .../main/resources/autogenkey-db.properties | 9 --- .../src/main/resources/autogenkey-schema.sql | 5 -- .../GetAutoGenKeyByJDBCIntTest.java | 55 ------------------- 7 files changed, 1 insertion(+), 137 deletions(-) delete mode 100644 spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java delete mode 100644 spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java delete mode 100644 spring-5/src/main/resources/autogenkey-db.properties delete mode 100644 spring-5/src/main/resources/autogenkey-schema.sql delete mode 100644 spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBCIntTest.java diff --git a/persistence-modules/spring-jdbc/README.md b/persistence-modules/spring-jdbc/README.md index 1433344b7a..437a1312da 100644 --- a/persistence-modules/spring-jdbc/README.md +++ b/persistence-modules/spring-jdbc/README.md @@ -4,3 +4,4 @@ - [Spring JDBC](https://www.baeldung.com/spring-jdbc-jdbctemplate) - [Spring JdbcTemplate Unit Testing](https://www.baeldung.com/spring-jdbctemplate-testing) - [Using a List of Values in a JdbcTemplate IN Clause](https://www.baeldung.com/spring-jdbctemplate-in-list) +- [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index 937890cd13..db70259005 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -6,7 +6,6 @@ - [Sorting with JPA](https://www.baeldung.com/jpa-sort) - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database) - [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) -- [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) - [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) - More articles: [[next -->]](/spring-jpa-2) diff --git a/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java b/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java deleted file mode 100644 index cf0dbe4681..0000000000 --- a/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.jdbc.autogenkey.repository; - -import java.sql.PreparedStatement; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.GeneratedKeyHolder; -import org.springframework.jdbc.support.KeyHolder; -import org.springframework.stereotype.Repository; - -@Repository -public class MessageRepositoryJDBCTemplate { - - @Autowired - JdbcTemplate jdbcTemplate; - - final String INSERT_MESSAGE_SQL = "insert into sys_message (message) values(?) "; - - public long insert(final String message) { - - KeyHolder keyHolder = new GeneratedKeyHolder(); - - jdbcTemplate.update(connection -> { - PreparedStatement ps = connection.prepareStatement(INSERT_MESSAGE_SQL); - ps.setString(1, message); - return ps; - }, keyHolder); - - return (long) keyHolder.getKey(); - } - - final String SELECT_BY_ID = "select message from sys_message where id = ?"; - - public String getMessageById(long id) { - return this.jdbcTemplate.queryForObject(SELECT_BY_ID, String.class, new Object[] { id }); - } - -} diff --git a/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java b/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java deleted file mode 100644 index 022ea29ed6..0000000000 --- a/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.jdbc.autogenkey.repository; - -import java.util.HashMap; -import java.util.Map; - -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.simple.SimpleJdbcInsert; -import org.springframework.stereotype.Repository; - -@Repository -public class MessageRepositorySimpleJDBCInsert { - - SimpleJdbcInsert messageInsert; - - @Autowired - public MessageRepositorySimpleJDBCInsert(DataSource dataSource) { - messageInsert = new SimpleJdbcInsert(dataSource).withTableName("sys_message").usingGeneratedKeyColumns("id"); - } - - public long insert(String message) { - Map parameters = new HashMap(1); - parameters.put("message", message); - Number newId = messageInsert.executeAndReturnKey(parameters); - return (long) newId; - } - -} diff --git a/spring-5/src/main/resources/autogenkey-db.properties b/spring-5/src/main/resources/autogenkey-db.properties deleted file mode 100644 index 3e1a088dc1..0000000000 --- a/spring-5/src/main/resources/autogenkey-db.properties +++ /dev/null @@ -1,9 +0,0 @@ -spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE -spring.datasource.username=sa -spring.datasource.password= -spring.datasource.driverClassName=org.h2.Driver -spring.jpa.hibernate.ddl-auto=create -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect - -spring.datasource.initialize=true -spring.datasource.schema=classpath:autogenkey-schema.sql diff --git a/spring-5/src/main/resources/autogenkey-schema.sql b/spring-5/src/main/resources/autogenkey-schema.sql deleted file mode 100644 index 925b27143c..0000000000 --- a/spring-5/src/main/resources/autogenkey-schema.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS sys_message ( - id bigint(20) NOT NULL AUTO_INCREMENT, - message varchar(100) NOT NULL, - PRIMARY KEY (id) -); \ No newline at end of file diff --git a/spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBCIntTest.java b/spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBCIntTest.java deleted file mode 100644 index 14d2fb736b..0000000000 --- a/spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBCIntTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.jdbc.autogenkey; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import com.baeldung.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate; -import com.baeldung.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert; - -@RunWith(SpringRunner.class) -@Ignore -public class GetAutoGenKeyByJDBCIntTest { - - @Configuration - @EnableAutoConfiguration - @PropertySource("classpath:autogenkey-db.properties") - @ComponentScan(basePackages = { "com.baeldung.jdbc.autogenkey.repository" }) - public static class SpringConfig { - - } - - @Autowired - MessageRepositorySimpleJDBCInsert messageRepositorySimpleJDBCInsert; - - @Autowired - MessageRepositoryJDBCTemplate messageRepositoryJDBCTemplate; - - final String MESSAGE_CONTENT = "Test"; - - @Test - public void insertJDBC_whenLoadMessageByKey_thenGetTheSameMessage() { - long key = messageRepositoryJDBCTemplate.insert(MESSAGE_CONTENT); - String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key); - - assertEquals(MESSAGE_CONTENT, loadedMessage); - - } - - @Test - public void insertSimpleInsert_whenLoadMessageKey_thenGetTheSameMessage() { - long key = messageRepositorySimpleJDBCInsert.insert(MESSAGE_CONTENT); - String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key); - - assertEquals(MESSAGE_CONTENT, loadedMessage); - } - -} From e0ca51411858c19c761eb42d8abb68bce0d088b7 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 15 Oct 2021 09:13:02 +0530 Subject: [PATCH 027/551] Method for validation of Serializable Objects Method for validation of Serializable Objects --- .../main/java/com/baeldung/util/SerializationUtils.java | 4 ++++ .../com/baeldung/serialization/SerializationUnitTest.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java index eb5eb6aac1..da884d0b9b 100644 --- a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java @@ -25,5 +25,9 @@ public class SerializationUtils { Object o = ois.readObject(); return cl.cast(o); } + + public static boolean isSerializable(Class it) { + return it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); + } } diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java index 9be174e42d..376bd370f5 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.serialization; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import java.io.FileOutputStream; import java.io.IOException; @@ -76,4 +77,11 @@ public class SerializationUnitTest { assertTrue(p2.getAge() == p.getAge()); assertTrue(p2.getName().equals(p.getName())); } + + @Test + public void whenSerializingUsingCustomSerializationUtils_ThanOk(){ + assertFalse(com.baeldung.util.SerializationUtils.isSerializable(Address.class)); + assertTrue(com.baeldung.util.SerializationUtils.isSerializable(Person.class)); + assertTrue(com.baeldung.util.SerializationUtils.isSerializable(Integer.class)); + } } From 40aa009be24b008c2b60ca633b82387c9e3b30b7 Mon Sep 17 00:00:00 2001 From: Shashank Date: Fri, 15 Oct 2021 09:16:33 +0530 Subject: [PATCH 028/551] Spring Boot 2.5.x compatible updates in spring-data-jpa-query --- .../src/main/resources/application-joins.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-query/src/main/resources/application-joins.properties b/persistence-modules/spring-data-jpa-query/src/main/resources/application-joins.properties index fe2270293b..5fc1fd78e0 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/resources/application-joins.properties +++ b/persistence-modules/spring-data-jpa-query/src/main/resources/application-joins.properties @@ -1 +1 @@ -spring.datasource.data=classpath:db/import_joins.sql +spring.sql.init.data-locations=classpath:db/import_joins.sql From df95f2e2a83ffad9de7fd698640ee3952059d76f Mon Sep 17 00:00:00 2001 From: Shashank Date: Fri, 15 Oct 2021 09:24:10 +0530 Subject: [PATCH 029/551] Spring Boot 2.5.x compatible updates in spring-data-jpa-query-2 --- .../spring/data/jpa/query/UserRepositoryIntegrationTest.java | 2 +- .../jpa/query/datetime/ArticleRepositoryIntegrationTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java index 0ede418acd..a9ab13feed 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java @@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @RunWith(SpringRunner.class) -@DataJpaTest(properties = "spring.datasource.data=classpath:insert_users.sql") +@DataJpaTest(properties = "spring.sql.init.data-locations=classpath:insert_users.sql") public class UserRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java index b1158b3dae..e00a340615 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) -@DataJpaTest(properties="spring.datasource.data=classpath:import_entities.sql") +@DataJpaTest(properties="spring.sql.init.data-locations=classpath:import_entities.sql") public class ArticleRepositoryIntegrationTest { @Autowired From 98528e849ea5376b6beda828391306a01554ecc8 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 15 Oct 2021 09:26:11 +0530 Subject: [PATCH 030/551] Style Correction Style Correction --- .../com/baeldung/util/SerializationUtils.java | 38 +++++++++---------- .../serialization/SerializationUnitTest.java | 5 ++- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java index da884d0b9b..7ebff1a113 100644 --- a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java @@ -9,25 +9,23 @@ import java.io.Serializable; public class SerializationUtils { - public static byte[] serialize(T obj) - throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(obj); - oos.close(); - return baos.toByteArray(); + public static byte[] serialize(T obj) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(obj); + oos.close(); + return baos.toByteArray(); } - - public static T deserialize(byte[] b, Class cl) - throws IOException, ClassNotFoundException { - ByteArrayInputStream bais = new ByteArrayInputStream(b); - ObjectInputStream ois = new ObjectInputStream(bais); - Object o = ois.readObject(); - return cl.cast(o); - } - - public static boolean isSerializable(Class it) { - return it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); - } -} + public static T deserialize(byte[] b, Class cl) + throws IOException, ClassNotFoundException { + ByteArrayInputStream bais = new ByteArrayInputStream(b); + ObjectInputStream ois = new ObjectInputStream(bais); + Object o = ois.readObject(); + return cl.cast(o); + } + + public static boolean isSerializable(Class it) { + return it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); + } +} diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java index 376bd370f5..b5795d362c 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java @@ -68,7 +68,8 @@ public class SerializationUnitTest { } @Test - public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame() throws IOException, ClassNotFoundException { + public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame() + throws IOException, ClassNotFoundException { Person p = new Person(); p.setAge(20); p.setName("Joe"); @@ -79,7 +80,7 @@ public class SerializationUnitTest { } @Test - public void whenSerializingUsingCustomSerializationUtils_ThanOk(){ + public void whenSerializingUsingCustomSerializationUtils_ThanOk() { assertFalse(com.baeldung.util.SerializationUtils.isSerializable(Address.class)); assertTrue(com.baeldung.util.SerializationUtils.isSerializable(Person.class)); assertTrue(com.baeldung.util.SerializationUtils.isSerializable(Integer.class)); From b5ed1148cc072f8bdf1bfd9c97a59dc5b82b4eac Mon Sep 17 00:00:00 2001 From: Shashank Date: Fri, 15 Oct 2021 09:46:03 +0530 Subject: [PATCH 031/551] Spring Boot 2.5.x compatible updates in spring-boot-persistence-h2 --- .../resources/application-lazy-load-no-trans-off.properties | 2 +- .../main/resources/application-lazy-load-no-trans-on.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties index ca60ef3ce3..a1243dc1df 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties @@ -5,7 +5,7 @@ spring.datasource.password= spring.jpa.hibernate.ddl-auto=create-drop spring.h2.console.enabled=true spring.h2.console.path=/h2-console -spring.datasource.data=data-trans.sql +spring.sql.init.data-locations=data-trans.sql logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type=INFO diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties index 0469ea0dde..2ea89b2ee6 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties @@ -5,7 +5,7 @@ spring.datasource.password= spring.jpa.hibernate.ddl-auto=create-drop spring.h2.console.enabled=true spring.h2.console.path=/h2-console -spring.datasource.data=data-trans.sql +spring.sql.init.data-locations=data-trans.sql logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type=INFO From 4bd4abe9839b38335d8f7b206ed6a48956e67694 Mon Sep 17 00:00:00 2001 From: Shashank Date: Fri, 15 Oct 2021 09:51:04 +0530 Subject: [PATCH 032/551] Spring Boot 2.5.x compatible updates in spring-data-jpa-annotations --- .../src/main/resources/ddd.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-annotations/src/main/resources/ddd.properties b/persistence-modules/spring-data-jpa-annotations/src/main/resources/ddd.properties index e5126b694b..af14453993 100644 --- a/persistence-modules/spring-data-jpa-annotations/src/main/resources/ddd.properties +++ b/persistence-modules/spring-data-jpa-annotations/src/main/resources/ddd.properties @@ -1 +1 @@ -spring.datasource.initialization-mode=never \ No newline at end of file +spring.sql.init.mode=never \ No newline at end of file From 1afa3bfcea5becd3fc0f7c4d26027c2975ad9508 Mon Sep 17 00:00:00 2001 From: Ashish Gupta <30566001+gupta-ashu01@users.noreply.github.com> Date: Fri, 15 Oct 2021 12:24:11 +0530 Subject: [PATCH 033/551] BAEL-5126 --- .../src/main/resources/application.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml new file mode 100644 index 0000000000..96f59859a4 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml @@ -0,0 +1,17 @@ +spring: + h2: + console: + enabled: true + path: /h2-console + datasource: + url: jdbc:h2:mem:mydb + username: sa + password: + driverClassName: org.h2.Driver + jpa: + defer-datasource-initialization: true + show-sql: true + hibernate: + format_sql: true + validator.apply_to_ddl: false + ddl-auto: create-drop \ No newline at end of file From 008e340482d77a0a1329dd49b56c9e9acd199e40 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 15 Oct 2021 19:25:52 +0530 Subject: [PATCH 034/551] Update SerializationUtils.java Updating serialization Utils --- .../java/com/baeldung/util/SerializationUtils.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java index 7ebff1a113..429325eb43 100644 --- a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import java.lang.reflect.Field; public class SerializationUtils { @@ -26,6 +27,15 @@ public class SerializationUtils { } public static boolean isSerializable(Class it) { - return it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); + boolean serializable = it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); + if(!serializable) { + return serializable; + } + Field[] declaredFields = it.getDeclaredFields(); + for(Field field: declaredFields) { + Class fieldType = field.getType(); + return isSerializable(fieldType); + } + return serializable; } } From 842f27c77eb2e7e6fd6b2b920b37383ed2805d78 Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Azam Khan Date: Sun, 17 Oct 2021 00:24:08 +0400 Subject: [PATCH 035/551] Test case for unsupported media type error --- .../unsupportedmedia/ApplicationTest.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java diff --git a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java new file mode 100644 index 0000000000..e5c56d0adc --- /dev/null +++ b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java @@ -0,0 +1,59 @@ +package com.baeldung.unsupportedmedia; + +import com.baeldung.unsupportedmediatype.UserController; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@WebMvcTest(UserController.class) +public class ApplicationTest { + @Autowired + private MockMvc mockMvc; + + @Test + void JsonTestCase() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.post("/user/") + .contentType(MediaType.APPLICATION_JSON_VALUE) + .content("{\n" + + " \"name\": \"Andy\",\n" + + " \"age\": 1,\n" + + " \"address\": \"Hello world\"\n" + + "}")) + .andExpect(status().isOk()); + } + + @Test + void JsonFailTestCase() throws Exception {// Because no content-type added + mockMvc.perform(MockMvcRequestBuilders.post("/user/") + .content("{\n" + + " \"name\": \"Andy\",\n" + + " \"age\": 1,\n" + + " \"address\": \"Hello world\"\n" + + "}")) + .andExpect(status().isUnsupportedMediaType()); + } + + @Test + void XmlTestCase() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.post("/user/") + .contentType(MediaType.APPLICATION_XML_VALUE) + .content("Andy1
Hello world
")) + .andExpect(status().isOk()); + } + + @Test + void StringTestCase() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.post("/user/") + .contentType(MediaType.TEXT_PLAIN_VALUE) + .content("Andy1
Hello world
")) + .andExpect(status().isUnsupportedMediaType()); + } +} From 733c7e76b96ba59962dc5032ae6dd4f0de5fca1c Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Azam Khan Date: Sun, 17 Oct 2021 00:52:40 +0400 Subject: [PATCH 036/551] Resolving build failure cases --- .../com/baeldung/unsupportedmediatype/User.java | 4 ++++ .../ApplicationUnitTest.java} | 15 +++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) rename spring-boot-rest-2/src/test/java/com/baeldung/{unsupportedmedia/ApplicationTest.java => unsupportedmediatype/ApplicationUnitTest.java} (84%) diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java index 74a6f4383b..5f5f2a972c 100644 --- a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java @@ -10,6 +10,10 @@ public class User implements Serializable { private Integer age; private String address; + public User(){ + + } + public User(Integer id, String name, Integer age, String address){ this.id = id; this.name = name; diff --git a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java similarity index 84% rename from spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java rename to spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java index e5c56d0adc..a84388f750 100644 --- a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmedia/ApplicationTest.java +++ b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java @@ -1,7 +1,6 @@ -package com.baeldung.unsupportedmedia; +package com.baeldung.unsupportedmediatype; -import com.baeldung.unsupportedmediatype.UserController; -import org.junit.jupiter.api.Test; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -14,12 +13,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringRunner.class) @WebMvcTest(UserController.class) -public class ApplicationTest { +public class ApplicationUnitTest { @Autowired private MockMvc mockMvc; @Test - void JsonTestCase() throws Exception { + public void JsonTestCase() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/user/") .contentType(MediaType.APPLICATION_JSON_VALUE) .content("{\n" + @@ -31,7 +30,7 @@ public class ApplicationTest { } @Test - void JsonFailTestCase() throws Exception {// Because no content-type added + public void JsonFailTestCase() throws Exception {// Because no content-type added mockMvc.perform(MockMvcRequestBuilders.post("/user/") .content("{\n" + " \"name\": \"Andy\",\n" + @@ -42,7 +41,7 @@ public class ApplicationTest { } @Test - void XmlTestCase() throws Exception { + public void XmlTestCase() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/user/") .contentType(MediaType.APPLICATION_XML_VALUE) .content("Andy1
Hello world
")) @@ -50,7 +49,7 @@ public class ApplicationTest { } @Test - void StringTestCase() throws Exception { + public void StringFailTestCase() throws Exception { // Because content-type is not supported mockMvc.perform(MockMvcRequestBuilders.post("/user/") .contentType(MediaType.TEXT_PLAIN_VALUE) .content("Andy1
Hello world
")) From 6d1cdbe9d75b7e34cf05a8fd9f459600ec5aab13 Mon Sep 17 00:00:00 2001 From: lsieun <331505785@qq.com> Date: Sun, 17 Oct 2021 13:29:38 +0800 Subject: [PATCH 037/551] BAEL-4522: Convert Byte Array to its Numeric Representation (#11267) * Convert Byte Array to its Numeric Representation * Remove Redundant Getter Method --- .../core-java-arrays-convert/pom.xml | 5 + .../ByteArrayToNumericRepresentation.java | 281 ++++++++++++++++ ...eArrayToNumericRepresentationUnitTest.java | 316 ++++++++++++++++++ 3 files changed, 602 insertions(+) create mode 100644 core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentation.java create mode 100644 core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentationUnitTest.java diff --git a/core-java-modules/core-java-arrays-convert/pom.xml b/core-java-modules/core-java-arrays-convert/pom.xml index 4cb2946ac9..6e001e12b0 100644 --- a/core-java-modules/core-java-arrays-convert/pom.xml +++ b/core-java-modules/core-java-arrays-convert/pom.xml @@ -19,6 +19,11 @@ guava ${guava.version} + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + diff --git a/core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentation.java b/core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentation.java new file mode 100644 index 0000000000..82d60e1666 --- /dev/null +++ b/core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentation.java @@ -0,0 +1,281 @@ +package com.baeldung.array.conversions; + +import com.google.common.primitives.Ints; +import com.google.common.primitives.Longs; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.Conversion; + +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.util.Arrays; + +class ByteArrayToNumericRepresentation { + + static int convertByteArrayToIntUsingShiftOperator(byte[] bytes) { + int value = 0; + for (byte b : bytes) { + value = (value << 8) + (b & 0xFF); + } + return value; + } + + static byte[] convertIntToByteArrayUsingShiftOperator(int value) { + byte[] bytes = new byte[Integer.BYTES]; + int length = bytes.length; + for (int i = 0; i < length; i++) { + bytes[length - i - 1] = (byte) (value & 0xFF); + value >>= 8; + } + return bytes; + } + + static long convertByteArrayToLongUsingShiftOperator(byte[] bytes) { + long value = 0; + for (byte b : bytes) { + value <<= 8; + value |= (b & 0xFF); + } + return value; + } + + static byte[] convertLongToByteArrayUsingShiftOperator(long value) { + byte[] bytes = new byte[Long.BYTES]; + int length = bytes.length; + for (int i = 0; i < length; i++) { + bytes[length - i - 1] = (byte) (value & 0xFF); + value >>= 8; + } + return bytes; + } + + static float convertByteArrayToFloatUsingShiftOperator(byte[] bytes) { + // convert bytes to int + int intValue = 0; + for (byte b : bytes) { + intValue = (intValue << 8) + (b & 0xFF); + } + + // convert int to float + return Float.intBitsToFloat(intValue); + } + + static byte[] convertFloatToByteArrayUsingShiftOperator(float value) { + // convert float to int + int intValue = Float.floatToIntBits(value); + + // convert int to bytes + byte[] bytes = new byte[Float.BYTES]; + int length = bytes.length; + for (int i = 0; i < length; i++) { + bytes[length - i - 1] = (byte) (intValue & 0xFF); + intValue >>= 8; + } + return bytes; + } + + static double convertingByteArrayToDoubleUsingShiftOperator(byte[] bytes) { + long longValue = 0; + for (byte b : bytes) { + longValue = (longValue << 8) + (b & 0xFF); + } + + return Double.longBitsToDouble(longValue); + } + + static byte[] convertDoubleToByteArrayUsingShiftOperator(double value) { + long longValue = Double.doubleToLongBits(value); + + byte[] bytes = new byte[Double.BYTES]; + int length = bytes.length; + for (int i = 0; i < length; i++) { + bytes[length - i - 1] = (byte) (longValue & 0xFF); + longValue >>= 8; + } + return bytes; + } + + static int convertByteArrayToIntUsingByteBuffer(byte[] bytes) { + ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES); + buffer.put(bytes); + buffer.rewind(); + return buffer.getInt(); + } + + static byte[] convertIntToByteArrayUsingByteBuffer(int value) { + ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES); + buffer.putInt(value); + buffer.rewind(); + return buffer.array(); + } + + static long convertByteArrayToLongUsingByteBuffer(byte[] bytes) { + ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); + buffer.put(bytes); + buffer.rewind(); + return buffer.getLong(); + } + + static byte[] convertLongToByteArrayUsingByteBuffer(long value) { + ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); + buffer.putLong(value); + buffer.rewind(); + return buffer.array(); + } + + static float convertByteArrayToFloatUsingByteBuffer(byte[] bytes) { + ByteBuffer buffer = ByteBuffer.allocate(Float.BYTES); + buffer.put(bytes); + buffer.rewind(); + return buffer.getFloat(); + } + + static byte[] convertFloatToByteArrayUsingByteBuffer(float value) { + ByteBuffer buffer = ByteBuffer.allocate(Float.BYTES); + buffer.putFloat(value); + buffer.rewind(); + return buffer.array(); + } + + static double convertByteArrayToDoubleUsingByteBuffer(byte[] bytes) { + ByteBuffer buffer = ByteBuffer.allocate(Double.BYTES); + buffer.put(bytes); + buffer.rewind(); + return buffer.getDouble(); + } + + static byte[] convertDoubleToByteArrayUsingByteBuffer(double value) { + ByteBuffer buffer = ByteBuffer.allocate(Double.BYTES); + buffer.putDouble(value); + buffer.rewind(); + return buffer.array(); + } + + static int convertByteArrayToIntUsingBigInteger(byte[] bytes) { + return new BigInteger(bytes).intValue(); + } + + static byte[] convertIntToByteArrayUsingBigInteger(int value) { + return BigInteger.valueOf(value).toByteArray(); + } + + static long convertByteArrayToLongUsingBigInteger(byte[] bytes) { + return new BigInteger(bytes).longValue(); + } + + static byte[] convertLongToByteArrayUsingBigInteger(long value) { + return BigInteger.valueOf(value).toByteArray(); + } + + static float convertByteArrayToFloatUsingBigInteger(byte[] bytes) { + int intValue = new BigInteger(bytes).intValue(); + return Float.intBitsToFloat(intValue); + } + + static byte[] convertFloatToByteArrayUsingBigInteger(float value) { + int intValue = Float.floatToIntBits(value); + return BigInteger.valueOf(intValue).toByteArray(); + } + + static double convertByteArrayToDoubleUsingBigInteger(byte[] bytes) { + long longValue = new BigInteger(bytes).longValue(); + return Double.longBitsToDouble(longValue); + } + + static byte[] convertDoubleToByteArrayUsingBigInteger(double value) { + long longValue = Double.doubleToLongBits(value); + return BigInteger.valueOf(longValue).toByteArray(); + } + + static int convertingByteArrayToIntUsingGuava(byte[] bytes) { + return Ints.fromByteArray(bytes); + } + + static byte[] convertIntToByteArrayUsingGuava(int value) { + return Ints.toByteArray(value); + } + + static long convertByteArrayToLongUsingGuava(byte[] bytes) { + return Longs.fromByteArray(bytes); + } + + static byte[] convertLongToByteArrayUsingGuava(long value) { + return Longs.toByteArray(value); + } + + static float convertByteArrayToFloatUsingGuava(byte[] bytes) { + int intValue = Ints.fromByteArray(bytes); + return Float.intBitsToFloat(intValue); + } + + static byte[] convertFloatToByteArrayUsingGuava(float value) { + int intValue = Float.floatToIntBits(value); + return Ints.toByteArray(intValue); + } + + static double convertByteArrayToDoubleUsingGuava(byte[] bytes) { + long longValue = Longs.fromByteArray(bytes); + return Double.longBitsToDouble(longValue); + } + + static byte[] convertDoubleToByteArrayUsingGuava(double value) { + long longValue = Double.doubleToLongBits(value); + return Longs.toByteArray(longValue); + } + + static int convertByteArrayToIntUsingCommonsLang(byte[] bytes) { + byte[] copyBytes = Arrays.copyOf(bytes, bytes.length); + ArrayUtils.reverse(copyBytes); + return Conversion.byteArrayToInt(copyBytes, 0, 0, 0, copyBytes.length); + } + + static byte[] convertIntToByteArrayUsingCommonsLang(int value) { + byte[] bytes = new byte[Integer.BYTES]; + Conversion.intToByteArray(value, 0, bytes, 0, bytes.length); + ArrayUtils.reverse(bytes); + return bytes; + } + + static long convertByteArrayToLongUsingCommonsLang(byte[] bytes) { + byte[] copyBytes = Arrays.copyOf(bytes, bytes.length); + ArrayUtils.reverse(copyBytes); + return Conversion.byteArrayToLong(copyBytes, 0, 0, 0, copyBytes.length); + } + + static byte[] convertLongToByteArrayUsingCommonsLang(long value) { + byte[] bytes = new byte[Long.BYTES]; + Conversion.longToByteArray(value, 0, bytes, 0, bytes.length); + ArrayUtils.reverse(bytes); + return bytes; + } + + static float convertByteArrayToFloatUsingCommonsLang(byte[] bytes) { + byte[] copyBytes = Arrays.copyOf(bytes, bytes.length); + ArrayUtils.reverse(copyBytes); + int intValue = Conversion.byteArrayToInt(copyBytes, 0, 0, 0, copyBytes.length); + return Float.intBitsToFloat(intValue); + } + + static byte[] convertFloatToByteArrayUsingCommonsLang(float value) { + int intValue = Float.floatToIntBits(value); + byte[] bytes = new byte[Float.BYTES]; + Conversion.intToByteArray(intValue, 0, bytes, 0, bytes.length); + ArrayUtils.reverse(bytes); + return bytes; + } + + static double convertByteArrayToDoubleUsingCommonsLang(byte[] bytes) { + byte[] copyBytes = Arrays.copyOf(bytes, bytes.length); + ArrayUtils.reverse(copyBytes); + long longValue = Conversion.byteArrayToLong(copyBytes, 0, 0, 0, copyBytes.length); + return Double.longBitsToDouble(longValue); + } + + static byte[] convertDoubleToByteArrayUsingCommonsLang(double value) { + long longValue = Double.doubleToLongBits(value); + byte[] bytes = new byte[Long.BYTES]; + Conversion.longToByteArray(longValue, 0, bytes, 0, bytes.length); + ArrayUtils.reverse(bytes); + return bytes; + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentationUnitTest.java b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentationUnitTest.java new file mode 100644 index 0000000000..0fae765d9c --- /dev/null +++ b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToNumericRepresentationUnitTest.java @@ -0,0 +1,316 @@ +package com.baeldung.array.conversions; + +import org.junit.Test; + +import static com.baeldung.array.conversions.ByteArrayToNumericRepresentation.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +public class ByteArrayToNumericRepresentationUnitTest { + private static final byte[] INT_BYTE_ARRAY = new byte[]{ + (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE + }; + private static final int INT_VALUE = 0xCAFEBABE; + + + private static final byte[] FLOAT_BYTE_ARRAY = new byte[]{ + (byte) 0x40, (byte) 0x48, (byte) 0xF5, (byte) 0xC3 + }; + private static final float FLOAT_VALUE = 3.14F; + + + private static final byte[] LONG_BYTE_ARRAY = new byte[]{ + (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, + (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF + }; + private static final long LONG_VALUE = 0x0123456789ABCDEFL; + + + private static final byte[] DOUBLE_BYTE_ARRAY = new byte[]{ + (byte) 0x3F, (byte) 0xE3, (byte) 0xC6, (byte) 0xA7, + (byte) 0xEF, (byte) 0x9D, (byte) 0xB2, (byte) 0x2D + }; + private static final double DOUBLE_VALUE = 0.618D; + + + @Test + public void givenShiftOperator_whenConvertingByteArrayToInt_thenSuccess() { + int value = convertByteArrayToIntUsingShiftOperator(INT_BYTE_ARRAY); + + assertEquals(INT_VALUE, value); + } + + @Test + public void givenShiftOperator_whenConvertingIntToByteArray_thenSuccess() { + byte[] bytes = convertIntToByteArrayUsingShiftOperator(INT_VALUE); + + assertArrayEquals(INT_BYTE_ARRAY, bytes); + } + + @Test + public void givenShiftOperator_whenConvertingByteArrayToLong_thenSuccess() { + long value = convertByteArrayToLongUsingShiftOperator(LONG_BYTE_ARRAY); + + assertEquals(LONG_VALUE, value); + } + + @Test + public void givenShiftOperator_whenConvertingLongToByteArray_thenSuccess() { + byte[] bytes = convertLongToByteArrayUsingShiftOperator(LONG_VALUE); + + assertArrayEquals(LONG_BYTE_ARRAY, bytes); + } + + @Test + public void givenShiftOperator_whenConvertingByteArrayToFloat_thenSuccess() { + float value = convertByteArrayToFloatUsingShiftOperator(FLOAT_BYTE_ARRAY); + + assertEquals(Float.floatToIntBits(FLOAT_VALUE), Float.floatToIntBits(value)); + } + + @Test + public void givenShiftOperator_whenConvertingFloatToByteArray_thenSuccess() { + byte[] bytes = convertFloatToByteArrayUsingShiftOperator(FLOAT_VALUE); + + assertArrayEquals(FLOAT_BYTE_ARRAY, bytes); + } + + @Test + public void givenShiftOperator_whenConvertingByteArrayToDouble_thenSuccess() { + double value = convertingByteArrayToDoubleUsingShiftOperator(DOUBLE_BYTE_ARRAY); + + assertEquals(Double.doubleToLongBits(DOUBLE_VALUE), Double.doubleToLongBits(value)); + } + + @Test + public void givenShiftOperator_whenConvertingDoubleToByteArray_thenSuccess() { + byte[] bytes = convertDoubleToByteArrayUsingShiftOperator(DOUBLE_VALUE); + + assertArrayEquals(DOUBLE_BYTE_ARRAY, bytes); + } + + @Test + public void givenByteBuffer_whenConvertingByteArrayToInt_thenSuccess() { + int value = convertByteArrayToIntUsingByteBuffer(INT_BYTE_ARRAY); + + assertEquals(INT_VALUE, value); + } + + @Test + public void givenByteBuffer_whenConvertingIntToByteArray_thenSuccess() { + byte[] bytes = convertIntToByteArrayUsingByteBuffer(INT_VALUE); + + assertArrayEquals(INT_BYTE_ARRAY, bytes); + } + + @Test + public void givenByteBuffer_whenConvertingByteArrayToLong_thenSuccess() { + long value = convertByteArrayToLongUsingByteBuffer(LONG_BYTE_ARRAY); + + assertEquals(LONG_VALUE, value); + } + + @Test + public void givenByteBuffer_whenConvertingLongToByteArray_thenSuccess() { + byte[] bytes = convertLongToByteArrayUsingByteBuffer(LONG_VALUE); + + assertArrayEquals(LONG_BYTE_ARRAY, bytes); + } + + @Test + public void givenByteBuffer_whenConvertingByteArrayToFloat_thenSuccess() { + float value = convertByteArrayToFloatUsingByteBuffer(FLOAT_BYTE_ARRAY); + + assertEquals(Float.floatToIntBits(FLOAT_VALUE), Float.floatToIntBits(value)); + } + + @Test + public void givenByteBuffer_whenConvertingFloatToByteArray_thenSuccess() { + byte[] bytes = convertFloatToByteArrayUsingByteBuffer(FLOAT_VALUE); + + assertArrayEquals(FLOAT_BYTE_ARRAY, bytes); + } + + @Test + public void givenByteBuffer_whenConvertingByteArrayToDouble_thenSuccess() { + double value = convertByteArrayToDoubleUsingByteBuffer(DOUBLE_BYTE_ARRAY); + + assertEquals(Double.doubleToLongBits(DOUBLE_VALUE), Double.doubleToLongBits(value)); + } + + @Test + public void givenByteBuffer_whenConvertingDoubleToByteArray_thenSuccess() { + byte[] bytes = convertDoubleToByteArrayUsingByteBuffer(DOUBLE_VALUE); + + assertArrayEquals(DOUBLE_BYTE_ARRAY, bytes); + } + + @Test + public void givenBigInteger_whenConvertingByteArrayToInt_thenSuccess() { + int value = convertByteArrayToIntUsingBigInteger(INT_BYTE_ARRAY); + + assertEquals(INT_VALUE, value); + } + + @Test + public void givenBigInteger_whenConvertingIntToByteArray_thenSuccess() { + byte[] bytes = convertIntToByteArrayUsingBigInteger(INT_VALUE); + + assertArrayEquals(INT_BYTE_ARRAY, bytes); + } + + @Test + public void givenBigInteger_whenConvertingByteArrayToLong_thenSuccess() { + long value = convertByteArrayToLongUsingBigInteger(LONG_BYTE_ARRAY); + + assertEquals(LONG_VALUE, value); + } + + @Test + public void givenBigInteger_whenConvertingLongToByteArray_thenSuccess() { + byte[] bytes = convertLongToByteArrayUsingBigInteger(LONG_VALUE); + + assertArrayEquals(LONG_BYTE_ARRAY, bytes); + } + + @Test + public void givenBigInteger_whenConvertingByteArrayToFloat_thenSuccess() { + float value = convertByteArrayToFloatUsingBigInteger(FLOAT_BYTE_ARRAY); + + assertEquals(Float.floatToIntBits(FLOAT_VALUE), Float.floatToIntBits(value)); + } + + @Test + public void givenBigInteger_whenConvertingFloatToByteArray_thenSuccess() { + byte[] bytes = convertFloatToByteArrayUsingBigInteger(FLOAT_VALUE); + + assertArrayEquals(FLOAT_BYTE_ARRAY, bytes); + } + + @Test + public void givenBigInteger_whenConvertingByteArrayToDouble_thenSuccess() { + double value = convertByteArrayToDoubleUsingBigInteger(DOUBLE_BYTE_ARRAY); + + assertEquals(Double.doubleToLongBits(DOUBLE_VALUE), Double.doubleToLongBits(value)); + } + + @Test + public void givenBigInteger_whenConvertingDoubleToByteArray_thenSuccess() { + byte[] bytes = convertDoubleToByteArrayUsingBigInteger(DOUBLE_VALUE); + + assertArrayEquals(DOUBLE_BYTE_ARRAY, bytes); + } + + @Test + public void givenGuava_whenConvertingByteArrayToInt_thenSuccess() { + int value = convertingByteArrayToIntUsingGuava(INT_BYTE_ARRAY); + + assertEquals(INT_VALUE, value); + } + + @Test + public void givenGuava_whenConvertingIntToByteArray_thenSuccess() { + byte[] bytes = convertIntToByteArrayUsingGuava(INT_VALUE); + + assertArrayEquals(INT_BYTE_ARRAY, bytes); + } + + @Test + public void givenGuava_whenConvertingByteArrayToLong_thenSuccess() { + long value = convertByteArrayToLongUsingGuava(LONG_BYTE_ARRAY); + + assertEquals(LONG_VALUE, value); + } + + @Test + public void givenGuava_whenConvertingLongToByteArray_thenSuccess() { + byte[] bytes = convertLongToByteArrayUsingGuava(LONG_VALUE); + + assertArrayEquals(LONG_BYTE_ARRAY, bytes); + } + + @Test + public void givenGuava_whenConvertingByteArrayToFloat_thenSuccess() { + float value = convertByteArrayToFloatUsingGuava(FLOAT_BYTE_ARRAY); + + assertEquals(Float.floatToIntBits(FLOAT_VALUE), Float.floatToIntBits(value)); + } + + @Test + public void givenGuava_whenConvertingFloatToByteArray_thenSuccess() { + byte[] bytes = convertFloatToByteArrayUsingGuava(FLOAT_VALUE); + + assertArrayEquals(FLOAT_BYTE_ARRAY, bytes); + } + + @Test + public void givenGuava_whenConvertingByteArrayToDouble_thenSuccess() { + double value = convertByteArrayToDoubleUsingGuava(DOUBLE_BYTE_ARRAY); + + assertEquals(Double.doubleToLongBits(DOUBLE_VALUE), Double.doubleToLongBits(value)); + } + + @Test + public void givenGuava_whenConvertingDoubleToByteArray_thenSuccess() { + byte[] bytes = convertDoubleToByteArrayUsingGuava(DOUBLE_VALUE); + + assertArrayEquals(DOUBLE_BYTE_ARRAY, bytes); + } + + @Test + public void givenCommonsLang_whenConvertingByteArrayToInt_thenSuccess() { + int value = convertByteArrayToIntUsingCommonsLang(INT_BYTE_ARRAY); + + assertEquals(INT_VALUE, value); + } + + @Test + public void givenCommonsLang_whenConvertingIntToByteArray_thenSuccess() { + byte[] bytes = convertIntToByteArrayUsingCommonsLang(INT_VALUE); + + assertArrayEquals(INT_BYTE_ARRAY, bytes); + } + + @Test + public void givenCommonsLang_whenConvertingByteArrayToLong_thenSuccess() { + long value = convertByteArrayToLongUsingCommonsLang(LONG_BYTE_ARRAY); + + assertEquals(LONG_VALUE, value); + } + + @Test + public void givenCommonsLang_whenConvertingLongToByteArray_thenSuccess() { + byte[] bytes = convertLongToByteArrayUsingCommonsLang(LONG_VALUE); + + assertArrayEquals(LONG_BYTE_ARRAY, bytes); + } + + @Test + public void givenCommonsLang_whenConvertingByteArrayToFloat_thenSuccess() { + float value = convertByteArrayToFloatUsingCommonsLang(FLOAT_BYTE_ARRAY); + + assertEquals(Float.floatToIntBits(FLOAT_VALUE), Float.floatToIntBits(value)); + } + + @Test + public void givenCommonsLang_whenConvertingFloatToByteArray_thenSuccess() { + byte[] bytes = convertFloatToByteArrayUsingCommonsLang(FLOAT_VALUE); + + assertArrayEquals(FLOAT_BYTE_ARRAY, bytes); + } + + @Test + public void givenCommonsLang_whenConvertingByteArrayToDouble_thenSuccess() { + double value = convertByteArrayToDoubleUsingCommonsLang(DOUBLE_BYTE_ARRAY); + + assertEquals(Double.doubleToLongBits(DOUBLE_VALUE), Double.doubleToLongBits(value)); + } + + @Test + public void givenCommonsLang_whenConvertingDoubleToByteArray_thenSuccess() { + byte[] bytes = convertDoubleToByteArrayUsingCommonsLang(DOUBLE_VALUE); + + assertArrayEquals(DOUBLE_BYTE_ARRAY, bytes); + } + +} \ No newline at end of file From 979db86a5121098e120995553e906eccee0f805c Mon Sep 17 00:00:00 2001 From: Willian Nalepa Oizumi Date: Sun, 17 Oct 2021 03:14:31 -0300 Subject: [PATCH 038/551] examples for BAEL-5153 - remove double quotes (#11344) --- .../DoubleQuotesRemovalUtils.java | 37 ++++++++++++++++ .../DoubleQuotesRemovalUtilsUnitTest.java | 42 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtils.java create mode 100644 core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtilsUnitTest.java diff --git a/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtils.java b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtils.java new file mode 100644 index 0000000000..c7cc162026 --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtils.java @@ -0,0 +1,37 @@ +package com.baeldung.doublequotesremoval; + +import com.google.common.base.CharMatcher; + +public class DoubleQuotesRemovalUtils { + + public static String removeWithSubString(String input) { + if (input != null && input.length() >= 2 && input.charAt(0) == '\"' + && input.charAt(input.length() - 1) == '\"') { + return input.substring(1, input.length() - 1); + } + + return input; + } + + public static String removeWithReplaceAllSimple(String input) { + if (input == null || input.isEmpty()) + return input; + + return input.replaceAll("\"", ""); + } + + public static String removeWithReplaceAllAdvanced(String input) { + if (input == null || input.isEmpty()) + return input; + + return input.replaceAll("^\"|\"$", ""); + } + + public static String removeWithGuava(String input) { + if (input == null || input.isEmpty()) + return input; + + return CharMatcher.is('\"').trimFrom(input); + } + +} diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtilsUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtilsUnitTest.java new file mode 100644 index 0000000000..2761cc3139 --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/doublequotesremoval/DoubleQuotesRemovalUtilsUnitTest.java @@ -0,0 +1,42 @@ +package com.baeldung.doublequotesremoval; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.jupiter.api.Test; + +public class DoubleQuotesRemovalUtilsUnitTest { + + @Test + public void given_EmptyString_ShouldReturn_EmptyString() { + String input = ""; + + assertTrue(DoubleQuotesRemovalUtils.removeWithSubString(input).isEmpty()); + assertTrue(DoubleQuotesRemovalUtils.removeWithReplaceAllSimple(input).isEmpty()); + assertTrue(DoubleQuotesRemovalUtils.removeWithReplaceAllAdvanced(input).isEmpty()); + assertTrue(DoubleQuotesRemovalUtils.removeWithGuava(input).isEmpty()); + } + + @Test + public void given_DoubleQuotesOnly_ShouldReturn_EmptyString() { + String input = "\"\""; + + assertTrue(DoubleQuotesRemovalUtils.removeWithSubString(input).isEmpty()); + assertTrue(DoubleQuotesRemovalUtils.removeWithReplaceAllSimple(input).isEmpty()); + assertTrue(DoubleQuotesRemovalUtils.removeWithReplaceAllAdvanced(input).isEmpty()); + assertTrue(DoubleQuotesRemovalUtils.removeWithGuava(input).isEmpty()); + } + + @Test + public void given_TextWithDoubleQuotes_ShouldReturn_TextOnly() { + + String input = "\"Example of text for this test suit\""; + String expectedResult = "Example of text for this test suit"; + + assertEquals(expectedResult, DoubleQuotesRemovalUtils.removeWithSubString(input)); + assertEquals(expectedResult, DoubleQuotesRemovalUtils.removeWithReplaceAllSimple(input)); + assertEquals(expectedResult, DoubleQuotesRemovalUtils.removeWithReplaceAllAdvanced(input)); + assertEquals(expectedResult, DoubleQuotesRemovalUtils.removeWithGuava(input)); + } + +} From 2f183181d4c5a564f6896f4af64352f19149ac44 Mon Sep 17 00:00:00 2001 From: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com> Date: Sun, 17 Oct 2021 08:36:43 +0200 Subject: [PATCH 039/551] BAEL-5149 (#11241) * Init * Removing mvnw files * Apply eclipse code format * Refactoring * Refactoring * BAEL-4211 Add benchmarks * Delete hexagonal directory * Refactoring based on the feedback * Refactoring based on feedback - package rename * Directory rename * BAEL-5149 Remove accents from String in Java * BAEL-5149 Remove accents from String in Java * Including suggestions after a review Co-authored-by: asia --- .../StringNormalizer.java | 49 +++++++++++++ .../CollatorUnitTest.java | 70 +++++++++++++++++++ .../StringNormalizerUnitTest.java | 51 ++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizer.java create mode 100644 core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/CollatorUnitTest.java create mode 100644 core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizerUnitTest.java diff --git a/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizer.java b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizer.java new file mode 100644 index 0000000000..d33b9178ea --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizer.java @@ -0,0 +1,49 @@ +package com.baeldung.accentsanddiacriticsremoval; + +import org.apache.commons.lang3.StringUtils; + +import java.text.Normalizer; +import java.util.StringJoiner; + +class StringNormalizer { + + static String removeAccentsWithApacheCommons(String input) { + return StringUtils.stripAccents(input); + } + + static String removeAccents(String input) { + return normalize(input).replaceAll("\\p{M}", ""); + } + + static String unicodeValueOfNormalizedString(String input) { + return toUnicode(normalize(input)); + } + + private static String normalize(String input) { + return input == null ? null : Normalizer.normalize(input, Normalizer.Form.NFKD); + } + + private static String toUnicode(String input) { + if (input.length() == 1) { + return toUnicode(input.charAt(0)); + } else { + StringJoiner stringJoiner = new StringJoiner(" "); + for (char c : input.toCharArray()) { + stringJoiner.add(toUnicode(c)); + } + return stringJoiner.toString(); + } + } + + private static String toUnicode(char input) { + + String hex = Integer.toHexString(input); + StringBuilder sb = new StringBuilder(hex); + + while (sb.length() < 4) { + sb.insert(0, "0"); + } + sb.insert(0, "\\u"); + return sb.toString(); + } +} diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/CollatorUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/CollatorUnitTest.java new file mode 100644 index 0000000000..93b4f5af2e --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/CollatorUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung.accentsanddiacriticsremoval; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Setup; + +import java.text.Collator; + +import static java.lang.Character.*; +import static java.lang.String.valueOf; +import static org.junit.Assert.assertEquals; + +public class CollatorUnitTest { + + private final Collator collator = Collator.getInstance(); + + @Setup + public void setup() { + collator.setDecomposition(2); + } + + @Test + public void givenAccentedStringAndPrimaryCollatorStrength_whenCompareWithASCIIString_thenReturnTrue() { + Collator collator = Collator.getInstance(); + collator.setDecomposition(2); + collator.setStrength(0); + assertEquals(0, collator.compare("a", "a")); + assertEquals(0, collator.compare("ä", "a")); + assertEquals(0, collator.compare("A", "a")); + assertEquals(1, collator.compare("b", "a")); + assertEquals(0, collator.compare(valueOf(toChars(0x0001)), valueOf(toChars(0x0002)))); + } + + @Test + public void givenAccentedStringAndSecondaryCollatorStrength_whenCompareWithASCIIString_thenReturnTrue() { + collator.setStrength(1); + assertEquals(1, collator.compare("ä", "a")); + assertEquals(1, collator.compare("b", "a")); + assertEquals(0, collator.compare("A", "a")); + assertEquals(0, collator.compare("a", "a")); + assertEquals(0, collator.compare(valueOf(toChars(0x0001)), valueOf(toChars(0x0002)))); + + } + + @Test + public void givenAccentedStringAndTeriaryCollatorStrength_whenCompareWithASCIIString_thenReturnTrue() { + collator.setStrength(2); + assertEquals(1, collator.compare("A", "a")); + assertEquals(1, collator.compare("ä", "a")); + assertEquals(1, collator.compare("b", "a")); + assertEquals(0, collator.compare("a", "a")); + assertEquals(0, collator.compare(valueOf(toChars(0x0001)), valueOf(toChars(0x0002)))); + } + + @Test + public void givenAccentedStringAndIdenticalCollatorStrength_whenCompareWithASCIIString_thenReturnTrue() { + collator.setStrength(3); + assertEquals(1, collator.compare("A", "a")); + assertEquals(1, collator.compare("ä", "a")); + assertEquals(1, collator.compare("b", "a")); + assertEquals(-1, collator.compare(valueOf(toChars(0x0001)), valueOf(toChars(0x0002)))); + assertEquals(0, collator.compare("a", "a")); + } + + @Test + public void givenNondecomposableAccentedStringAndIdenticalCollatorStrength_whenCompareWithASCIIString_thenReturnTrue() { + collator.setStrength(0); + assertEquals(1, collator.compare("ł", "l")); + assertEquals(1, collator.compare("ø", "o")); + } +} diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizerUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizerUnitTest.java new file mode 100644 index 0000000000..74359726b7 --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/accentsanddiacriticsremoval/StringNormalizerUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.accentsanddiacriticsremoval; + +import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.text.Normalizer; + +import org.junit.jupiter.api.Test; + +class StringNormalizerUnitTest { + + @Test + public void givenNotNormalizedString_whenIsNormalized_thenReturnFalse() { + assertFalse(Normalizer.isNormalized("āăąēîïĩíĝġńñšŝśûůŷ", Normalizer.Form.NFKD)); + } + + @Test + void givenStringWithDecomposableUnicodeCharacters_whenRemoveAccents_thenReturnASCIIString() { + assertEquals("aaaeiiiiggnnsssuuy", StringNormalizer.removeAccents("āăąēîïĩíĝġńñšŝśûůŷ")); + } + + @Test + void givenStringWithDecomposableUnicodeCharacters_whenRemoveAccentsWithApacheCommons_thenReturnASCIIString() { + assertEquals("aaaeiiiiggnnsssuuy", StringNormalizer.removeAccentsWithApacheCommons("āăąēîïĩíĝġńñšŝśûůŷ")); + } + + @Test + void givenStringWithNondecomposableUnicodeCharacters_whenRemoveAccents_thenReturnOriginalString() { + assertEquals("łđħœ", StringNormalizer.removeAccents("łđħœ")); + } + + @Test + void givenStringWithNondecomposableUnicodeCharacters_whenRemoveAccentsWithApacheCommons_thenReturnModifiedString() { + assertEquals("lđħœ", StringNormalizer.removeAccentsWithApacheCommons("łđħœ")); + } + + @Test + void givenStringWithDecomposableUnicodeCharacters_whenUnicodeValueOfNormalizedString_thenReturnUnicodeValue() { + assertEquals("\\u0066 \\u0069", StringNormalizer.unicodeValueOfNormalizedString("fi")); + assertEquals("\\u0061 \\u0304", StringNormalizer.unicodeValueOfNormalizedString("ā")); + assertEquals("\\u0069 \\u0308", StringNormalizer.unicodeValueOfNormalizedString("ï")); + assertEquals("\\u006e \\u0301", StringNormalizer.unicodeValueOfNormalizedString("ń")); + } + + @Test + void givenStringWithNonDecomposableUnicodeCharacters_whenUnicodeValueOfNormalizedString_thenReturnOriginalValue() { + assertEquals("\\u0142", StringNormalizer.unicodeValueOfNormalizedString("ł")); + assertEquals("\\u0127", StringNormalizer.unicodeValueOfNormalizedString("ħ")); + assertEquals("\\u0111", StringNormalizer.unicodeValueOfNormalizedString("đ")); + } +} \ No newline at end of file From a11613cf3650017f2f92b2d372aae480cc2a3b75 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sun, 17 Oct 2021 08:39:39 +0200 Subject: [PATCH 040/551] BAEL-5214: Upgrade xstream and jettison versions (#11332) --- xstream/pom.xml | 4 ++-- .../com/baeldung/initializer/SimpleXstreamInitializer.java | 6 +++++- .../test/java/com/baeldung/rce/XStreamBasicsUnitTest.java | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xstream/pom.xml b/xstream/pom.xml index c4104d29c4..682b830dd8 100644 --- a/xstream/pom.xml +++ b/xstream/pom.xml @@ -30,8 +30,8 @@ - 1.4.10 - 1.3.8 + 1.4.18 + 1.4.1 \ No newline at end of file diff --git a/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java b/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java index 27b8cc84f3..c631726eb3 100644 --- a/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java +++ b/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java @@ -7,7 +7,11 @@ import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver; public class SimpleXstreamInitializer { public XStream getXstreamInstance() { - return new XStream(); + XStream xstream = new XStream(); + xstream.allowTypesByWildcard(new String[]{ + "com.baeldung.**" + }); + return xstream; } public XStream getXstreamJettisonMappedInstance() { diff --git a/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java b/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java index d762813b22..6a9e3c6782 100644 --- a/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java +++ b/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java @@ -21,6 +21,7 @@ public final class XStreamBasicsUnitTest { public void before() { xstream = new XStream(); xstream.alias("person", Person.class); + xstream.allowTypes(new Class[] { Person.class }); } @Test From 125aa509c088ea93b1224b078c723ac09848648d Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sun, 17 Oct 2021 08:52:26 +0200 Subject: [PATCH 041/551] BAEL-5215: Remove redundant @EnableAutoConfiguration annotations (#11331) --- .../kafka/embedded/KafkaProducerConsumerApplication.java | 1 - .../main/java/com/baeldung/kafka/ssl/KafkaSslApplication.java | 1 - 2 files changed, 2 deletions(-) diff --git a/spring-kafka/src/main/java/com/baeldung/kafka/embedded/KafkaProducerConsumerApplication.java b/spring-kafka/src/main/java/com/baeldung/kafka/embedded/KafkaProducerConsumerApplication.java index bf14251d75..b4a03a12b0 100644 --- a/spring-kafka/src/main/java/com/baeldung/kafka/embedded/KafkaProducerConsumerApplication.java +++ b/spring-kafka/src/main/java/com/baeldung/kafka/embedded/KafkaProducerConsumerApplication.java @@ -5,7 +5,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -@EnableAutoConfiguration public class KafkaProducerConsumerApplication { public static void main(String[] args) { diff --git a/spring-kafka/src/main/java/com/baeldung/kafka/ssl/KafkaSslApplication.java b/spring-kafka/src/main/java/com/baeldung/kafka/ssl/KafkaSslApplication.java index ae6df5bee2..b7747ebfef 100644 --- a/spring-kafka/src/main/java/com/baeldung/kafka/ssl/KafkaSslApplication.java +++ b/spring-kafka/src/main/java/com/baeldung/kafka/ssl/KafkaSslApplication.java @@ -5,7 +5,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -@EnableAutoConfiguration public class KafkaSslApplication { public static void main(String[] args) { From 6ada7ea8618d8b606a860af6d0877fa45f612130 Mon Sep 17 00:00:00 2001 From: Ashish Gupta <30566001+gupta-ashu01@users.noreply.github.com> Date: Mon, 18 Oct 2021 10:33:43 +0530 Subject: [PATCH 042/551] Update application.yaml --- .../src/main/resources/application.yaml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml index 96f59859a4..0ad77cc3cb 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml @@ -1,17 +1,14 @@ spring: h2: console: - enabled: true - path: /h2-console + enabled:true + path:/h2-console + console.settings.trace:false + spring.h2.console.settings.web-allow-others:false datasource: - url: jdbc:h2:mem:mydb - username: sa - password: + url:jdbc:h2:mem:mydb + username:sa + password:password driverClassName: org.h2.Driver jpa: - defer-datasource-initialization: true - show-sql: true - hibernate: - format_sql: true - validator.apply_to_ddl: false - ddl-auto: create-drop \ No newline at end of file + spring.jpa.database-platform:org.hibernate.dialect.H2Dialect From faf9c9e3eee649c64cde590ca92f720a6d1d5e23 Mon Sep 17 00:00:00 2001 From: Ashish Gupta <30566001+gupta-ashu01@users.noreply.github.com> Date: Mon, 18 Oct 2021 10:39:18 +0530 Subject: [PATCH 043/551] Update application.yaml --- .../src/main/resources/application.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml index 0ad77cc3cb..aeb33f797a 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml @@ -1,14 +1,14 @@ spring: h2: console: - enabled:true - path:/h2-console - console.settings.trace:false - spring.h2.console.settings.web-allow-others:false + enabled: true + path: /h2-console + console.settings.trace: false + spring.h2.console.settings.web-allow-others: false datasource: - url:jdbc:h2:mem:mydb - username:sa - password:password + url: jdbc:h2:mem:mydb + username: sa + password: password driverClassName: org.h2.Driver jpa: - spring.jpa.database-platform:org.hibernate.dialect.H2Dialect + spring.jpa.database-platform: org.hibernate.dialect.H2Dialect From 4d072e5e090c688e1e419904df96057b39c75dd9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 18 Oct 2021 13:30:21 +0200 Subject: [PATCH 044/551] JAVA-7578: Fix xstream tests --- .../initializer/SimpleXstreamInitializer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java b/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java index c631726eb3..a391b0dca0 100644 --- a/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java +++ b/xstream/src/main/java/com/baeldung/initializer/SimpleXstreamInitializer.java @@ -15,10 +15,18 @@ public class SimpleXstreamInitializer { } public XStream getXstreamJettisonMappedInstance() { - return new XStream(new JettisonMappedXmlDriver()); + XStream xstream = new XStream(new JettisonMappedXmlDriver()); + xstream.allowTypesByWildcard(new String[]{ + "com.baeldung.**" + }); + return xstream; } public XStream getXstreamJsonHierarchicalInstance() { - return new XStream(new JsonHierarchicalStreamDriver()); + XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); + xstream.allowTypesByWildcard(new String[]{ + "com.baeldung.**" + }); + return xstream; } } \ No newline at end of file From b2c4765cc3b305b6044176f0be8be0f0374fbe2d Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Mon, 18 Oct 2021 18:44:47 +0200 Subject: [PATCH 045/551] Parallel Test Execution for JUnit 5 - refactoring --- junit5/README.md | 6 ---- junit5/pom.xml | 36 ------------------- .../java/com/baeldung/junit5/A_UnitTest.java | 21 ----------- .../java/com/baeldung/junit5/B_UnitTest.java | 23 ------------ .../parallel/FirstParallelUnitTest.java | 21 +++++++++++ .../ParallelResourceLockUnitTest.java | 12 +++---- .../parallel/SecondParallelUnitTest.java | 21 +++++++++++ .../test/resources/junit-platform.properties | 0 8 files changed, 48 insertions(+), 92 deletions(-) delete mode 100644 junit5/README.md delete mode 100644 junit5/pom.xml delete mode 100644 junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java delete mode 100644 junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java create mode 100644 testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/FirstParallelUnitTest.java rename junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java => testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/ParallelResourceLockUnitTest.java (61%) create mode 100644 testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/SecondParallelUnitTest.java rename {junit5 => testing-modules/junit-5-advanced}/src/test/resources/junit-platform.properties (100%) diff --git a/junit5/README.md b/junit5/README.md deleted file mode 100644 index ad16ad164d..0000000000 --- a/junit5/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## JUnit5 - -This module contains articles about the JUnit 5 - -### Relevant Articles: - diff --git a/junit5/pom.xml b/junit5/pom.xml deleted file mode 100644 index b9804408a2..0000000000 --- a/junit5/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - 4.0.0 - junit5 - junit5 - - - parent-modules - com.baeldung - 1.0.0-SNAPSHOT - - - - 8 - 8 - - - - - org.junit.jupiter - junit-jupiter-api - 5.8.1 - test - - - org.junit.jupiter - junit-jupiter-engine - 5.8.1 - test - - - - \ No newline at end of file diff --git a/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java deleted file mode 100644 index e4ba59b22d..0000000000 --- a/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.junit5; - -import org.junit.jupiter.api.Test; - -public class A_UnitTest { - - @Test - public void first() throws Exception{ - System.out.println("Test A first() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test A first() end => " + Thread.currentThread().getName()); - } - - @Test - public void second() throws Exception{ - System.out.println("Test A second() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test A second() end => " + Thread.currentThread().getName()); - } - -} diff --git a/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java deleted file mode 100644 index 2b195d2551..0000000000 --- a/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.junit5; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; - -public class B_UnitTest { - - @Test - public void first() throws Exception{ - System.out.println("Test B first() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test B first() end => " + Thread.currentThread().getName()); - } - - @Test - public void second() throws Exception{ - System.out.println("Test B second() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test B second() end => " + Thread.currentThread().getName()); - } - -} diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/FirstParallelUnitTest.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/FirstParallelUnitTest.java new file mode 100644 index 0000000000..8ac8a161ba --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/FirstParallelUnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.parallel; + +import org.junit.jupiter.api.Test; + +public class FirstParallelUnitTest { + + @Test + public void first() throws Exception{ + System.out.println("FirstParallelUnitTest first() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("FirstParallelUnitTest first() end => " + Thread.currentThread().getName()); + } + + @Test + public void second() throws Exception{ + System.out.println("FirstParallelUnitTest second() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("FirstParallelUnitTest second() end => " + Thread.currentThread().getName()); + } + +} diff --git a/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/ParallelResourceLockUnitTest.java similarity index 61% rename from junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java rename to testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/ParallelResourceLockUnitTest.java index ce545f6bee..ba607b2654 100644 --- a/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/ParallelResourceLockUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit5; +package com.baeldung.parallel; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -8,7 +8,7 @@ import org.junit.jupiter.api.parallel.ResourceLock; import java.util.ArrayList; import java.util.List; -public class C_UnitTest { +public class ParallelResourceLockUnitTest { private List resources; @@ -26,20 +26,20 @@ public class C_UnitTest { @Test @ResourceLock(value = "resources") public void first() throws Exception { - System.out.println("Test C first() start => " + Thread.currentThread().getName()); + System.out.println("ParallelResourceLockUnitTest first() start => " + Thread.currentThread().getName()); resources.add("first"); System.out.println(resources); Thread.sleep(500); - System.out.println("Test C first() end => " + Thread.currentThread().getName()); + System.out.println("ParallelResourceLockUnitTest first() end => " + Thread.currentThread().getName()); } @Test @ResourceLock(value = "resources") public void second() throws Exception { - System.out.println("Test C second() start => " + Thread.currentThread().getName()); + System.out.println("ParallelResourceLockUnitTest second() start => " + Thread.currentThread().getName()); resources.add("second"); System.out.println(resources); Thread.sleep(500); - System.out.println("Test C second() end => " + Thread.currentThread().getName()); + System.out.println("ParallelResourceLockUnitTest second() end => " + Thread.currentThread().getName()); } } diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/SecondParallelUnitTest.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/SecondParallelUnitTest.java new file mode 100644 index 0000000000..6a6a83fbd8 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/parallel/SecondParallelUnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.parallel; + +import org.junit.jupiter.api.Test; + +public class SecondParallelUnitTest { + + @Test + public void first() throws Exception{ + System.out.println("SecondParallelUnitTest first() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("SecondParallelUnitTest first() end => " + Thread.currentThread().getName()); + } + + @Test + public void second() throws Exception{ + System.out.println("SecondParallelUnitTest second() start => " + Thread.currentThread().getName()); + Thread.sleep(500); + System.out.println("SecondParallelUnitTest second() end => " + Thread.currentThread().getName()); + } + +} diff --git a/junit5/src/test/resources/junit-platform.properties b/testing-modules/junit-5-advanced/src/test/resources/junit-platform.properties similarity index 100% rename from junit5/src/test/resources/junit-platform.properties rename to testing-modules/junit-5-advanced/src/test/resources/junit-platform.properties From 3a2eee308c0259169ab0762bb29cecc42cddb054 Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Mon, 18 Oct 2021 18:48:13 +0200 Subject: [PATCH 046/551] BAEL-5095 Dockerfile strategies for Git (#11348) Co-authored-by: majewsk6 --- docker/dockerfile-with-git/.gitmodules | 4 ++++ docker/dockerfile-with-git/Dockerfile | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 docker/dockerfile-with-git/.gitmodules create mode 100644 docker/dockerfile-with-git/Dockerfile diff --git a/docker/dockerfile-with-git/.gitmodules b/docker/dockerfile-with-git/.gitmodules new file mode 100644 index 0000000000..aa3911dfc3 --- /dev/null +++ b/docker/dockerfile-with-git/.gitmodules @@ -0,0 +1,4 @@ +[submodule "project"] + path = project + url = https://github.com/eugenp/tutorials.git + branch = master \ No newline at end of file diff --git a/docker/dockerfile-with-git/Dockerfile b/docker/dockerfile-with-git/Dockerfile new file mode 100644 index 0000000000..91dfee3bc6 --- /dev/null +++ b/docker/dockerfile-with-git/Dockerfile @@ -0,0 +1,13 @@ +ADD . /project/ +ADD /build/ /project/ +ADD /output/project.jar /project/ + +ADD ssh-private-key /root/.ssh/id_rsa +RUN git clone git@github.com:eugenp/tutorials.git + +ARG username=$GIT_USERNAME +ARG password=$GIT_PASSWORD +RUN git clone https://username:password@github.com:eugenp/tutorials.git + +VOLUME /build/ /project/ + From 5f20ca1a780625961a56d353901aea06431f4e32 Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Mon, 18 Oct 2021 21:40:50 +0200 Subject: [PATCH 047/551] Parallel Test Execution for JUnit 5 - fixed module issue --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index fccee8823f..1e26d09906 100644 --- a/pom.xml +++ b/pom.xml @@ -472,7 +472,6 @@ json-path jsoup jta - junit5 kubernetes ksqldb From 025afb1f7d348d3ef8027aa9f3eb7bf9584e713a Mon Sep 17 00:00:00 2001 From: Andrey Bichkevski <1533091+andbi@users.noreply.github.com> Date: Mon, 18 Oct 2021 20:22:37 -0500 Subject: [PATCH 048/551] BAEL-5143 (#11273) * BAEL-5143 * Modified as per PR comments * The List<> type for session data is changed to a more generic Collection<> * Version upgrade Co-authored-by: 0swald --- rule-engines/evrete/pom.xml | 35 ++++++++ .../evrete/introduction/IntroductionAJR.java | 47 ++++++++++ .../introduction/IntroductionInline.java | 58 ++++++++++++ .../evrete/introduction/model/Customer.java | 26 ++++++ .../evrete/introduction/model/Invoice.java | 19 ++++ .../evrete/src/main/resources/logback.xml | 13 +++ .../main/resources/rules/SalesRuleset.java | 20 +++++ .../introduction/IntroductionAJRUnitTest.java | 80 +++++++++++++++++ .../IntroductionInlineUnitTest.java | 90 +++++++++++++++++++ rule-engines/pom.xml | 1 + 10 files changed, 389 insertions(+) create mode 100644 rule-engines/evrete/pom.xml create mode 100644 rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionAJR.java create mode 100644 rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionInline.java create mode 100644 rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Customer.java create mode 100644 rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Invoice.java create mode 100644 rule-engines/evrete/src/main/resources/logback.xml create mode 100644 rule-engines/evrete/src/main/resources/rules/SalesRuleset.java create mode 100644 rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionAJRUnitTest.java create mode 100644 rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionInlineUnitTest.java diff --git a/rule-engines/evrete/pom.xml b/rule-engines/evrete/pom.xml new file mode 100644 index 0000000000..819a912c43 --- /dev/null +++ b/rule-engines/evrete/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + com.baeldung.evrete + evrete + 1.0 + evrete + + + 2.1.04 + + + + com.baeldung + rule-engines + 1.0.0-SNAPSHOT + + + + + + org.evrete + evrete-core + ${evrete.version} + + + + org.evrete + evrete-dsl-java + ${evrete.version} + + + \ No newline at end of file diff --git a/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionAJR.java b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionAJR.java new file mode 100644 index 0000000000..287d083311 --- /dev/null +++ b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionAJR.java @@ -0,0 +1,47 @@ +package com.baeldung.evrete.introduction; + +import com.baeldung.evrete.introduction.model.Customer; +import com.baeldung.evrete.introduction.model.Invoice; +import org.evrete.KnowledgeService; +import org.evrete.api.Knowledge; + +import java.io.IOException; +import java.net.URL; +import java.util.*; + +public class IntroductionAJR { + public static void main(String[] args) throws IOException { + ClassLoader classLoader = IntroductionAJR.class.getClassLoader(); + KnowledgeService service = new KnowledgeService(); + URL rulesetUrl = classLoader.getResource("rules/SalesRuleset.java"); + Knowledge knowledge = service.newKnowledge( + "JAVA-SOURCE", + rulesetUrl + ); + + List customers = Arrays.asList( + new Customer("Customer A"), + new Customer("Customer B"), + new Customer("Customer C") + ); + + Random random = new Random(); + Collection sessionData = new LinkedList<>(customers); + for (int i = 0; i < 100_000; i++) { + Customer randomCustomer = customers.get(random.nextInt(customers.size())); + Invoice invoice = new Invoice(randomCustomer, 100 * random.nextDouble()); + sessionData.add(invoice); + } + + knowledge + .newStatelessSession() + .insert(sessionData) + .fire(); + + for (Customer c : customers) { + System.out.printf("%s:\t$%,.2f%n", c.getName(), c.getTotal()); + } + + service.shutdown(); + } +} diff --git a/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionInline.java b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionInline.java new file mode 100644 index 0000000000..8867a72d23 --- /dev/null +++ b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/IntroductionInline.java @@ -0,0 +1,58 @@ +package com.baeldung.evrete.introduction; + +import org.evrete.KnowledgeService; +import org.evrete.api.Knowledge; +import com.baeldung.evrete.introduction.model.*; + +import java.util.*; + +public class IntroductionInline { + public static void main(String[] args) { + KnowledgeService service = new KnowledgeService(); + Knowledge knowledge = service + .newKnowledge() + .newRule("Clear total sales") + .forEach("$c", Customer.class) + .execute(ctx -> { + Customer c = ctx.get("$c"); + c.setTotal(0.0); + }) + .newRule("Compute totals") + .forEach( + "$c", Customer.class, + "$i", Invoice.class + ) + .where("$i.customer == $c") + .execute(ctx -> { + Customer c = ctx.get("$c"); + Invoice i = ctx.get("$i"); + c.addToTotal(i.getAmount()); + }); + + + List customers = Arrays.asList( + new Customer("Customer A"), + new Customer("Customer B"), + new Customer("Customer C") + ); + + Random random = new Random(); + Collection sessionData = new LinkedList<>(customers); + for (int i = 0; i < 100_000; i++) { + Customer randomCustomer = customers.get(random.nextInt(customers.size())); + Invoice invoice = new Invoice(randomCustomer, 100 * random.nextDouble()); + sessionData.add(invoice); + } + + knowledge + .newStatelessSession() + .insert(sessionData) + .fire(); + + for (Customer c : customers) { + System.out.printf("%s:\t$%,.2f%n", c.getName(), c.getTotal()); + } + + service.shutdown(); + } +} diff --git a/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Customer.java b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Customer.java new file mode 100644 index 0000000000..9a60850d7c --- /dev/null +++ b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Customer.java @@ -0,0 +1,26 @@ +package com.baeldung.evrete.introduction.model; + +public class Customer { + private double total = 0.0; + private final String name; + + public Customer(String name) { + this.name = name; + } + + public void addToTotal(double amount) { + this.total += amount; + } + + public String getName() { + return name; + } + + public double getTotal() { + return total; + } + + public void setTotal(double total) { + this.total = total; + } +} diff --git a/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Invoice.java b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Invoice.java new file mode 100644 index 0000000000..3be4fd2908 --- /dev/null +++ b/rule-engines/evrete/src/main/java/com/baeldung/evrete/introduction/model/Invoice.java @@ -0,0 +1,19 @@ +package com.baeldung.evrete.introduction.model; + +public class Invoice { + private final Customer customer; + private final double amount; + + public Invoice(Customer customer, double amount) { + this.customer = customer; + this.amount = amount; + } + + public Customer getCustomer() { + return customer; + } + + public double getAmount() { + return amount; + } +} diff --git a/rule-engines/evrete/src/main/resources/logback.xml b/rule-engines/evrete/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/rule-engines/evrete/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/rule-engines/evrete/src/main/resources/rules/SalesRuleset.java b/rule-engines/evrete/src/main/resources/rules/SalesRuleset.java new file mode 100644 index 0000000000..d36aca9c4d --- /dev/null +++ b/rule-engines/evrete/src/main/resources/rules/SalesRuleset.java @@ -0,0 +1,20 @@ +package org.abc.author1; + +import com.baeldung.evrete.introduction.model.Customer; +import com.baeldung.evrete.introduction.model.Invoice; +import org.evrete.dsl.annotation.Rule; +import org.evrete.dsl.annotation.Where; + +public class SalesRuleset { + + @Rule + public void rule1(Customer $c) { + $c.setTotal(0.0); + } + + @Rule + @Where("$i.customer == $c") + public void rule2(Customer $c, Invoice $i) { + $c.addToTotal($i.getAmount()); + } +} \ No newline at end of file diff --git a/rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionAJRUnitTest.java b/rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionAJRUnitTest.java new file mode 100644 index 0000000000..955dbb2fe1 --- /dev/null +++ b/rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionAJRUnitTest.java @@ -0,0 +1,80 @@ +package com.baeldung.evrete.introduction; + +import com.baeldung.evrete.introduction.model.Customer; +import com.baeldung.evrete.introduction.model.Invoice; +import org.evrete.KnowledgeService; +import org.evrete.api.Knowledge; +import org.evrete.api.RuleSession; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.IOException; +import java.util.*; + +class IntroductionAJRUnitTest { + private static KnowledgeService service; + + @BeforeAll + static void setUpClass() { + service = new KnowledgeService(); + } + + @AfterAll + static void shutDownClass() { + service.shutdown(); + } + + /** + * This test makes sure that each customer's actual total sales is equal to the amount + * computed by the rule engine + */ + @ParameterizedTest + @ValueSource(strings = {"true", "false"}) + void sessionTotalsTest(String type) throws IOException { + boolean stateful = Boolean.parseBoolean(type); + ClassLoader classLoader = IntroductionAJR.class.getClassLoader(); + KnowledgeService service = new KnowledgeService(); + Knowledge knowledge = service + .newKnowledge( + "JAVA-SOURCE", + classLoader.getResource("rules/SalesRuleset.java") + ); + + + List customers = Arrays.asList( + new Customer("Customer A"), + new Customer("Customer B"), + new Customer("Customer C") + ); + Collection sessionData = new LinkedList<>(customers); + + HashMap actualTotals = new HashMap<>(); + Random random = new Random(); + for (int i = 0; i < 1_000; i++) { + Customer randomCustomer = customers.get(random.nextInt(customers.size())); + Invoice invoice = new Invoice(randomCustomer, random.nextInt(100)); + sessionData.add(invoice); + + Double d = actualTotals.get(randomCustomer); + if(d == null) { + d = 0.0; + } + d = d + invoice.getAmount(); + actualTotals.put(randomCustomer, d); + } + + RuleSession session = stateful ? knowledge.newStatefulSession() : knowledge.newStatelessSession(); + session + .insert(sessionData) + .fire(); + + for(Customer c : customers) { + double d1 = c.getTotal(); + double d2 = actualTotals.get(c); + assert d1 == d2; + } + + } +} \ No newline at end of file diff --git a/rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionInlineUnitTest.java b/rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionInlineUnitTest.java new file mode 100644 index 0000000000..0a6aac83bd --- /dev/null +++ b/rule-engines/evrete/src/test/java/com/baeldung/evrete/introduction/IntroductionInlineUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.evrete.introduction; + +import com.baeldung.evrete.introduction.model.Customer; +import com.baeldung.evrete.introduction.model.Invoice; +import org.evrete.KnowledgeService; +import org.evrete.api.Knowledge; +import org.evrete.api.RuleSession; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.util.*; + +class IntroductionInlineUnitTest { + private static KnowledgeService service; + + @BeforeAll + static void setUpClass() { + service = new KnowledgeService(); + } + + @AfterAll + static void shutDownClass() { + service.shutdown(); + } + + /** + * This test makes sure that each customer's actual total sales is equal to the amount + * computed by the rule engine + */ + @ParameterizedTest + @ValueSource(strings = {"true", "false"}) + void sessionTotalsTest(String type) { + boolean stateful = Boolean.parseBoolean(type); + Knowledge knowledge = service + .newKnowledge() + .newRule("Clear customer's total sales") + .forEach("$c", Customer.class) + .execute(ctx -> { + Customer c = ctx.get("$c"); + c.setTotal(0.0); + }) + .newRule("Compute totals") + .forEach( + "$c", Customer.class, + "$i", Invoice.class + ) + .where("$i.customer == $c") + .execute(ctx -> { + Customer c = ctx.get("$c"); + Invoice i = ctx.get("$i"); + c.addToTotal(i.getAmount()); + }); + + + List customers = Arrays.asList( + new Customer("Customer A"), + new Customer("Customer B"), + new Customer("Customer C") + ); + Collection sessionData = new LinkedList<>(customers); + + HashMap actualTotals = new HashMap<>(); + Random random = new Random(); + for (int i = 0; i < 1_000; i++) { + Customer randomCustomer = customers.get(random.nextInt(customers.size())); + Invoice invoice = new Invoice(randomCustomer, random.nextInt(100)); + sessionData.add(invoice); + + Double d = actualTotals.get(randomCustomer); + if(d == null) { + d = 0.0; + } + d = d + invoice.getAmount(); + actualTotals.put(randomCustomer, d); + } + + RuleSession session = stateful ? knowledge.newStatefulSession() : knowledge.newStatelessSession(); + session + .insert(sessionData) + .fire(); + + for(Customer c : customers) { + double d1 = c.getTotal(); + double d2 = actualTotals.get(c); + assert d1 == d2; + } + } +} \ No newline at end of file diff --git a/rule-engines/pom.xml b/rule-engines/pom.xml index db6b2e47ef..6d8a014128 100644 --- a/rule-engines/pom.xml +++ b/rule-engines/pom.xml @@ -15,6 +15,7 @@ easy-rules + evrete openl-tablets rulebook From 2fa7ea1f22e41082f70350f39b436023e5a390f0 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Tue, 19 Oct 2021 07:24:07 +0530 Subject: [PATCH 049/551] Changes to PO Changes to add transition and volatile --- .../java/com/baeldung/util/SerializationUtils.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java index 429325eb43..2a9391965f 100644 --- a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java @@ -7,6 +7,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; public class SerializationUtils { @@ -28,11 +29,16 @@ public class SerializationUtils { public static boolean isSerializable(Class it) { boolean serializable = it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); - if(!serializable) { + if (!serializable) { return serializable; } Field[] declaredFields = it.getDeclaredFields(); - for(Field field: declaredFields) { + for (Field field : declaredFields) { + if (Modifier.isVolatile(field.getModifiers()) + || Modifier.isTransient(field.getModifiers()) + || Modifier.isStatic(field.getModifiers())) { + continue; + } Class fieldType = field.getType(); return isSerializable(fieldType); } From 2dfd2e9e273a27c74c43033d80ef786c7ff0ee9c Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 19 Oct 2021 10:37:14 +0200 Subject: [PATCH 050/551] BAEL-5219: Fix spring-mvc-webflow and spring-mvc-xml poms (#11350) --- spring-web-modules/spring-mvc-webflow/pom.xml | 4 ++-- spring-web-modules/spring-mvc-xml/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-web-modules/spring-mvc-webflow/pom.xml b/spring-web-modules/spring-mvc-webflow/pom.xml index 2e150e2d01..49037e7186 100644 --- a/spring-web-modules/spring-mvc-webflow/pom.xml +++ b/spring-web-modules/spring-mvc-webflow/pom.xml @@ -10,8 +10,8 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + spring-web-modules + 0.0.1-SNAPSHOT diff --git a/spring-web-modules/spring-mvc-xml/pom.xml b/spring-web-modules/spring-mvc-xml/pom.xml index 354d652095..e67052e0cd 100644 --- a/spring-web-modules/spring-mvc-xml/pom.xml +++ b/spring-web-modules/spring-mvc-xml/pom.xml @@ -10,8 +10,8 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + spring-web-modules + 0.0.1-SNAPSHOT From c034fb74bc0f30f1e0b0f897cee6a51dce697778 Mon Sep 17 00:00:00 2001 From: Ralf Ueberfuhr Date: Wed, 20 Oct 2021 14:14:40 +0200 Subject: [PATCH 051/551] BAEL-5036: Add Quarkus Hello App that uses several external modules that contain CDI managed beans. Each module is indexed using a different kind of registration. --- pom.xml | 2 + quarkus-jandex/README.md | 3 + quarkus-jandex/hello-app/.dockerignore | 5 + quarkus-jandex/hello-app/.gitignore | 39 +++ .../.mvn/wrapper/MavenWrapperDownloader.java | 114 +++++++ .../.mvn/wrapper/maven-wrapper.properties | 2 + quarkus-jandex/hello-app/README.md | 51 +++ quarkus-jandex/hello-app/mvnw | 310 ++++++++++++++++++ quarkus-jandex/hello-app/mvnw.cmd | 182 ++++++++++ quarkus-jandex/hello-app/pom.xml | 131 ++++++++ .../hello-app/src/main/docker/Dockerfile.jvm | 55 ++++ .../src/main/docker/Dockerfile.legacy-jar | 51 +++ .../src/main/docker/Dockerfile.native | 27 ++ .../main/docker/Dockerfile.native-distroless | 23 ++ .../baeldung/quarkus/hello/HelloResource.java | 26 ++ .../resources/META-INF/resources/index.html | 14 + .../src/main/resources/application.properties | 2 + .../pom.xml | 26 ++ .../ApplicationPropertiesHelloSender.java | 15 + quarkus-jandex/hello-sender-beans-xml/pom.xml | 26 ++ .../sender/beansxml/BeansXmlHelloSender.java | 15 + .../src/main/resources/META-INF/beans.xml | 0 .../hello-sender-maven-plugin/pom.xml | 46 +++ .../mavenplugin/MavenPluginHelloSender.java | 15 + .../hello-sender-undetected/pom.xml | 26 ++ .../undetected/UndetectedHelloSender.java | 15 + quarkus-jandex/hello-service/pom.xml | 21 ++ .../hello/service/HelloRetrieving.java | 17 + .../quarkus/hello/service/HelloService.java | 18 + .../src/main/resources/META-INF/beans.xml | 0 quarkus-jandex/pom.xml | 42 +++ 31 files changed, 1319 insertions(+) create mode 100644 quarkus-jandex/README.md create mode 100644 quarkus-jandex/hello-app/.dockerignore create mode 100644 quarkus-jandex/hello-app/.gitignore create mode 100644 quarkus-jandex/hello-app/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 quarkus-jandex/hello-app/.mvn/wrapper/maven-wrapper.properties create mode 100644 quarkus-jandex/hello-app/README.md create mode 100644 quarkus-jandex/hello-app/mvnw create mode 100644 quarkus-jandex/hello-app/mvnw.cmd create mode 100644 quarkus-jandex/hello-app/pom.xml create mode 100644 quarkus-jandex/hello-app/src/main/docker/Dockerfile.jvm create mode 100644 quarkus-jandex/hello-app/src/main/docker/Dockerfile.legacy-jar create mode 100644 quarkus-jandex/hello-app/src/main/docker/Dockerfile.native create mode 100644 quarkus-jandex/hello-app/src/main/docker/Dockerfile.native-distroless create mode 100644 quarkus-jandex/hello-app/src/main/java/com/baeldung/quarkus/hello/HelloResource.java create mode 100644 quarkus-jandex/hello-app/src/main/resources/META-INF/resources/index.html create mode 100644 quarkus-jandex/hello-app/src/main/resources/application.properties create mode 100644 quarkus-jandex/hello-sender-application-properties/pom.xml create mode 100644 quarkus-jandex/hello-sender-application-properties/src/main/java/com/baeldung/quarkus/hello/sender/applicationproperties/ApplicationPropertiesHelloSender.java create mode 100644 quarkus-jandex/hello-sender-beans-xml/pom.xml create mode 100644 quarkus-jandex/hello-sender-beans-xml/src/main/java/com/baeldung/quarkus/hello/sender/beansxml/BeansXmlHelloSender.java create mode 100644 quarkus-jandex/hello-sender-beans-xml/src/main/resources/META-INF/beans.xml create mode 100644 quarkus-jandex/hello-sender-maven-plugin/pom.xml create mode 100644 quarkus-jandex/hello-sender-maven-plugin/src/main/java/com/baeldung/quarkus/hello/sender/mavenplugin/MavenPluginHelloSender.java create mode 100644 quarkus-jandex/hello-sender-undetected/pom.xml create mode 100644 quarkus-jandex/hello-sender-undetected/src/main/java/com/baeldung/quarkus/hello/sender/undetected/UndetectedHelloSender.java create mode 100644 quarkus-jandex/hello-service/pom.xml create mode 100644 quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloRetrieving.java create mode 100644 quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloService.java create mode 100644 quarkus-jandex/hello-service/src/main/resources/META-INF/beans.xml create mode 100644 quarkus-jandex/pom.xml diff --git a/pom.xml b/pom.xml index 1e26d09906..f51491137e 100644 --- a/pom.xml +++ b/pom.xml @@ -534,6 +534,7 @@ quarkus quarkus-extension + quarkus-jandex rabbitmq @@ -1004,6 +1005,7 @@ quarkus quarkus-extension + quarkus-jandex rabbitmq diff --git a/quarkus-jandex/README.md b/quarkus-jandex/README.md new file mode 100644 index 0000000000..a03cdc708f --- /dev/null +++ b/quarkus-jandex/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Create a Jandex index in Quarkus for classes in a external module](https://www.baeldung.com/quarkus-jandex) diff --git a/quarkus-jandex/hello-app/.dockerignore b/quarkus-jandex/hello-app/.dockerignore new file mode 100644 index 0000000000..94810d006e --- /dev/null +++ b/quarkus-jandex/hello-app/.dockerignore @@ -0,0 +1,5 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* +!target/quarkus-app/* \ No newline at end of file diff --git a/quarkus-jandex/hello-app/.gitignore b/quarkus-jandex/hello-app/.gitignore new file mode 100644 index 0000000000..bdf57ce3b4 --- /dev/null +++ b/quarkus-jandex/hello-app/.gitignore @@ -0,0 +1,39 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties + +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX +.DS_Store + +# Vim +*.swp +*.swo + +# patch +*.orig +*.rej + +# Local environment +.env diff --git a/quarkus-jandex/hello-app/.mvn/wrapper/MavenWrapperDownloader.java b/quarkus-jandex/hello-app/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..c39041cdf6 --- /dev/null +++ b/quarkus-jandex/hello-app/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println("- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/quarkus-jandex/hello-app/.mvn/wrapper/maven-wrapper.properties b/quarkus-jandex/hello-app/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..ffdc10e59f --- /dev/null +++ b/quarkus-jandex/hello-app/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/quarkus-jandex/hello-app/README.md b/quarkus-jandex/hello-app/README.md new file mode 100644 index 0000000000..769709eb00 --- /dev/null +++ b/quarkus-jandex/hello-app/README.md @@ -0,0 +1,51 @@ +# Hello App with Quarkus + +## Running the application in dev mode + +You can run your application in dev mode that enables live coding using: + +```shell script +./mvnw compile quarkus:dev +``` + +You can then find the app using `http://localhost:8080`. + +> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. + +## Packaging and running the application + +The application can be packaged using: + +```shell script +./mvnw package +``` + +It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. + +The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. + +If you want to build an _über-jar_, execute the following command: + +```shell script +./mvnw package -Dquarkus.package.type=uber-jar +``` + +The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. + +## Creating a native executable + +You can create a native executable using: + +```shell script +./mvnw package -Pnative +``` + +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: + +```shell script +./mvnw package -Pnative -Dquarkus.native.container-build=true +``` + +You can then execute your native executable with: `./target/quarkus-sample-1.0-SNAPSHOT-runner` + +If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. diff --git a/quarkus-jandex/hello-app/mvnw b/quarkus-jandex/hello-app/mvnw new file mode 100644 index 0000000000..a16b5431b4 --- /dev/null +++ b/quarkus-jandex/hello-app/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/quarkus-jandex/hello-app/mvnw.cmd b/quarkus-jandex/hello-app/mvnw.cmd new file mode 100644 index 0000000000..c8d43372c9 --- /dev/null +++ b/quarkus-jandex/hello-app/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/quarkus-jandex/hello-app/pom.xml b/quarkus-jandex/hello-app/pom.xml new file mode 100644 index 0000000000..8da874a1c7 --- /dev/null +++ b/quarkus-jandex/hello-app/pom.xml @@ -0,0 +1,131 @@ + + + 4.0.0 + + + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + + + hello-app + + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + ${project.groupId} + hello-service + ${project.version} + + + ${project.groupId} + hello-sender-beans-xml + ${project.version} + + + ${project.groupId} + hello-sender-maven-plugin + ${project.version} + + + ${project.groupId} + hello-sender-application-properties + ${project.version} + + + ${project.groupId} + hello-sender-undetected + ${project.version} + + + + + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + ${compiler-plugin.version} + + ${maven.compiler.parameters} + + + + maven-surefire-plugin + ${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + + native + + + native + + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + + + native + + + + diff --git a/quarkus-jandex/hello-app/src/main/docker/Dockerfile.jvm b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000000..3eb1b4de84 --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.jvm @@ -0,0 +1,55 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-sample-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-sample-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/quarkus-sample-jvm +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 + +ARG JAVA_PACKAGE=java-11-openjdk-headless +ARG RUN_JAVA_VERSION=1.3.8 +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +# Install java and the run-java script +# Also set up permissions for user `1001` +RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ + && microdnf update \ + && microdnf clean all \ + && mkdir /deployments \ + && chown 1001 /deployments \ + && chmod "g+rwX" /deployments \ + && chown 1001:root /deployments \ + && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ + && chown 1001 /deployments/run-java.sh \ + && chmod 540 /deployments/run-java.sh \ + && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security + +# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=1001 target/quarkus-app/*.jar /deployments/ +COPY --chown=1001 target/quarkus-app/app/ /deployments/app/ +COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT [ "/deployments/run-java.sh" ] + diff --git a/quarkus-jandex/hello-app/src/main/docker/Dockerfile.legacy-jar b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.legacy-jar new file mode 100644 index 0000000000..f32188a45d --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.legacy-jar @@ -0,0 +1,51 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package -Dquarkus.package.type=legacy-jar +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/quarkus-sample-legacy-jar . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-sample-legacy-jar +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/quarkus-sample-legacy-jar +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 + +ARG JAVA_PACKAGE=java-11-openjdk-headless +ARG RUN_JAVA_VERSION=1.3.8 +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +# Install java and the run-java script +# Also set up permissions for user `1001` +RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ + && microdnf update \ + && microdnf clean all \ + && mkdir /deployments \ + && chown 1001 /deployments \ + && chmod "g+rwX" /deployments \ + && chown 1001:root /deployments \ + && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ + && chown 1001 /deployments/run-java.sh \ + && chmod 540 /deployments/run-java.sh \ + && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security + +# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/app.jar + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT [ "/deployments/run-java.sh" ] diff --git a/quarkus-jandex/hello-app/src/main/docker/Dockerfile.native b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.native new file mode 100644 index 0000000000..4fa16507fe --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.native @@ -0,0 +1,27 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# +# Before building the container image run: +# +# ./mvnw package -Pnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-sample . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-sample +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/quarkus-jandex/hello-app/src/main/docker/Dockerfile.native-distroless b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.native-distroless new file mode 100644 index 0000000000..86370b0a0b --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/docker/Dockerfile.native-distroless @@ -0,0 +1,23 @@ +#### +# This Dockerfile is used in order to build a distroless container that runs the Quarkus application in native (no JVM) mode +# +# Before building the container image run: +# +# ./mvnw package -Pnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-distroless -t quarkus/quarkus-sample . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-sample +# +### +FROM quay.io/quarkus/quarkus-distroless-image:1.0 +COPY target/*-runner /application + +EXPOSE 8080 +USER nonroot + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/quarkus-jandex/hello-app/src/main/java/com/baeldung/quarkus/hello/HelloResource.java b/quarkus-jandex/hello-app/src/main/java/com/baeldung/quarkus/hello/HelloResource.java new file mode 100644 index 0000000000..1867527327 --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/java/com/baeldung/quarkus/hello/HelloResource.java @@ -0,0 +1,26 @@ +package com.baeldung.quarkus.hello; + +import com.baeldung.quarkus.hello.service.HelloService; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/hello") +public class HelloResource { + + @Inject + HelloService service; + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + StringBuilder sb = new StringBuilder(); + sb.append("Those are saying hello:\n=======================\n\n"); + service.sendHello(s -> sb.append(" - ").append(s).append("\n")); + return sb.toString(); + } + +} diff --git a/quarkus-jandex/hello-app/src/main/resources/META-INF/resources/index.html b/quarkus-jandex/hello-app/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000..ba625a1420 --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,14 @@ + + + + + qHello App + + + +

Hello App

+ +This app demonstrates how Quarkus resolves CDI managed beans. You can find the output of all resolved beans by invoking the Hello Resource. + + + diff --git a/quarkus-jandex/hello-app/src/main/resources/application.properties b/quarkus-jandex/hello-app/src/main/resources/application.properties new file mode 100644 index 0000000000..95ff9889c7 --- /dev/null +++ b/quarkus-jandex/hello-app/src/main/resources/application.properties @@ -0,0 +1,2 @@ +quarkus.index-dependency.hello-sender.group-id=com.baeldung.quarkus +quarkus.index-dependency.hello-sender.artifact-id=hello-sender-application-properties diff --git a/quarkus-jandex/hello-sender-application-properties/pom.xml b/quarkus-jandex/hello-sender-application-properties/pom.xml new file mode 100644 index 0000000000..01784b44f4 --- /dev/null +++ b/quarkus-jandex/hello-sender-application-properties/pom.xml @@ -0,0 +1,26 @@ + + + + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + + 4.0.0 + + hello-sender-application-properties + + + + io.quarkus + quarkus-arc + + + ${project.groupId} + hello-service + ${project.version} + + + + diff --git a/quarkus-jandex/hello-sender-application-properties/src/main/java/com/baeldung/quarkus/hello/sender/applicationproperties/ApplicationPropertiesHelloSender.java b/quarkus-jandex/hello-sender-application-properties/src/main/java/com/baeldung/quarkus/hello/sender/applicationproperties/ApplicationPropertiesHelloSender.java new file mode 100644 index 0000000000..ffd495e92e --- /dev/null +++ b/quarkus-jandex/hello-sender-application-properties/src/main/java/com/baeldung/quarkus/hello/sender/applicationproperties/ApplicationPropertiesHelloSender.java @@ -0,0 +1,15 @@ +package com.baeldung.quarkus.hello.sender.applicationproperties; + +import com.baeldung.quarkus.hello.service.HelloRetrieving; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; + +@ApplicationScoped +public class ApplicationPropertiesHelloSender { + + public void sendHello(@Observes HelloRetrieving event) { + event.getHelloReceiver().accept("Hi, I was detected by inserting this module's groupId and artifactId into the app's application.properties file."); + } + +} diff --git a/quarkus-jandex/hello-sender-beans-xml/pom.xml b/quarkus-jandex/hello-sender-beans-xml/pom.xml new file mode 100644 index 0000000000..30cabcc91d --- /dev/null +++ b/quarkus-jandex/hello-sender-beans-xml/pom.xml @@ -0,0 +1,26 @@ + + + + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + + 4.0.0 + + hello-sender-beans-xml + + + + io.quarkus + quarkus-arc + + + ${project.groupId} + hello-service + ${project.version} + + + + diff --git a/quarkus-jandex/hello-sender-beans-xml/src/main/java/com/baeldung/quarkus/hello/sender/beansxml/BeansXmlHelloSender.java b/quarkus-jandex/hello-sender-beans-xml/src/main/java/com/baeldung/quarkus/hello/sender/beansxml/BeansXmlHelloSender.java new file mode 100644 index 0000000000..bed6a7793d --- /dev/null +++ b/quarkus-jandex/hello-sender-beans-xml/src/main/java/com/baeldung/quarkus/hello/sender/beansxml/BeansXmlHelloSender.java @@ -0,0 +1,15 @@ +package com.baeldung.quarkus.hello.sender.beansxml; + +import com.baeldung.quarkus.hello.service.HelloRetrieving; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; + +@ApplicationScoped +public class BeansXmlHelloSender { + + public void sendHello(@Observes HelloRetrieving event) { + event.getHelloReceiver().accept("Hi, I was detected using an empty META-INF/beans.xml file."); + } + +} diff --git a/quarkus-jandex/hello-sender-beans-xml/src/main/resources/META-INF/beans.xml b/quarkus-jandex/hello-sender-beans-xml/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/quarkus-jandex/hello-sender-maven-plugin/pom.xml b/quarkus-jandex/hello-sender-maven-plugin/pom.xml new file mode 100644 index 0000000000..ad226f38dd --- /dev/null +++ b/quarkus-jandex/hello-sender-maven-plugin/pom.xml @@ -0,0 +1,46 @@ + + + + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + + 4.0.0 + + hello-sender-maven-plugin + + + + io.quarkus + quarkus-arc + + + ${project.groupId} + hello-service + ${project.version} + + + + + + + + org.jboss.jandex + jandex-maven-plugin + 1.2.1 + + + make-index + + + jandex + + + + + + + + diff --git a/quarkus-jandex/hello-sender-maven-plugin/src/main/java/com/baeldung/quarkus/hello/sender/mavenplugin/MavenPluginHelloSender.java b/quarkus-jandex/hello-sender-maven-plugin/src/main/java/com/baeldung/quarkus/hello/sender/mavenplugin/MavenPluginHelloSender.java new file mode 100644 index 0000000000..ca08eef5ac --- /dev/null +++ b/quarkus-jandex/hello-sender-maven-plugin/src/main/java/com/baeldung/quarkus/hello/sender/mavenplugin/MavenPluginHelloSender.java @@ -0,0 +1,15 @@ +package com.baeldung.quarkus.hello.sender.mavenplugin; + +import com.baeldung.quarkus.hello.service.HelloRetrieving; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; + +@ApplicationScoped +public class MavenPluginHelloSender { + + public void sendHello(@Observes HelloRetrieving event) { + event.getHelloReceiver().accept("Hi, I was detected using the Jandex Maven Plugin."); + } + +} diff --git a/quarkus-jandex/hello-sender-undetected/pom.xml b/quarkus-jandex/hello-sender-undetected/pom.xml new file mode 100644 index 0000000000..0d8cb29a98 --- /dev/null +++ b/quarkus-jandex/hello-sender-undetected/pom.xml @@ -0,0 +1,26 @@ + + + + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + + 4.0.0 + + hello-sender-undetected + + + + io.quarkus + quarkus-arc + + + ${project.groupId} + hello-service + ${project.version} + + + + diff --git a/quarkus-jandex/hello-sender-undetected/src/main/java/com/baeldung/quarkus/hello/sender/undetected/UndetectedHelloSender.java b/quarkus-jandex/hello-sender-undetected/src/main/java/com/baeldung/quarkus/hello/sender/undetected/UndetectedHelloSender.java new file mode 100644 index 0000000000..a39e610b2a --- /dev/null +++ b/quarkus-jandex/hello-sender-undetected/src/main/java/com/baeldung/quarkus/hello/sender/undetected/UndetectedHelloSender.java @@ -0,0 +1,15 @@ +package com.baeldung.quarkus.hello.sender.undetected; + +import com.baeldung.quarkus.hello.service.HelloRetrieving; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; + +@ApplicationScoped +public class UndetectedHelloSender { + + public void sendHello(@Observes HelloRetrieving event) { + event.getHelloReceiver().accept("Hi, I do not create a Jandex index, so I should not get detected."); + } + +} diff --git a/quarkus-jandex/hello-service/pom.xml b/quarkus-jandex/hello-service/pom.xml new file mode 100644 index 0000000000..274423c526 --- /dev/null +++ b/quarkus-jandex/hello-service/pom.xml @@ -0,0 +1,21 @@ + + + + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + + 4.0.0 + + hello-service + + + + io.quarkus + quarkus-arc + + + + diff --git a/quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloRetrieving.java b/quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloRetrieving.java new file mode 100644 index 0000000000..513e2ff245 --- /dev/null +++ b/quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloRetrieving.java @@ -0,0 +1,17 @@ +package com.baeldung.quarkus.hello.service; + +import java.util.function.Consumer; + +public class HelloRetrieving { + + private final Consumer helloReceiver; + + public HelloRetrieving(Consumer helloReceiver) { + this.helloReceiver = helloReceiver; + } + + public Consumer getHelloReceiver() { + return helloReceiver; + } + +} diff --git a/quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloService.java b/quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloService.java new file mode 100644 index 0000000000..4b93d2f12f --- /dev/null +++ b/quarkus-jandex/hello-service/src/main/java/com/baeldung/quarkus/hello/service/HelloService.java @@ -0,0 +1,18 @@ +package com.baeldung.quarkus.hello.service; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Event; +import javax.inject.Inject; +import java.util.function.Consumer; + +@ApplicationScoped +public class HelloService { + + @Inject + Event helloRetrievingEvent; + + public void sendHello(Consumer target) { + helloRetrievingEvent.fire(new HelloRetrieving(target)); + } + +} diff --git a/quarkus-jandex/hello-service/src/main/resources/META-INF/beans.xml b/quarkus-jandex/hello-service/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/quarkus-jandex/pom.xml b/quarkus-jandex/pom.xml new file mode 100644 index 0000000000..e8e66b44b1 --- /dev/null +++ b/quarkus-jandex/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + com.baeldung.quarkus + quarkus-jandex + 1.0.0-SNAPSHOT + pom + + + hello-service + hello-sender-beans-xml + hello-sender-maven-plugin + hello-sender-application-properties + hello-sender-undetected + hello-app + + + + 3.8.1 + true + 11 + 11 + UTF-8 + UTF-8 + quarkus-bom + io.quarkus.platform + 2.3.0.Final + 3.0.0-M5 + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + From 00b22063ef0acd1aa7ea0d19a369d050d20c7554 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Wed, 20 Oct 2021 18:59:46 +0200 Subject: [PATCH 052/551] Feature/bael 5177 switch pattern matching (#11345) * BAEL-5177: New module using Java 17 * BAEL-5177: Add unit tests * BAEL-5177: Add switch example * BAEL-5177: Update type pattern test * BAEL-5177: Total type example * BAEL-5177: Refactor * BAEL-5177: Move implementation to separate class * BAEL-5177: Tabs to spaces --- core-java-modules/core-java-17/README.md | 3 + core-java-modules/core-java-17/pom.xml | 81 +++++++++++++++++++ .../switchpatterns/GuardedPatterns.java | 25 ++++++ .../switchpatterns/HandlingNullValues.java | 20 +++++ .../switchpatterns/ParenthesizedPatterns.java | 29 +++++++ .../switchpatterns/PatternMatching.java | 14 ++++ .../switchpatterns/SwitchStatement.java | 14 ++++ .../baeldung/switchpatterns/TypePatterns.java | 30 +++++++ .../GuardedPatternsUnitTest.java | 30 +++++++ .../HandlingNullValuesUnitTest.java | 30 +++++++ .../ParenthesizedPatternsUnitTest.java | 40 +++++++++ .../switchpatterns/TypePatternsUnitTest.java | 49 +++++++++++ 12 files changed, 365 insertions(+) create mode 100644 core-java-modules/core-java-17/README.md create mode 100644 core-java-modules/core-java-17/pom.xml create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/GuardedPatterns.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/HandlingNullValues.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/ParenthesizedPatterns.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/PatternMatching.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/SwitchStatement.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/TypePatterns.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/GuardedPatternsUnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/HandlingNullValuesUnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/ParenthesizedPatternsUnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/TypePatternsUnitTest.java diff --git a/core-java-modules/core-java-17/README.md b/core-java-modules/core-java-17/README.md new file mode 100644 index 0000000000..798fd3a903 --- /dev/null +++ b/core-java-modules/core-java-17/README.md @@ -0,0 +1,3 @@ +### Relevant articles: + +- TODO \ No newline at end of file diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml new file mode 100644 index 0000000000..f9a7ec326b --- /dev/null +++ b/core-java-modules/core-java-17/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + core-java-17 + 0.1.0-SNAPSHOT + core-java-17 + jar + http://maven.apache.org + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.release} + --enable-preview + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + --enable-preview + 1 + + + + org.apache.maven.surefire + surefire-api + ${surefire.plugin.version} + + + + + + + + 17 + 17 + 17 + 3.8.1 + 3.0.0-M5 + 3.17.2 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/GuardedPatterns.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/GuardedPatterns.java new file mode 100644 index 0000000000..a76287f64a --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/GuardedPatterns.java @@ -0,0 +1,25 @@ +package com.baeldung.switchpatterns; + +public class GuardedPatterns { + + static double getDoubleValueUsingIf(Object o) { + return switch (o) { + case String s -> { + if (s.length() > 0) { + yield Double.parseDouble(s); + } else { + yield 0d; + } + } + default -> 0d; + }; + } + + static double getDoubleValueUsingGuardedPatterns(Object o) { + return switch (o) { + case String s && s.length() > 0 -> Double.parseDouble(s); + default -> 0d; + }; + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/HandlingNullValues.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/HandlingNullValues.java new file mode 100644 index 0000000000..8e64480a41 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/HandlingNullValues.java @@ -0,0 +1,20 @@ +package com.baeldung.switchpatterns; + +public class HandlingNullValues { + + static double getDoubleUsingSwitchNullCase(Object o) { + return switch (o) { + case String s -> Double.parseDouble(s); + case null -> 0d; + default -> 0d; + }; + } + + static double getDoubleUsingSwitchTotalType(Object o) { + return switch (o) { + case String s -> Double.parseDouble(s); + case Object ob -> 0d; + }; + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/ParenthesizedPatterns.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/ParenthesizedPatterns.java new file mode 100644 index 0000000000..49dd5edb31 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/ParenthesizedPatterns.java @@ -0,0 +1,29 @@ +package com.baeldung.switchpatterns; + +public class ParenthesizedPatterns { + + static double getDoubleValueUsingIf(Object o) { + return switch (o) { + case String s -> { + if (s.length() > 0) { + if (s.contains("#") || s.contains("@")) { + yield 0d; + } else { + yield Double.parseDouble(s); + } + } else { + yield 0d; + } + } + default -> 0d; + }; + } + + static double getDoubleValueUsingParenthesizedPatterns(Object o) { + return switch (o) { + case String s && s.length() > 0 && !(s.contains("#") || s.contains("@")) -> Double.parseDouble(s); + default -> 0d; + }; + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/PatternMatching.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/PatternMatching.java new file mode 100644 index 0000000000..f026caa3f1 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/PatternMatching.java @@ -0,0 +1,14 @@ +package com.baeldung.switchpatterns; + +public class PatternMatching { + + public static void main(String[] args) { + Object o = args[0]; + if (o instanceof String s) { + System.out.printf("Object is a string %s", s); + } else if(o instanceof Number n) { + System.out.printf("Object is a number %n", n); + } + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/SwitchStatement.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/SwitchStatement.java new file mode 100644 index 0000000000..17d2b1856d --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/SwitchStatement.java @@ -0,0 +1,14 @@ +package com.baeldung.switchpatterns; + +public class SwitchStatement { + + public static void main(String[] args) { + final String b = "B"; + switch (args[0]) { + case "A" -> System.out.println("Parameter is A"); + case b -> System.out.println("Parameter is b"); + default -> System.out.println("Parameter is unknown"); + }; + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/TypePatterns.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/TypePatterns.java new file mode 100644 index 0000000000..47af090ad0 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/switchpatterns/TypePatterns.java @@ -0,0 +1,30 @@ +package com.baeldung.switchpatterns; + +public class TypePatterns { + + static double getDoubleUsingIf(Object o) { + double result; + + if (o instanceof Integer) { + result = ((Integer) o).doubleValue(); + } else if (o instanceof Float) { + result = ((Float) o).doubleValue(); + } else if (o instanceof String) { + result = Double.parseDouble(((String) o)); + } else { + result = 0d; + } + + return result; + } + + static double getDoubleUsingSwitch(Object o) { + return switch (o) { + case Integer i -> i.doubleValue(); + case Float f -> f.doubleValue(); + case String s -> Double.parseDouble(s); + default -> 0d; + }; + } + +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/GuardedPatternsUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/GuardedPatternsUnitTest.java new file mode 100644 index 0000000000..cff8b1caca --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/GuardedPatternsUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.switchpatterns; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static com.baeldung.switchpatterns.GuardedPatterns.*; + +class GuardedPatternsUnitTest { + + @Test + void givenIfImplementation_whenUsingEmptyString_thenDoubleIsReturned() { + assertEquals(0d, getDoubleValueUsingIf("")); + } + + @Test + void givenIfImplementation_whenUsingNonEmptyString_thenDoubleIsReturned() { + assertEquals(10d, getDoubleValueUsingIf("10")); + } + + @Test + void givenPatternsImplementation_whenUsingEmptyString_thenDoubleIsReturned() { + assertEquals(0d, getDoubleValueUsingGuardedPatterns("")); + } + + @Test + void givenPatternsImplementation_whenUsingNonEmptyString_thenDoubleIsReturned() { + assertEquals(10d, getDoubleValueUsingGuardedPatterns("10")); + } + +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/HandlingNullValuesUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/HandlingNullValuesUnitTest.java new file mode 100644 index 0000000000..ffe045cc26 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/HandlingNullValuesUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.switchpatterns; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static com.baeldung.switchpatterns.HandlingNullValues.*; + +class HandlingNullValuesUnitTest { + + @Test + void givenNullCaseInSwitch_whenUsingStringAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingSwitchNullCase("10")); + } + + @Test + void givenTotalTypeInSwitch_whenUsingNullArgument_thenDoubleIsReturned() { + assertEquals(0d, getDoubleUsingSwitchNullCase(null)); + } + + @Test + void givenTotalTypeInSwitch_whenUsingStringAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingSwitchTotalType("10")); + } + + @Test + void givenNullCaseInSwitch_whenUsingNullArgument_thenDoubleIsReturned() { + assertEquals(0d, getDoubleUsingSwitchTotalType(null)); + } + +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/ParenthesizedPatternsUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/ParenthesizedPatternsUnitTest.java new file mode 100644 index 0000000000..9548c9f0b6 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/ParenthesizedPatternsUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.switchpatterns; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static com.baeldung.switchpatterns.ParenthesizedPatterns.*; + +class ParenthesizedPatternsUnitTest { + + @Test + void givenIfImplementation_whenUsingEmptyString_thenDoubleIsReturned() { + assertEquals(0d, getDoubleValueUsingIf("")); + } + + @Test + void givenIfImplementation_whenUsingNonEmptyString_thenDoubleIsReturned() { + assertEquals(10d, getDoubleValueUsingIf("10")); + } + + @Test + void givenIfImplementation_whenStringContainsSpecialChar_thenDoubleIsReturned() { + assertEquals(0d, getDoubleValueUsingIf("@10")); + } + + @Test + void givenPatternsImplementation_whenUsingEmptyString_thenDoubleIsReturned() { + assertEquals(0d, getDoubleValueUsingParenthesizedPatterns("")); + } + + @Test + void givenPatternsImplementation_whenUsingNonEmptyString_thenDoubleIsReturned() { + assertEquals(10d, getDoubleValueUsingParenthesizedPatterns("10")); + } + + @Test + void givenPatternsImplementation_whenStringContainsSpecialChar_thenDoubleIsReturned() { + assertEquals(0d, getDoubleValueUsingParenthesizedPatterns("@10")); + } + +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/TypePatternsUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/TypePatternsUnitTest.java new file mode 100644 index 0000000000..25988be53d --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/switchpatterns/TypePatternsUnitTest.java @@ -0,0 +1,49 @@ +package com.baeldung.switchpatterns; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static com.baeldung.switchpatterns.TypePatterns.*; + +class TypePatternsUnitTest { + + @Test + void givenIfImplementation_whenUsingIntegerAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingIf(10)); + } + + @Test + void givenIfImplementation_whenUsingDoubleAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingIf(10.0f)); + } + + @Test + void givenIfImplementation_whenUsingStringAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingIf("10")); + } + + @Test + void givenIfImplementation_whenUsingCharAsArgument_thenDoubleIsReturned() { + assertEquals(0d, getDoubleUsingIf('c')); + } + + @Test + void givenSwitchImplementation_whenUsingIntegerAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingSwitch(10)); + } + + @Test + void givenSwitchImplementation_whenUsingDoubleAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingSwitch(10.0f)); + } + + @Test + void givenSwitchImplementation_whenUsingStringAsArgument_thenDoubleIsReturned() { + assertEquals(10d, getDoubleUsingSwitch("10")); + } + + @Test + void givenSwitchImplementation_whenUsingCharAsArgument_thenDoubleIsReturned() { + assertEquals(0d, getDoubleUsingSwitch('c')); + } + +} From 3d58e691a4e42b45ce32df846eae3c09067b54ca Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 21:58:48 +0800 Subject: [PATCH 053/551] Update README.md --- testing-modules/junit-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/junit-4/README.md b/testing-modules/junit-4/README.md index cb5def7144..1f7517c5b9 100644 --- a/testing-modules/junit-4/README.md +++ b/testing-modules/junit-4/README.md @@ -7,3 +7,4 @@ - [Introduction to Lambda Behave](https://www.baeldung.com/lambda-behave) - [Conditionally Run or Ignore Tests in JUnit 4](https://www.baeldung.com/junit-conditional-assume) - [JUnit 4 on How to Ignore a Base Test Class](https://www.baeldung.com/junit-ignore-base-test-class) +- [Using Fail Assertion in JUnit](https://www.baeldung.com/junit-fail) From ebd12c4cd002b20884ad86ad75067e78acf3e445 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:00:30 +0800 Subject: [PATCH 054/551] Update README.md --- ratpack/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ratpack/README.md b/ratpack/README.md index 9c24670709..f42d4c030b 100644 --- a/ratpack/README.md +++ b/ratpack/README.md @@ -11,3 +11,4 @@ This module contains articles about Ratpack. - [Ratpack HTTP Client](https://www.baeldung.com/ratpack-http-client) - [Ratpack with RxJava](https://www.baeldung.com/ratpack-rxjava) - [Ratpack with Groovy](https://www.baeldung.com/ratpack-groovy) +- [Reactive Streams API with Ratpack](https://www.baeldung.com/ratpack-reactive-streams-api) From 12410d9bbc57ceb8cdb035c9ab1481eb0ac03da0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:02:15 +0800 Subject: [PATCH 055/551] Update README.md --- spring-boot-modules/spring-boot-environment/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-environment/README.md b/spring-boot-modules/spring-boot-environment/README.md index e7b0ace7a4..687322938e 100644 --- a/spring-boot-modules/spring-boot-environment/README.md +++ b/spring-boot-modules/spring-boot-environment/README.md @@ -6,3 +6,4 @@ This module contains articles about configuring the Spring Boot `Environment` - [EnvironmentPostProcessor in Spring Boot](https://www.baeldung.com/spring-boot-environmentpostprocessor) - [Spring Properties File Outside jar](https://www.baeldung.com/spring-properties-file-outside-jar) - [Get the Running Port in Spring Boot](https://www.baeldung.com/spring-boot-running-port) + - [Environment Variable Prefixes in Spring Boot 2.5](https://www.baeldung.com/spring-boot-env-variable-prefixes) From 6b244618b8503220a9640bc2c67249f84f1d4916 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:04:21 +0800 Subject: [PATCH 056/551] Update README.md --- core-java-modules/core-java-arrays-convert/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-arrays-convert/README.md b/core-java-modules/core-java-arrays-convert/README.md index 4bd060a246..b28b97cb09 100644 --- a/core-java-modules/core-java-arrays-convert/README.md +++ b/core-java-modules/core-java-arrays-convert/README.md @@ -5,3 +5,4 @@ This module contains articles about arrays conversion in Java ## Relevant Articles - [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array) - [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array) +- [Convert a Byte Array to a Numeric Representation in Java](https://www.baeldung.com/java-byte-array-to-number) From 8ae64fa5dc5ebe4f393286a7be7c775854481ce1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:06:53 +0800 Subject: [PATCH 057/551] Update README.md --- core-java-modules/core-java-string-operations-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-3/README.md b/core-java-modules/core-java-string-operations-3/README.md index f4cde6104f..1a131c57ac 100644 --- a/core-java-modules/core-java-string-operations-3/README.md +++ b/core-java-modules/core-java-string-operations-3/README.md @@ -6,3 +6,4 @@ - [Split a String in Java and Keep the Delimiters](https://www.baeldung.com/java-split-string-keep-delimiters) - [Validate String as Filename in Java](https://www.baeldung.com/java-validate-filename) - [Count Spaces in a Java String](https://www.baeldung.com/java-string-count-spaces) +- [Remove Accents and Diacritics From a String in Java](https://www.baeldung.com/java-remove-accents-from-text) From 06afc4c7b6a02ac8f82686deb62766a94f742a84 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:08:29 +0800 Subject: [PATCH 058/551] Update README.md --- testing-modules/junit-5-advanced/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/junit-5-advanced/README.md b/testing-modules/junit-5-advanced/README.md index 5d70e6f058..7790cb6770 100644 --- a/testing-modules/junit-5-advanced/README.md +++ b/testing-modules/junit-5-advanced/README.md @@ -4,3 +4,4 @@ - [JUnit Custom Display Name Generator API](https://www.baeldung.com/junit-custom-display-name-generator) - [@TestInstance Annotation in JUnit 5](https://www.baeldung.com/junit-testinstance-annotation) - [Run JUnit Test Cases From the Command Line](https://www.baeldung.com/junit-run-from-command-line) +- [Parallel Test Execution for JUnit 5](https://www.baeldung.com/junit-5-parallel-tests) From 70d973a22fedf0de6a0dd7ed77c501a5c6e03a01 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:10:30 +0800 Subject: [PATCH 059/551] Create README.md --- rule-engines/evrete/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 rule-engines/evrete/README.md diff --git a/rule-engines/evrete/README.md b/rule-engines/evrete/README.md new file mode 100644 index 0000000000..aa9a3a4b9d --- /dev/null +++ b/rule-engines/evrete/README.md @@ -0,0 +1,3 @@ +## Relevant Articles: + +- [Introduction to the Evrete Rule Engine](https://www.baeldung.com/java-evrete-rule-engine) From 6194ed1d086eb678d33473930fe648db17ae4fc3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:12:41 +0800 Subject: [PATCH 060/551] Update README.md --- core-java-modules/core-java-17/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-17/README.md b/core-java-modules/core-java-17/README.md index 798fd3a903..074c5e4f86 100644 --- a/core-java-modules/core-java-17/README.md +++ b/core-java-modules/core-java-17/README.md @@ -1,3 +1,3 @@ ### Relevant articles: -- TODO \ No newline at end of file +- [Pattern Matching for Switch](https://www.baeldung.com/java-switch-pattern-matching) From a591d1ff74cdd114686a1b01f72b1efc0d3bf8ac Mon Sep 17 00:00:00 2001 From: kwoyke Date: Thu, 21 Oct 2021 22:30:52 +0200 Subject: [PATCH 061/551] JAVA-7662: Upgrade jmh-core and jmh-generator dependencies to 1.33 (#11311) --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1e26d09906..7263c95599 100644 --- a/pom.xml +++ b/pom.xml @@ -1403,8 +1403,8 @@ 1.8 1.2.17 2.2.2.0 - 1.28 - 1.28 + 1.33 + 1.33 2.21.0 2.11.0 2.6 From e944857c0589cb4309429b7f02a72860b3e0d983 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Thu, 21 Oct 2021 22:48:44 +0200 Subject: [PATCH 062/551] JAVA-7659: Upgrade byte-buddy to 1.11.20 (#11319) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7263c95599..4709d4a86a 100644 --- a/pom.xml +++ b/pom.xml @@ -1389,7 +1389,7 @@ 2.2 1.3 3.3.0 - 1.10.22 + 1.11.20 1.7.30 From d6be7a2528828a51449b392ead093eecd6845e9d Mon Sep 17 00:00:00 2001 From: Kayvan Tehrani Date: Sat, 23 Oct 2021 20:16:51 +0330 Subject: [PATCH 063/551] resolving (BAEL-5148) Get String Character by Index in Java (#11340) * resolving (BAEL-5148) Get String Character by Index in Java * changing method name from *_thenCorrect() to *_thenSuccess() * reverted README changes according to the editor suggestion * extra snippet removed inorder to comply with the article edits --- .../stringapi/StringCharAtUnitTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 core-java-modules/core-java-string-apis/src/test/java/com/baeldung/stringapi/StringCharAtUnitTest.java diff --git a/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/stringapi/StringCharAtUnitTest.java b/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/stringapi/StringCharAtUnitTest.java new file mode 100644 index 0000000000..5d31b337ef --- /dev/null +++ b/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/stringapi/StringCharAtUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.stringapi; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class StringCharAtUnitTest { + @Test + public void whenCallCharAt_thenSuccess() { + String sample = "abcdefg"; + assertEquals('d', sample.charAt(3)); + } + + @Test() + public void whenCharAtNonExist_thenIndexOutOfBoundsExceptionThrown() { + String sample = "abcdefg"; + assertThrows(IndexOutOfBoundsException.class, () -> sample.charAt(-1)); + assertThrows(IndexOutOfBoundsException.class, () -> sample.charAt(sample.length())); + } + + @Test + public void whenCallCharAt_thenReturnString() { + String sample = "abcdefg"; + assertEquals("a", Character.toString(sample.charAt(0))); + assertEquals("a", String.valueOf(sample.charAt(0))); + } + +} \ No newline at end of file From 40c6b489d8a55ffa7f46448c5e3b8debfe34b357 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sun, 24 Oct 2021 07:03:35 +0530 Subject: [PATCH 064/551] Update SerializationUnitTest.java Changes to add more tests. --- .../serialization/SerializationUnitTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java index b5795d362c..e0ee2bb654 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java @@ -3,9 +3,11 @@ package com.baeldung.serialization; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.NotSerializableException; +import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -23,6 +25,25 @@ public class SerializationUnitTest { objectOutputStream.writeObject(address); } } + + @Test + public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOException, ClassNotFoundException { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + + FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt"); + try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { + objectOutputStream.writeObject(p); + } + + FileInputStream fileInputStream = new FileInputStream("yofile.txt"); + try ( ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) { + Person p2 = (Person) objectInputStream.readObject(); + assertTrue(p2.getAge() == p.getAge()); + assertTrue(p2.getName().equals(p.getName())); + } + } @Test(expected = ClassCastException.class) public void whenSerializingUsingApacheCommons_ThenThrowsError() { From 4c600af55d8b546739e5490370d0aed1164bdae1 Mon Sep 17 00:00:00 2001 From: freelansam <79205526+freelansam@users.noreply.github.com> Date: Mon, 25 Oct 2021 01:36:50 +0530 Subject: [PATCH 065/551] JAVA-7782: Align module names, folder names and artifact id (#11361) * JAVA-7782: Align module names, folder names and artifact id * JAVA-7782: Align module names, folder names and artifact id --- ksqldb/pom.xml | 2 +- .../maven-copy-files/maven-resources-plugin/pom.xml | 2 +- .../README.md | 0 .../pom.xml | 7 +++---- .../src/main/java/com/baeldung/Main.java | 0 maven-modules/pom.xml | 2 +- patterns/simplehexagonalexample/pom.xml | 2 +- .../bin/eureka-client/pom.xml | 2 +- .../bin/eureka-server/pom.xml | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) rename maven-modules/{maven-dependency-management => maven-dependency}/README.md (100%) rename maven-modules/{maven-dependency-management => maven-dependency}/pom.xml (88%) rename maven-modules/{maven-dependency-management => maven-dependency}/src/main/java/com/baeldung/Main.java (100%) diff --git a/ksqldb/pom.xml b/ksqldb/pom.xml index 970e8c3788..2f92419d6e 100644 --- a/ksqldb/pom.xml +++ b/ksqldb/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - ksqldb-app + ksqldb 0.0.1-SNAPSHOT ksqldb diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml index eed40565da..8942c84f6f 100644 --- a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml @@ -6,7 +6,7 @@ org.baeldung maven-resources-plugin 1.0-SNAPSHOT - maven-resoures-plugin + maven-resources-plugin maven-copy-files diff --git a/maven-modules/maven-dependency-management/README.md b/maven-modules/maven-dependency/README.md similarity index 100% rename from maven-modules/maven-dependency-management/README.md rename to maven-modules/maven-dependency/README.md diff --git a/maven-modules/maven-dependency-management/pom.xml b/maven-modules/maven-dependency/pom.xml similarity index 88% rename from maven-modules/maven-dependency-management/pom.xml rename to maven-modules/maven-dependency/pom.xml index fb2bdfe602..7f80ea1222 100644 --- a/maven-modules/maven-dependency-management/pom.xml +++ b/maven-modules/maven-dependency/pom.xml @@ -1,9 +1,8 @@ + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.baeldung maven-dependency 1.0.0-SNAPSHOT @@ -15,7 +14,6 @@ 0.0.1-SNAPSHOT - @@ -42,4 +40,5 @@ commons-lang3 + \ No newline at end of file diff --git a/maven-modules/maven-dependency-management/src/main/java/com/baeldung/Main.java b/maven-modules/maven-dependency/src/main/java/com/baeldung/Main.java similarity index 100% rename from maven-modules/maven-dependency-management/src/main/java/com/baeldung/Main.java rename to maven-modules/maven-dependency/src/main/java/com/baeldung/Main.java diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index 3f87c60406..54dc5e6ff6 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -37,7 +37,7 @@ plugin-management maven-surefire-plugin maven-parent-pom-resolution - maven-dependency-management + maven-dependency
\ No newline at end of file diff --git a/patterns/simplehexagonalexample/pom.xml b/patterns/simplehexagonalexample/pom.xml index d9b9b36831..31e829b7dc 100644 --- a/patterns/simplehexagonalexample/pom.xml +++ b/patterns/simplehexagonalexample/pom.xml @@ -4,7 +4,7 @@ 4.0.0 1.0.0-SNAPSHOT simple-hexagonal-example - simpleHexagonalExample + simple-hexagonal-example com.baeldung diff --git a/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-client/pom.xml b/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-client/pom.xml index 9989893f2f..5c9f85d06e 100644 --- a/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-client/pom.xml +++ b/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-client/pom.xml @@ -5,7 +5,7 @@ 4.0.0 eureka-client 1.0.0-SNAPSHOT - Spring Cloud Eureka Client + eureka-client jar Spring Cloud Eureka Sample Client diff --git a/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-server/pom.xml b/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-server/pom.xml index 34f82a7347..2d2a94d779 100644 --- a/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-server/pom.xml +++ b/spring-cloud/spring-cloud-zuul-eureka-integration/bin/eureka-server/pom.xml @@ -5,7 +5,7 @@ 4.0.0 eureka-server 1.0.0-SNAPSHOT - Spring Cloud Eureka Server + eureka-server jar Spring Cloud Eureka Server Demo From b94cfdc2703137df28dbad871592b2f5d6af99bd Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sun, 24 Oct 2021 22:07:41 +0200 Subject: [PATCH 066/551] JAVA-7661: Upgrade logback to 1.2.6 (#11325) * JAVA-7661: Upgrade logback version to 1.2.6 in the main pom.xml * JAVA-7661: Use logback.version property from the main pom.xml * JAVA-7661: Fix maven-exec-plugin setup --- kubernetes/k8s-intro/pom.xml | 2 +- maven-modules/maven-exec-plugin/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kubernetes/k8s-intro/pom.xml b/kubernetes/k8s-intro/pom.xml index 61722cb2c8..6d1cec9971 100644 --- a/kubernetes/k8s-intro/pom.xml +++ b/kubernetes/k8s-intro/pom.xml @@ -20,7 +20,7 @@ ch.qos.logback logback-classic - 1.2.3 + ${logback.version} diff --git a/maven-modules/maven-exec-plugin/pom.xml b/maven-modules/maven-exec-plugin/pom.xml index 837f31edeb..f0d4706455 100644 --- a/maven-modules/maven-exec-plugin/pom.xml +++ b/maven-modules/maven-exec-plugin/pom.xml @@ -12,7 +12,7 @@ ch.qos.logback logback-classic - ${logback-classic.version} + ${logback.version} @@ -44,9 +44,9 @@ + 1.2.6 3.8.1 1.8 - 1.2.3 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4709d4a86a..aec3e08c9d 100644 --- a/pom.xml +++ b/pom.xml @@ -1393,7 +1393,7 @@ 1.7.30 - 1.2.3 + 1.2.6 From 24864eb3701a99feee6cff62b28b2baef1bf2b36 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Mon, 25 Oct 2021 09:47:50 +0200 Subject: [PATCH 067/551] Feature/bael 5040 cassandra testcontainers (#11124) * BAEL-5040: initial commit - spring data cassandra using boot-2 * BAEL-5040: update test example * BAEL-5040: add brackets * BAEL-5040: use singleton container * BAEL-5040: switch from singleton to nested classes approach * BAEL-5040: package private methods in junit5 * BAEL-5040: Move SpringBootTest annotation to parent class --- .../spring-data-cassandra-2/.gitignore | 33 ++ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 +++++++ .../.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 50710 bytes .../.mvn/wrapper/maven-wrapper.properties | 2 + .../spring-data-cassandra-2/mvnw | 310 ++++++++++++++++++ .../spring-data-cassandra-2/mvnw.cmd | 182 ++++++++++ .../spring-data-cassandra-2/pom.xml | 72 ++++ .../SpringCassandraApplication.java | 15 + .../baeldung/springcassandra/model/Car.java | 77 +++++ .../repository/CarRepository.java | 12 + .../src/main/resources/application.properties | 4 + .../CassandraNestedIntegrationTest.java | 101 ++++++ .../CassandraSimpleIntegrationTest.java | 53 +++ .../src/test/resources/application.properties | 5 + 14 files changed, 983 insertions(+) create mode 100644 persistence-modules/spring-data-cassandra-2/.gitignore create mode 100644 persistence-modules/spring-data-cassandra-2/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.jar create mode 100644 persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.properties create mode 100644 persistence-modules/spring-data-cassandra-2/mvnw create mode 100644 persistence-modules/spring-data-cassandra-2/mvnw.cmd create mode 100644 persistence-modules/spring-data-cassandra-2/pom.xml create mode 100644 persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/SpringCassandraApplication.java create mode 100644 persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/model/Car.java create mode 100644 persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/repository/CarRepository.java create mode 100644 persistence-modules/spring-data-cassandra-2/src/main/resources/application.properties create mode 100644 persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraNestedIntegrationTest.java create mode 100644 persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraSimpleIntegrationTest.java create mode 100644 persistence-modules/spring-data-cassandra-2/src/test/resources/application.properties diff --git a/persistence-modules/spring-data-cassandra-2/.gitignore b/persistence-modules/spring-data-cassandra-2/.gitignore new file mode 100644 index 0000000000..549e00a2a9 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/MavenWrapperDownloader.java b/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..e76d1f3241 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.jar b/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054 GIT binary patch literal 50710 zcmbTd1CVCTmM+|7+wQV$+qP}n>auOywyU~q+qUhh+uxis_~*a##hm*_WW?9E7Pb7N%LRFiwbEGCJ0XP=%-6oeT$XZcYgtzC2~q zk(K08IQL8oTl}>>+hE5YRgXTB@fZ4TH9>7=79e`%%tw*SQUa9~$xKD5rS!;ZG@ocK zQdcH}JX?W|0_Afv?y`-NgLum62B&WSD$-w;O6G0Sm;SMX65z)l%m1e-g8Q$QTI;(Q z+x$xth4KFvH@Bs6(zn!iF#nenk^Y^ce;XIItAoCsow38eq?Y-Auh!1in#Rt-_D>H^ z=EjbclGGGa6VnaMGmMLj`x3NcwA43Jb(0gzl;RUIRAUDcR1~99l2SAPkVhoRMMtN} zXvC<tOmX83grD8GSo_Lo?%lNfhD#EBgPo z*nf@ppMC#B!T)Ae0RG$mlJWmGl7CkuU~B8-==5i;rS;8i6rJ=PoQxf446XDX9g|c> zU64ePyMlsI^V5Jq5A+BPe#e73+kpc_r1tv#B)~EZ;7^67F0*QiYfrk0uVW;Qb=NsG zN>gsuCwvb?s-KQIppEaeXtEMdc9dy6Dfduz-tMTms+i01{eD9JE&h?Kht*$eOl#&L zJdM_-vXs(V#$Ed;5wyNWJdPNh+Z$+;$|%qR(t`4W@kDhd*{(7-33BOS6L$UPDeE_53j${QfKN-0v-HG z(QfyvFNbwPK%^!eIo4ac1;b>c0vyf9}Xby@YY!lkz-UvNp zwj#Gg|4B~?n?G^{;(W;|{SNoJbHTMpQJ*Wq5b{l9c8(%?Kd^1?H1om1de0Da9M;Q=n zUfn{f87iVb^>Exl*nZ0hs(Yt>&V9$Pg`zX`AI%`+0SWQ4Zc(8lUDcTluS z5a_KerZWe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|8E=8**5?qn8#n`*(bt1xRQrdGxyx2y%B$qmw#>ZV$c7%cO#%JM1lY$Y0q?Yuo> ze9KdJoiM)RH*SB%^;TAdX-zEjA7@%y=!0=Zg%iWK7jVI9b&Dk}0$Af&08KHo+ zOwDhFvA(E|ER%a^cdh@^wLUlmIv6?_3=BvX8jKk92L=Y}7Jf5OGMfh` zBdR1wFCi-i5@`9km{isRb0O%TX+f~)KNaEz{rXQa89`YIF;EN&gN)cigu6mNh>?Cm zAO&Im2flv6D{jwm+y<%WsPe4!89n~KN|7}Cb{Z;XweER73r}Qp2 zz}WP4j}U0&(uD&9yGy6`!+_v-S(yG*iytsTR#x_Rc>=6u^vnRDnf1gP{#2>`ffrAC% zTZ5WQ@hAK;P;>kX{D)mIXe4%a5p=LO1xXH@8T?mz7Q@d)$3pL{{B!2{-v70L*o1AO+|n5beiw~ zk@(>m?T3{2k2c;NWc^`4@P&Z?BjxXJ@;x1qhn)9Mn*IFdt_J-dIqx5#d`NfyfX~m( zIS~5)MfZ2Uy?_4W`47i}u0ZgPh<{D|w_d#;D}Q&U$Q-G}xM1A@1f{#%A$jh6Qp&0hQ<0bPOM z-{1Wm&p%%#eb_?x7i;bol EfAhh=DF6Tf literal 0 HcmV?d00001 diff --git a/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.properties b/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..ffdc10e59f --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/persistence-modules/spring-data-cassandra-2/mvnw b/persistence-modules/spring-data-cassandra-2/mvnw new file mode 100644 index 0000000000..a16b5431b4 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/persistence-modules/spring-data-cassandra-2/mvnw.cmd b/persistence-modules/spring-data-cassandra-2/mvnw.cmd new file mode 100644 index 0000000000..c8d43372c9 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/persistence-modules/spring-data-cassandra-2/pom.xml b/persistence-modules/spring-data-cassandra-2/pom.xml new file mode 100644 index 0000000000..0e09448d0f --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + org.baeldung + spring-cassandra + 0.0.1-SNAPSHOT + spring-cassandra + Demo project for Spring Data Cassandra + + + + org.springframework.boot + spring-boot-starter-data-cassandra + + + org.springframework.data + spring-data-cassandra + ${org.springframework.data.version} + + + uk.org.webcompere + system-stubs-core + ${system.stubs.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + org.testcontainers + testcontainers + ${testcontainers.version} + test + + + org.testcontainers + cassandra + ${testcontainers.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + test + + + uk.org.webcompere + system-stubs-jupiter + ${system.stubs.version} + test + + + + + 11 + 3.1.11 + 1.15.3 + 1.1.0 + 5.6.2 + + + diff --git a/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/SpringCassandraApplication.java b/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/SpringCassandraApplication.java new file mode 100644 index 0000000000..66324a7dfa --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/SpringCassandraApplication.java @@ -0,0 +1,15 @@ +package org.baeldung.springcassandra; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; + +@SpringBootApplication +@EnableCassandraRepositories(basePackages = "org.baeldung.springcassandra.repository") +public class SpringCassandraApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringCassandraApplication.class, args); + } + +} diff --git a/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/model/Car.java b/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/model/Car.java new file mode 100644 index 0000000000..f07535770a --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/model/Car.java @@ -0,0 +1,77 @@ +package org.baeldung.springcassandra.model; + +import org.springframework.data.cassandra.core.mapping.PrimaryKey; +import org.springframework.data.cassandra.core.mapping.Table; + +import java.util.Objects; +import java.util.UUID; + +@Table +public class Car { + + @PrimaryKey + private UUID id; + + private String make; + + private String model; + + private int year; + + public Car(UUID id, String make, String model, int year) { + this.id = id; + this.make = make; + this.model = model; + this.year = year; + } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getMake() { + return make; + } + + public void setMake(String make) { + this.make = make; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Car car = (Car) o; + return year == car.year && Objects.equals(id, car.id) && Objects.equals(make, car.make) && Objects.equals(model, car.model); + } + + @Override + public int hashCode() { + return Objects.hash(id, make, model, year); + } + +} diff --git a/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/repository/CarRepository.java b/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/repository/CarRepository.java new file mode 100644 index 0000000000..492c385953 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/main/java/org/baeldung/springcassandra/repository/CarRepository.java @@ -0,0 +1,12 @@ +package org.baeldung.springcassandra.repository; + +import org.baeldung.springcassandra.model.Car; +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.stereotype.Repository; + +import java.util.UUID; + +@Repository +public interface CarRepository extends CassandraRepository { + +} diff --git a/persistence-modules/spring-data-cassandra-2/src/main/resources/application.properties b/persistence-modules/spring-data-cassandra-2/src/main/resources/application.properties new file mode 100644 index 0000000000..bea2021070 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.data.cassandra.keyspace-name=${CASSANDRA_KEYSPACE_NAME} +spring.data.cassandra.contact-points=${CASSANDRA_CONTACT_POINTS} +spring.data.cassandra.port=${CASSANDRA_PORT} +spring.data.cassandra.local-datacenter=datacenter1 \ No newline at end of file diff --git a/persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraNestedIntegrationTest.java b/persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraNestedIntegrationTest.java new file mode 100644 index 0000000000..668f5eabd7 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraNestedIntegrationTest.java @@ -0,0 +1,101 @@ +package org.baeldung.springcassandra; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.utils.UUIDs; +import org.baeldung.springcassandra.model.Car; +import org.baeldung.springcassandra.repository.CarRepository; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.testcontainers.containers.CassandraContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.util.List; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + + +@Testcontainers +@SpringBootTest +class CassandraNestedIntegrationTest { + + private static final String KEYSPACE_NAME = "test"; + + @Container + private static final CassandraContainer cassandra = (CassandraContainer) new CassandraContainer("cassandra:3.11.2") + .withExposedPorts(9042); + + @BeforeAll + static void setupCassandraConnectionProperties() { + System.setProperty("spring.data.cassandra.keyspace-name", KEYSPACE_NAME); + System.setProperty("spring.data.cassandra.contact-points", cassandra.getContainerIpAddress()); + System.setProperty("spring.data.cassandra.port", String.valueOf(cassandra.getMappedPort(9042))); + + createKeyspace(cassandra.getCluster()); + } + + static void createKeyspace(Cluster cluster) { + try(Session session = cluster.connect()) { + session.execute("CREATE KEYSPACE IF NOT EXISTS " + KEYSPACE_NAME + " WITH replication = \n" + + "{'class':'SimpleStrategy','replication_factor':'1'};"); + } + } + + @Nested + class ApplicationContextIntegrationTest { + + @Test + void givenCassandraContainer_whenSpringContextIsBootstrapped_thenContainerIsRunningWithNoExceptions() { + assertThat(cassandra.isRunning()).isTrue(); + } + + } + + @Nested + class CarRepositoryIntegrationTest { + + @Autowired + private CarRepository carRepository; + + @Test + void givenValidCarRecord_whenSavingIt_thenRecordIsSaved() { + UUID carId = UUIDs.timeBased(); + Car newCar = new Car(carId, "Nissan", "Qashqai", 2018); + + carRepository.save(newCar); + + List savedCars = carRepository.findAllById(List.of(carId)); + assertThat(savedCars.get(0)).isEqualTo(newCar); + } + + @Test + void givenExistingCarRecord_whenUpdatingIt_thenRecordIsUpdated() { + UUID carId = UUIDs.timeBased(); + Car existingCar = carRepository.save(new Car(carId, "Nissan", "Qashqai", 2018)); + + existingCar.setModel("X-Trail"); + carRepository.save(existingCar); + + List savedCars = carRepository.findAllById(List.of(carId)); + assertThat(savedCars.get(0).getModel()).isEqualTo("X-Trail"); + } + + @Test + void givenExistingCarRecord_whenDeletingIt_thenRecordIsDeleted() { + UUID carId = UUIDs.timeBased(); + Car existingCar = carRepository.save(new Car(carId, "Nissan", "Qashqai", 2018)); + + carRepository.delete(existingCar); + + List savedCars = carRepository.findAllById(List.of(carId)); + assertThat(savedCars.isEmpty()).isTrue(); + } + + } + +} diff --git a/persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraSimpleIntegrationTest.java b/persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraSimpleIntegrationTest.java new file mode 100644 index 0000000000..fef162a1b7 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/test/java/org/baeldung/springcassandra/CassandraSimpleIntegrationTest.java @@ -0,0 +1,53 @@ +package org.baeldung.springcassandra; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.utils.UUIDs; +import org.baeldung.springcassandra.model.Car; +import org.baeldung.springcassandra.repository.CarRepository; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.testcontainers.containers.CassandraContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.util.List; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +@Testcontainers +@SpringBootTest +class CassandraSimpleIntegrationTest { + + private static final String KEYSPACE_NAME = "test"; + + @Container + private static final CassandraContainer cassandra = (CassandraContainer) new CassandraContainer("cassandra:3.11.2") + .withExposedPorts(9042); + + @BeforeAll + static void setupCassandraConnectionProperties() { + System.setProperty("spring.data.cassandra.keyspace-name", KEYSPACE_NAME); + System.setProperty("spring.data.cassandra.contact-points", cassandra.getContainerIpAddress()); + System.setProperty("spring.data.cassandra.port", String.valueOf(cassandra.getMappedPort(9042))); + + createKeyspace(cassandra.getCluster()); + } + + static void createKeyspace(Cluster cluster) { + try(Session session = cluster.connect()) { + session.execute("CREATE KEYSPACE IF NOT EXISTS " + KEYSPACE_NAME + " WITH replication = \n" + + "{'class':'SimpleStrategy','replication_factor':'1'};"); + } + } + + @Test + void givenCassandraContainer_whenSpringContextIsBootstrapped_thenContainerIsRunningWithNoExceptions() { + assertThat(cassandra.isRunning()).isTrue(); + } + +} diff --git a/persistence-modules/spring-data-cassandra-2/src/test/resources/application.properties b/persistence-modules/spring-data-cassandra-2/src/test/resources/application.properties new file mode 100644 index 0000000000..58f1fe2ab7 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/src/test/resources/application.properties @@ -0,0 +1,5 @@ +spring.data.cassandra.keyspace-name=${CASSANDRA_KEYSPACE_NAME} +spring.data.cassandra.contact-points=${CASSANDRA_CONTACT_POINTS} +spring.data.cassandra.port=${CASSANDRA_PORT} +spring.data.cassandra.local-datacenter=datacenter1 +spring.data.cassandra.schema-action=create_if_not_exists \ No newline at end of file From 8fc2e305518f184d2e5819f30e974d79cebfcadd Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Mon, 25 Oct 2021 13:33:28 +0530 Subject: [PATCH 068/551] JAVA-7665 : Updating jackson dependency in main pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aec3e08c9d..de3f2583d6 100644 --- a/pom.xml +++ b/pom.xml @@ -1415,7 +1415,7 @@ 1.2 2.3.1 1.2 - 2.12.4 + 2.13.0 1.4 1.2.0 5.2.0 From cac3ae3a5e8cadbb8caefd98bc315a8372342cbc Mon Sep 17 00:00:00 2001 From: Bhaskara Navuluri Date: Mon, 25 Oct 2021 15:16:58 +0530 Subject: [PATCH 069/551] Added code for BAEL-4965: Securing SOAP services using Keycloa --- .../spring-boot-keycloak/.gitignore | 24 -- .../.mvn/wrapper/maven-wrapper.jar | Bin 47610 -> 0 bytes .../.mvn/wrapper/maven-wrapper.properties | 1 - spring-boot-modules/spring-boot-keycloak/mvnw | 225 ------------------ .../spring-boot-keycloak/mvnw.cmd | 143 ----------- .../spring-boot-keycloak/pom.xml | 44 +++- .../keycloaksoap/KeycloakSecurityConfig.java | 54 +++++ .../KeycloakSoapServicesApplication.java | 15 ++ .../keycloaksoap/ProductsEndpoint.java | 42 ++++ .../keycloaksoap/WebServiceConfig.java | 75 ++++++ .../resources/application-keycloak.properties | 17 ++ .../src/main/resources/products.xsd | 45 ++++ .../KeycloakSoapIntegrationTest.java | 156 ++++++++++++ .../com/baeldung/keycloaksoap/Utility.java | 12 + .../resources/application-test.properties | 4 + 15 files changed, 463 insertions(+), 394 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-keycloak/.gitignore delete mode 100644 spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar delete mode 100644 spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties delete mode 100755 spring-boot-modules/spring-boot-keycloak/mvnw delete mode 100644 spring-boot-modules/spring-boot-keycloak/mvnw.cmd create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSecurityConfig.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSoapServicesApplication.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/ProductsEndpoint.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/WebServiceConfig.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/resources/application-keycloak.properties create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/resources/products.xsd create mode 100644 spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/Utility.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/test/resources/application-test.properties diff --git a/spring-boot-modules/spring-boot-keycloak/.gitignore b/spring-boot-modules/spring-boot-keycloak/.gitignore deleted file mode 100644 index 2af7cefb0a..0000000000 --- a/spring-boot-modules/spring-boot-keycloak/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar b/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 9cc84ea9b4d95453115d0c26488d6a78694e0bc6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 47610 zcmbTd1CXW7vMxN+wr$(CZCk5to71*!+jjS~ZJX1!ds=tCefGhB{(HVS`>u$J^~PFn zW>r>YRc2N`sUQsug7OUl0^-}ZZ-jr^e|{kUJj#ly2+~T*iO~apQ;-J#>z!{v|9nH? zexD9D~4A70;F%I|$?{aX9)~)7!NMGs_XtoO(D2z3Q#5Lmj zOYWk1b{iMmsdX30UFmYyZk1gWICVeOtk^$+{3U2(8gx?WA2F!EfBPf&|1?AJ|5Z>M zfUAk^zcf#n|9^4|J34286~NKrUt&c5cZ~iqE?PH7fW5tm3-qG$) z56%`QPSn!0RMV3)jjXfG^UQ}*^yBojH!}58lPlDclX5iUhf*|DV=~e*bl;(l$Wn@r zPE*iH(NK!e9KQcU$rRM}aJc?-&H1PO&vOs*=U+QVvwuk-=zr1x>;XpRCjSyC;{TWQ z|824V8t*^*{x=5yn^pP#-?k<5|7|4y&Pd44&e_TN&sxg@ENqpX0glclj&w%W04Jwp zwJ}#@ag^@h5VV4H5U@i7V#A*a;4bzM-y_rd{0WG#jRFPJU}(#&o8vo@uM+B+$>Tiq zei^5$wg8CVf{+_#Vh`yPx-6TmB~zT_nocS_Rb6&EYp*KjbN#-aP<~3j=NVuR)S1wm zdy3AWx2r9uww3eNJxT>{tdmY4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J}QQuPE z-u#DdD6hH6`;nVJ>O}8iuWxH>Z2vc>a;iFbm)nrbj$ps$6aa4TjfVZVZr7dK+E_E# z+S`ErJDM9i{HX815lax33Wl(;H~m|sF28cs+hB$%2pjyXgubo5p_%ay3!*?212bxX z@1{$rzY6~DK*{`5@oRm0>(9INQX61!{Ip#NymIM*g~u=D)UFH!NcfQ(AsZXVOPv5) zX?=4bI9>9;>HvTACiBNDt)x;_}tsJousTuWrG- zDUSM9|4|IRSy@PhdB$sAk4b;vRr>Nt@t3OB<#_*dl_7P>FGcFF3-DA?KBW00A<;2=*&`^P8}cEZW!GSO9(+{;-V@ zd%%C8KEDYD$pC#x%zb4bfVJ|kgWcG0-UNZT9@2=R|Wz+H2iJ2A29LV z#Dye7Qn~^KUqOIS)8EGZC9w+k*Sq|}?ze$| zKpJrq7cvL=dV^7%ejE4Cn@aE>Q}b^ELnd#EUUf703IedX{*S;n6P|BELgooxW`$lE z2;lhae}w#VCPR>N+{A=T+qyn;-Jk!Dn2`C1H{l?&Wv&mW{)_(?+|T+JGMPf)s$;=d z5J27Mw}F4!tB`@`mkAnI1_G4%{WjW<(=~4PFy#B)>ubz@;O|2J^F9yq(EB<9e9})4 z{&vv)&j^s`f|tKquM7lG$@pD_AFY;q=hx31Z;lY;$;aa>NbnT| kh{^d0>dn0}#6IV5TMroUdkH8gdhnkj_&0LYo6ArC2O!h?t^fc4 diff --git a/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties b/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 9dda3b659b..0000000000 --- a/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip diff --git a/spring-boot-modules/spring-boot-keycloak/mvnw b/spring-boot-modules/spring-boot-keycloak/mvnw deleted file mode 100755 index 5bf251c077..0000000000 --- a/spring-boot-modules/spring-boot-keycloak/mvnw +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -echo $MAVEN_PROJECTBASEDIR -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/spring-boot-modules/spring-boot-keycloak/mvnw.cmd b/spring-boot-modules/spring-boot-keycloak/mvnw.cmd deleted file mode 100644 index 019bd74d76..0000000000 --- a/spring-boot-modules/spring-boot-keycloak/mvnw.cmd +++ /dev/null @@ -1,143 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/spring-boot-modules/spring-boot-keycloak/pom.xml b/spring-boot-modules/spring-boot-keycloak/pom.xml index b80dbfa191..c1bff066e3 100644 --- a/spring-boot-modules/spring-boot-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-keycloak/pom.xml @@ -64,6 +64,28 @@ org.springframework.boot spring-boot-starter-thymeleaf + + wsdl4j + wsdl4j + 1.6.3 + + + org.springframework.boot + spring-boot-starter-web-services + + + + org.springframework.security + spring-security-test + test + + + org.assertj + assertj-core + 3.21.0 + test + + @@ -72,11 +94,31 @@ org.springframework.boot spring-boot-maven-plugin + + org.codehaus.mojo + jaxb2-maven-plugin + 2.5.0 + + + xjc + + xjc + + + + + com.baeldung + + ${project.basedir}/src/main/resources/products.xsd + + + + - 13.0.1 + 15.0.2 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSecurityConfig.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSecurityConfig.java new file mode 100644 index 0000000000..66a17f4967 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSecurityConfig.java @@ -0,0 +1,54 @@ +package com.baeldung.keycloaksoap; + +import org.keycloak.adapters.KeycloakConfigResolver; +import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; +import org.keycloak.adapters.springsecurity.KeycloakConfiguration; +import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; +import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; +import org.springframework.security.core.session.SessionRegistryImpl; +import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy; +import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; + +@KeycloakConfiguration +@ConditionalOnProperty(name = "keycloak.enabled", havingValue = "true") +@EnableGlobalMethodSecurity(jsr250Enabled = true) +public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter { + @Override + protected void configure(HttpSecurity http) throws Exception { + super.configure(http); + //@formatter:off + http + .csrf() + .disable() + .authorizeRequests() + .anyRequest() + .permitAll(); + //@formatter:on + } + + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) { + KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider(); + keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper()); + auth.authenticationProvider(keycloakAuthenticationProvider); + } + + @Bean + @Override + protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { + return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl()); + } + + @Bean + public KeycloakConfigResolver keycloakSpringBootConfigResolver() { + return new KeycloakSpringBootConfigResolver(); + } + +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSoapServicesApplication.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSoapServicesApplication.java new file mode 100644 index 0000000000..4cf60a804a --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/KeycloakSoapServicesApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.keycloaksoap; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class KeycloakSoapServicesApplication { + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(KeycloakSoapServicesApplication.class); + application.setAdditionalProfiles("keycloak"); + application.run(args); + } + +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/ProductsEndpoint.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/ProductsEndpoint.java new file mode 100644 index 0000000000..58f7739af0 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/ProductsEndpoint.java @@ -0,0 +1,42 @@ +package com.baeldung.keycloaksoap; + +import com.baeldung.DeleteProductRequest; +import com.baeldung.DeleteProductResponse; +import com.baeldung.GetProductDetailsRequest; +import com.baeldung.GetProductDetailsResponse; +import com.baeldung.Product; +import org.springframework.ws.server.endpoint.annotation.Endpoint; +import org.springframework.ws.server.endpoint.annotation.PayloadRoot; +import org.springframework.ws.server.endpoint.annotation.RequestPayload; +import org.springframework.ws.server.endpoint.annotation.ResponsePayload; + +import javax.annotation.security.RolesAllowed; +import java.util.Map; + +@Endpoint +public class ProductsEndpoint { + + private final Map productMap; + + public ProductsEndpoint(Map productMap) { + this.productMap = productMap; + } + + @RolesAllowed("user") + @PayloadRoot(namespace = "http://www.baeldung.com/springbootsoap/keycloak", localPart = "getProductDetailsRequest") + @ResponsePayload + public GetProductDetailsResponse getProductDetails(@RequestPayload GetProductDetailsRequest request) { + GetProductDetailsResponse response = new GetProductDetailsResponse(); + response.setProduct(productMap.get(request.getId())); + return response; + } + + @RolesAllowed("admin") + @PayloadRoot(namespace = "http://www.baeldung.com/springbootsoap/keycloak", localPart = "deleteProductRequest") + @ResponsePayload + public DeleteProductResponse deleteProduct(@RequestPayload DeleteProductRequest request) { + DeleteProductResponse response = new DeleteProductResponse(); + response.setMessage("Success! Deleted the product with the id - "+request.getId()); + return response; + } +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/WebServiceConfig.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/WebServiceConfig.java new file mode 100644 index 0000000000..00d128fa12 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloaksoap/WebServiceConfig.java @@ -0,0 +1,75 @@ +package com.baeldung.keycloaksoap; + +import com.baeldung.Product; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.ws.config.annotation.EnableWs; +import org.springframework.ws.config.annotation.WsConfigurerAdapter; +import org.springframework.ws.transport.http.MessageDispatcherServlet; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.xml.xsd.SimpleXsdSchema; +import org.springframework.xml.xsd.XsdSchema; + +import java.util.HashMap; +import java.util.Map; + +@EnableWs +@Configuration +public class WebServiceConfig extends WsConfigurerAdapter { + + @Value("${ws.api.path:/ws/api/v1/*}") + private String webserviceApiPath; + @Value("${ws.port.type.name:ProductsPort}") + private String webservicePortTypeName; + @Value("${ws.target.namespace:http://www.baeldung.com/springbootsoap/keycloak}") + private String webserviceTargetNamespace; + @Value("${ws.location.uri:http://localhost:18080/ws/api/v1/}") + private String locationUri; + + @Bean + public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { + MessageDispatcherServlet servlet = new MessageDispatcherServlet(); + servlet.setApplicationContext(applicationContext); + servlet.setTransformWsdlLocations(true); + return new ServletRegistrationBean<>(servlet, webserviceApiPath); + } + + @Bean(name = "products") + public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema productsSchema) { + DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); + wsdl11Definition.setPortTypeName(webservicePortTypeName); + wsdl11Definition.setTargetNamespace(webserviceTargetNamespace); + wsdl11Definition.setLocationUri(locationUri); + wsdl11Definition.setSchema(productsSchema); + return wsdl11Definition; + } + + @Bean + public XsdSchema productsSchema() { + return new SimpleXsdSchema(new ClassPathResource("products.xsd")); + } + + @Bean + public Map getProducts() + { + Map map = new HashMap<>(); + Product foldsack= new Product(); + foldsack.setId("1"); + foldsack.setName("Fjallraven - Foldsack No. 1 Backpack, Fits 15 Laptops"); + foldsack.setDescription("Your perfect pack for everyday use and walks in the forest. "); + + Product shirt= new Product(); + shirt.setId("2"); + shirt.setName("Mens Casual Premium Slim Fit T-Shirts"); + shirt.setDescription("Slim-fitting style, contrast raglan long sleeve, three-button henley placket."); + + map.put("1", foldsack); + map.put("2", shirt); + return map; + } + +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/resources/application-keycloak.properties b/spring-boot-modules/spring-boot-keycloak/src/main/resources/application-keycloak.properties new file mode 100644 index 0000000000..0a28b7ac48 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/resources/application-keycloak.properties @@ -0,0 +1,17 @@ +server.port=18080 + +keycloak.enabled=true +keycloak.realm=baeldung-soap-services +keycloak.auth-server-url=http://localhost:8080/auth +keycloak.bearer-only=true +keycloak.credentials.secret=14da6f9e-261f-489a-9bf0-1441e4a9ddc4 +keycloak.ssl-required=external +keycloak.resource=baeldung-soap-services +keycloak.use-resource-role-mappings=true + + +# Custom properties begin here +ws.api.path=/ws/api/v1/* +ws.port.type.name=ProductsPort +ws.target.namespace=http://www.baeldung.com/springbootsoap/keycloak +ws.location.uri=http://localhost:18080/ws/api/v1/ \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/resources/products.xsd b/spring-boot-modules/spring-boot-keycloak/src/main/resources/products.xsd new file mode 100644 index 0000000000..b147118e96 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/resources/products.xsd @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java new file mode 100644 index 0000000000..3207e4cc56 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java @@ -0,0 +1,156 @@ +package com.baeldung.keycloaksoap; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The class contains Live/Integration tests. + * These tests expect that the Keycloak server is up and running on port 8080. + * The tests may fail without a Keycloak server. + */ +@DisplayName("Keycloak SOAP Webservice Unit Tests") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@AutoConfigureMockMvc +class KeycloakSoapIntegrationTest { + + private static final Logger logger = LoggerFactory.getLogger(KeycloakSoapIntegrationTest.class); + @LocalServerPort + private int port; + @Autowired + private TestRestTemplate restTemplate; + @Autowired + private ObjectMapper objectMapper; + @Value("${grant.type}") + private String grantType; + @Value("${client.id}") + private String clientId; + @Value("${client.secret}") + private String clientSecret; + @Value("${url}") + private String keycloakUrl; + + /** + * Test a happy flow. Test the janedoe user. + * This user should be configured in Keycloak server with a role user + */ + @Test + @DisplayName("Get Products With Access Token") + void givenAccessToken_whenGetProducts_thenReturnProduct() { + + HttpHeaders headers = new HttpHeaders(); + headers.set("content-type", "text/xml"); + headers.set("Authorization", "Bearer " + generateToken("janedoe", "password")); + HttpEntity request = new HttpEntity<>(Utility.getGetProductDetailsRequest(), headers); + ResponseEntity responseEntity = restTemplate.postForEntity("http://localhost:" + port + "/ws/api/v1/", request, String.class); + + assertThat(responseEntity).isNotNull(); + assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getBody()).isNotBlank(); + assertThat(responseEntity.getBody()).containsIgnoringCase(":id>1janeadoe user. + * Keycloak returns Unauthorized. Assert 401 status and empty body. + */ + @Test + @DisplayName("Get Products With Wrong Access Token") + void givenWrongAccessToken_whenGetProducts_thenReturnError() { + + HttpHeaders headers = new HttpHeaders(); + headers.set("content-type", "text/xml"); + headers.set("Authorization", "Bearer " + generateToken("janeadoe", "password")); + HttpEntity request = new HttpEntity<>(Utility.getGetProductDetailsRequest(), headers); + ResponseEntity responseEntity = restTemplate.postForEntity("http://localhost:" + port + "/ws/api/v1/", request, String.class); + System.out.println("This is the URL --> " + "http://localhost:" + port + "/ws/api/v1/"); + System.out.println("Body --> " + responseEntity.getBody()); + System.out.println("Location Header --> " + responseEntity.getHeaders().get("Location")); + assertThat(responseEntity).isNotNull(); + assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.UNAUTHORIZED.value()); + assertThat(responseEntity.getBody()).isBlank(); + } + + /** + * Happy flow to test deleteProduct operation. Test the jhondoe user. + * This user should be configured in Keycloak server with a role user + */ + @Test + @DisplayName("Delete Product With Access Token") + void givenAccessToken_whenDeleteProduct_thenReturnSuccess() { + HttpHeaders headers = new HttpHeaders(); + headers.set("content-type", "text/xml"); + headers.set("Authorization", "Bearer " + generateToken("jhondoe", "password")); + HttpEntity request = new HttpEntity<>(Utility.getDeleteProductsRequest(), headers); + ResponseEntity responseEntity = restTemplate.postForEntity("http://localhost:" + port + "/ws/api/v1/", request, String.class); + + assertThat(responseEntity).isNotNull(); + assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getBody()).isNotBlank(); + assertThat(responseEntity.getBody()).containsIgnoringCase("Deleted the product with the id"); + } + + /** + * Negative flow to test . Test the janedoe user. + * Obtain the access token of janedoe and access the admin operation deleteProduct + * Assume janedoe has restricted access to deleteProduct operation + */ + @Test + @DisplayName("Delete Products With Unauthorized Access Token") + void givenUnauthorizedAccessToken_whenDeleteProduct_thenReturnUnauthorized() { + HttpHeaders headers = new HttpHeaders(); + headers.set("content-type", "text/xml"); + headers.set("Authorization", "Bearer " + generateToken("janedoe", "password")); + HttpEntity request = new HttpEntity<>(Utility.getDeleteProductsRequest(), headers); + ResponseEntity responseEntity = restTemplate.postForEntity("http://localhost:" + port + "/ws/api/v1/", request, String.class); + + assertThat(responseEntity).isNotNull(); + assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); + assertThat(responseEntity.getBody()).isNotBlank(); + assertThat(responseEntity.getBody()).containsIgnoringCase("Access is denied"); + } + + private String generateToken(String username, String password) { + + try { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + MultiValueMap map = new LinkedMultiValueMap<>(); + map.add("grant_type", grantType); + map.add("client_id", clientId); + map.add("client_secret", clientSecret); + map.add("username", username); + map.add("password", password); + HttpEntity> entity = new HttpEntity<>(map, headers); + ResponseEntity response = restTemplate.exchange(keycloakUrl, HttpMethod.POST, entity, String.class); + return Objects.requireNonNull(response.getBody()).contains("access_token") ? objectMapper.readTree(response.getBody()).get("access_token").asText() : ""; + } catch (Exception ex) { + logger.error("There is an internal server error. Returning an empty access token", ex); + return ""; + } + + } + +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/Utility.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/Utility.java new file mode 100644 index 0000000000..1535d9f171 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/Utility.java @@ -0,0 +1,12 @@ +package com.baeldung.keycloaksoap; + +public class Utility { + public static String getGetProductDetailsRequest() { + return "\n" + " \n" + " \n" + " \n" + + " 1\n" + " \n" + " \n" + ""; + } + public static String getDeleteProductsRequest() { + return "\n" + " \n" + " \n" + " \n" + + " 1\n" + " \n" + " \n" + ""; + } +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/test/resources/application-test.properties b/spring-boot-modules/spring-boot-keycloak/src/test/resources/application-test.properties new file mode 100644 index 0000000000..a818b5be7a --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/test/resources/application-test.properties @@ -0,0 +1,4 @@ +grant.type=password +client.id=baeldung-soap-services +client.secret=d2ba7af8-f7d2-4c97-b4a5-3c88b59920ae +url=http://localhost:8080/auth/realms/baeldung-soap-services/protocol/openid-connect/token From f9feb0aad7c694f365b1fbd196219499c6afcb82 Mon Sep 17 00:00:00 2001 From: Bhaskara Navuluri Date: Mon, 25 Oct 2021 15:26:06 +0530 Subject: [PATCH 070/551] removed debug info --- .../com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java index 3207e4cc56..e0de897044 100644 --- a/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java +++ b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloaksoap/KeycloakSoapIntegrationTest.java @@ -85,9 +85,6 @@ class KeycloakSoapIntegrationTest { headers.set("Authorization", "Bearer " + generateToken("janeadoe", "password")); HttpEntity request = new HttpEntity<>(Utility.getGetProductDetailsRequest(), headers); ResponseEntity responseEntity = restTemplate.postForEntity("http://localhost:" + port + "/ws/api/v1/", request, String.class); - System.out.println("This is the URL --> " + "http://localhost:" + port + "/ws/api/v1/"); - System.out.println("Body --> " + responseEntity.getBody()); - System.out.println("Location Header --> " + responseEntity.getHeaders().get("Location")); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.UNAUTHORIZED.value()); assertThat(responseEntity.getBody()).isBlank(); From d548f8cd85eb1662f0155001d1ac3105ea8d0d39 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Mon, 25 Oct 2021 16:35:06 +0530 Subject: [PATCH 071/551] Fixing HttpClientLiveTest --- libraries-http/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index 8eb6142c38..a00bb4bd39 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -94,6 +94,11 @@ jackson-databind ${jackson.version} + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + org.apache.httpcomponents httpclient From 6835bf200d786096e1d361850dfcb56e43544ae4 Mon Sep 17 00:00:00 2001 From: Yashasvii Date: Mon, 25 Oct 2021 18:15:25 +0545 Subject: [PATCH 072/551] BAEL-5163: HashMap - keySet vs entrySet vs values methods (#11301) * Hexagonal Architecture in Java * Refactor Hexagonal Architecture in Java * Refactor Hexagonal Architecture in Java * BAEL-5163: HashMap - keySet vs entrySet vs values methods * BAEL-5163: HashMap - keySet vs entrySet vs values methods * Revert "Hexagonal Architecture in Java" This reverts commit 1add21c1 * BAEL-5163: HashMap - keySet vs entrySet vs values methods * BAEL-5163: HashMap - keySet vs entrySet vs values methods" --- .../EntrySetExampleUnitTest.java | 30 +++++++++++++++++++ .../KeySetExampleUnitTest.java | 27 +++++++++++++++++ .../ValuesExampleUnitTest.java | 27 +++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/EntrySetExampleUnitTest.java create mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/KeySetExampleUnitTest.java create mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/ValuesExampleUnitTest.java diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/EntrySetExampleUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/EntrySetExampleUnitTest.java new file mode 100644 index 0000000000..fea88f729b --- /dev/null +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/EntrySetExampleUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.map.keysetValuesEntrySet; + +import org.junit.Test; + +import java.util.AbstractMap.SimpleEntry; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class EntrySetExampleUnitTest { + + @Test + public void givenHashMap_whenEntrySetApplied_thenShouldReturnSetOfEntries() { + + Map map = new HashMap<>(); + map.put("one", 1); + map.put("two", 2); + + Set> actualValues = map.entrySet(); + + assertEquals(2, actualValues.size()); + assertTrue(actualValues.contains(new SimpleEntry<>("one", 1))); + assertTrue(actualValues.contains(new SimpleEntry<>("two", 2))); + + } + +} diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/KeySetExampleUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/KeySetExampleUnitTest.java new file mode 100644 index 0000000000..6cb0620e35 --- /dev/null +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/KeySetExampleUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.map.keysetValuesEntrySet; + +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class KeySetExampleUnitTest { + + @Test + public void givenHashMap_whenKeySetApplied_thenShouldReturnSetOfKeys() { + Map map = new HashMap<>(); + map.put("one", 1); + map.put("two", 2); + + Set actualValues = map.keySet(); + + assertEquals(2, actualValues.size()); + assertTrue(actualValues.contains("one")); + assertTrue(actualValues.contains("two")); + } + +} diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/ValuesExampleUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/ValuesExampleUnitTest.java new file mode 100644 index 0000000000..ba9369a122 --- /dev/null +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/keysetValuesEntrySet/ValuesExampleUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.map.keysetValuesEntrySet; + +import org.junit.Test; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class ValuesExampleUnitTest { + + @Test + public void givenHashMap_whenValuesApplied_thenShouldReturnCollectionOfValues() { + Map map = new HashMap<>(); + map.put("one", 1); + map.put("two", 2); + + Collection actualValues = map.values(); + + assertEquals(2, actualValues.size()); + assertTrue(actualValues.contains(1)); + assertTrue(actualValues.contains(2)); + } + +} From 258778b6fcb66d2798bdcd9628572c03cf5e934e Mon Sep 17 00:00:00 2001 From: HarisHashim Date: Wed, 27 Oct 2021 00:06:06 +0800 Subject: [PATCH 073/551] BAEL-5202: Add excel multiline text (#11366) * BAEL-5202: Add excel multiline text * BAEL-5202: Reformat code and rename ExcelMultilineText for consistency with unit test * Cleanup and formatting --- .../excel/multilinetext/MultilineText.java | 18 +++++ .../multilinetext/MultilineTextTest.xlsx | Bin 0 -> 8556 bytes .../multilinetext/MultilineTextUnitTest.java | 69 ++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 apache-poi/src/main/java/com/baeldung/poi/excel/multilinetext/MultilineText.java create mode 100644 apache-poi/src/main/resources/com/baeldung/poi/excel/multilinetext/MultilineTextTest.xlsx create mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/multilinetext/MultilineTextUnitTest.java diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/multilinetext/MultilineText.java b/apache-poi/src/main/java/com/baeldung/poi/excel/multilinetext/MultilineText.java new file mode 100644 index 0000000000..2e0cc5770e --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/multilinetext/MultilineText.java @@ -0,0 +1,18 @@ +package com.baeldung.poi.excel.multilinetext; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Row; + +public class MultilineText { + public void formatMultilineText(Cell cell, int cellNumber) { + cell.getRow() + .setHeightInPoints(cell.getSheet() + .getDefaultRowHeightInPoints() * 2); + CellStyle cellStyle = cell.getSheet() + .getWorkbook() + .createCellStyle(); + cellStyle.setWrapText(true); + cell.setCellStyle(cellStyle); + } +} diff --git a/apache-poi/src/main/resources/com/baeldung/poi/excel/multilinetext/MultilineTextTest.xlsx b/apache-poi/src/main/resources/com/baeldung/poi/excel/multilinetext/MultilineTextTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..c6b963d5a54cad7e77610d3da850013063c1b646 GIT binary patch literal 8556 zcmeHMg5l}!0K^lhcP*Ortx^qB6Is^sjR2l~uLW!Y41QEXR zzW2WOUa#L@@ZLSYv-g}iXRSH=?6vl@*0XdqP|-*L7yv8)0Kf>a+RwGOKmh=f&;S5p z0M@O03a&1mwl1EQhJJ3g5OW@1XD5atv|DTifLqA>|84)nZ=gDLM7tMEsC2G+rLe)R z{;@$8OK2~AfQUm+x~DItzsmYv-s8tNc`@Gz`7+Fw@@V*;BfV#;klReB#4+==AW%(#AE#n_$175hd^y&*L!sXPfsq9I~q(j$p z7YB@iEB$S_Rb~}pgG+B#wT+j7qQjLR2-l~GryU-%2Uwh}bE~1nF$H`i^R_6}Wi&Bh zx6*I(xXjRa4Pk2)n0a7*YZ)Aw)P)ZlU%}{jEkdUyNYzjods=1IpXA8d9e6*`znd)~ z?o{`(U6|C~lKWnsY#3ws`+0z_V_YLy4Zq7oP@fEGvF6C(TL#!S5S*B%Z-v^XJ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r5^XQ;NPnfe--RRKI{Kqqxf0R&s6oFnhubq`=5yGpM`%W=>8NI z#{Ca?{+F)%S@dU)<4;i@Bx8>J-=7(epB4NZVE(D#nDoC7{*Q3;XDvSi{-0VZkWuTe z;Qwb0e+Sk-{liWAcOMf~@DQC9;Uxw-(rZRF=ibUjP= Date: Wed, 27 Oct 2021 12:25:33 +0530 Subject: [PATCH 074/551] JAVA-7660 : Upgrade slf4j dependency in the main pom.xml (#11372) * JAVA-7660 : Upgrade slf4j dependency in the main pom.xml * Upgrading logback version also to resolve compilation issues * Revering the logback updated version and using slf4j stable newest version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de3f2583d6..7a415ad976 100644 --- a/pom.xml +++ b/pom.xml @@ -1392,7 +1392,7 @@ 1.11.20 - 1.7.30 + 1.7.32 1.2.6 From 7c8bb5206eccdaf112cecb88281b46a6ff400d7a Mon Sep 17 00:00:00 2001 From: Ramazan Sakin Date: Wed, 27 Oct 2021 10:50:01 +0300 Subject: [PATCH 075/551] Update README.md typo fix --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 88750cf654..8fb884e3c8 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,16 @@ Java and Spring Tutorials This project is **a collection of small and focused tutorials** - each covering a single and well defined area of development in the Java ecosystem. A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Security. -In additional to Spring, the modules here are covering a number of aspects in Java. +In addition to Spring, the modules here cover a number of aspects of Java. Profile based segregation ==================== We are using maven build profiles to segregate the huge list of individual projects we have in our repository. -The projects are broadly divided into 3 list: first, second and heavy. +The projects are broadly divided into 3 lists: first, second and heavy. -Next, they are segregated further on the basis of tests that we want to execute. +Next, they are segregated further on the basis of the tests that we want to execute. Therefore, we have a total of 6 profiles: @@ -56,12 +56,12 @@ or if we want to build the entire repository with Integration Tests enabled, we Building a single module ==================== -To build a specific module run the command: `mvn clean install` in the module directory +To build a specific module, run the command: `mvn clean install` in the module directory. Running a Spring Boot module ==================== -To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory +To run a Spring Boot module, run the command: `mvn spring-boot:run` in the module directory. Working with the IDE From 4a306f7171866d1c245e4e438196a95524b8b1e8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Oct 2021 01:48:10 +0800 Subject: [PATCH 076/551] Update README.md --- docker/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/README.md b/docker/README.md index ab3ddd35b7..8aca8e4293 100644 --- a/docker/README.md +++ b/docker/README.md @@ -4,3 +4,4 @@ - [Reusing Docker Layers with Spring Boot](https://www.baeldung.com/docker-layers-spring-boot) - [Running Spring Boot with PostgreSQL in Docker Compose](https://www.baeldung.com/spring-boot-postgresql-docker) - [How To Configure Java Heap Size Inside a Docker Container](https://www.baeldung.com/ops/docker-jvm-heap-size) +- [Dockerfile Strategies for Git](https://www.baeldung.com/ops/dockerfile-git-strategies) From d014cb699083ad6fb2ca7b68ea3fd8bf947a2811 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Oct 2021 01:50:12 +0800 Subject: [PATCH 077/551] Update README.md --- core-java-modules/core-java-string-apis/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-apis/README.md b/core-java-modules/core-java-string-apis/README.md index c9aa40de7a..0dd24d7e9a 100644 --- a/core-java-modules/core-java-string-apis/README.md +++ b/core-java-modules/core-java-string-apis/README.md @@ -10,3 +10,4 @@ This module contains articles about string APIs. - [CharSequence vs. String in Java](https://www.baeldung.com/java-char-sequence-string) - [StringBuilder vs StringBuffer in Java](https://www.baeldung.com/java-string-builder-string-buffer) - [Generate a Secure Random Password in Java](https://www.baeldung.com/java-generate-secure-password) +- [Getting a Character by Index From a String in Java](https://www.baeldung.com/java-character-at-position) From 6d2a137636deb3f07c7882c3d56409d7eb23d618 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Oct 2021 01:52:51 +0800 Subject: [PATCH 078/551] Create README.md --- persistence-modules/spring-data-cassandra-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 persistence-modules/spring-data-cassandra-2/README.md diff --git a/persistence-modules/spring-data-cassandra-2/README.md b/persistence-modules/spring-data-cassandra-2/README.md new file mode 100644 index 0000000000..f5cf20b8a9 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Using Test Containers With Spring Data Cassandra](https://www.baeldung.com/spring-data-cassandra-test-containers) From 1d5ab855f9491904ebafdaf8c10e04b7a8961601 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Oct 2021 01:54:57 +0800 Subject: [PATCH 079/551] Update README.md --- java-collections-maps-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index 831f987523..87817331b5 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -5,3 +5,4 @@ - [Using the Map.Entry Java Class](https://www.baeldung.com/java-map-entry) - [Optimizing HashMap’s Performance](https://www.baeldung.com/java-hashmap-optimize-performance) - [Update the Value Associated With a Key in a HashMap](https://www.baeldung.com/java-hashmap-update-value-by-key) +- [Java Map – keySet() vs. entrySet() vs. values() Methods](https://www.baeldung.com/java-map-entries-methods) From 301961ade14eb71f35862e493632fbf08aa18968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Tarj=C3=A1nyi?= Date: Wed, 27 Oct 2021 20:33:40 +0200 Subject: [PATCH 080/551] Improve Spring WebClient tutorial (#10993) --- .../webclient/simultaneous/Client.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java index bbfc88322b..a72957d079 100644 --- a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java +++ b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java @@ -1,9 +1,8 @@ package com.baeldung.reactive.webclient.simultaneous; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; import reactor.core.publisher.Flux; -import reactor.core.scheduler.Schedulers; +import reactor.core.publisher.Mono; import java.util.List; import java.util.logging.Logger; @@ -19,8 +18,6 @@ public class Client { } public Mono getUser(int id) { - LOG.info(String.format("Calling getUser(%d)", id)); - return webClient.get() .uri("/user/{id}", id) .retrieve() @@ -43,22 +40,16 @@ public class Client { public Flux fetchUsers(List userIds) { return Flux.fromIterable(userIds) - .parallel() - .runOn(Schedulers.elastic()) - .flatMap(this::getUser) - .ordered((u1, u2) -> u2.id() - u1.id()); + .flatMap(this::getUser); } public Flux fetchUserAndOtherUser(int id) { - return Flux.merge(getUser(id), getOtherUser(id)) - .parallel() - .runOn(Schedulers.elastic()) - .ordered((u1, u2) -> u2.id() - u1.id()); + return Flux.merge(getUser(id), getOtherUser(id)); } public Mono fetchUserAndItem(int userId, int itemId) { - Mono user = getUser(userId).subscribeOn(Schedulers.elastic()); - Mono item = getItem(itemId).subscribeOn(Schedulers.elastic()); + Mono user = getUser(userId); + Mono item = getItem(itemId); return Mono.zip(user, item, UserWithItem::new); } From a41f46c5941d1bf26ef34370ccfb6921b4693a34 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 27 Oct 2021 20:56:46 +0200 Subject: [PATCH 081/551] BAEL-5114: Do not use deprecated PropertyNamingStrategy class (#11371) --- .../com/baeldung/jackson/advancedannotations/NamingBean.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java index 323df49c14..c1b8da4c1c 100644 --- a/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java +++ b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java @@ -1,9 +1,9 @@ package com.baeldung.jackson.advancedannotations; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class NamingBean { private int id; private String beanName; From b9fadd8f3d8ee6b3705dafd2b5f3344d703757fe Mon Sep 17 00:00:00 2001 From: Rafael Lopez Date: Wed, 27 Oct 2021 14:58:57 -0400 Subject: [PATCH 082/551] JAVA-2592: Update article on AbstractRoutingDatasource (#11320) Co-authored-by: Dhawal Kapil --- .../spring-boot-persistence/README.md | 1 + .../com/baeldung/dsrouting/ClientDao.java | 0 .../dsrouting/ClientDataSourceRouter.java | 27 ++++++++ .../baeldung/dsrouting/ClientDatabase.java | 0 .../ClientDatabaseContextHolder.java | 0 .../com/baeldung/dsrouting/ClientService.java | 0 .../dsrouting/model/ClientADetails.java | 28 +++++++++ .../dsrouting/model/ClientBDetails.java | 28 +++++++++ .../DataSourceRoutingIntegrationTest.java | 0 .../DataSourceRoutingTestConfiguration.java | 4 +- ...gBootDataSourceRoutingIntegrationTest.java | 62 +++++++++++++++++++ ...ootDataSourceRoutingTestConfiguration.java | 55 ++++++++++++++++ .../src/test/resources/application.properties | 8 +++ .../src/test/resources/dsrouting-db.sql | 5 ++ persistence-modules/spring-jpa/README.md | 2 +- .../dsrouting/ClientDataSourceRouter.java | 14 ----- 16 files changed, 217 insertions(+), 17 deletions(-) rename persistence-modules/{spring-jpa => spring-boot-persistence}/src/main/java/com/baeldung/dsrouting/ClientDao.java (100%) create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java rename persistence-modules/{spring-jpa => spring-boot-persistence}/src/main/java/com/baeldung/dsrouting/ClientDatabase.java (100%) rename persistence-modules/{spring-jpa => spring-boot-persistence}/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java (100%) rename persistence-modules/{spring-jpa => spring-boot-persistence}/src/main/java/com/baeldung/dsrouting/ClientService.java (100%) create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientADetails.java create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientBDetails.java rename persistence-modules/{spring-jpa => spring-boot-persistence}/src/test/java/com/baeldung/dsrouting/DataSourceRoutingIntegrationTest.java (100%) rename persistence-modules/{spring-jpa => spring-boot-persistence}/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java (92%) create mode 100644 persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingIntegrationTest.java create mode 100644 persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingTestConfiguration.java create mode 100644 persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql delete mode 100644 persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java diff --git a/persistence-modules/spring-boot-persistence/README.md b/persistence-modules/spring-boot-persistence/README.md index 5b9fbf7b79..a9fe3905c2 100644 --- a/persistence-modules/spring-boot-persistence/README.md +++ b/persistence-modules/spring-boot-persistence/README.md @@ -7,4 +7,5 @@ - [Resolving “Failed to Configure a DataSource” Error](https://www.baeldung.com/spring-boot-failed-to-configure-data-source) - [Hibernate Field Naming with Spring Boot](https://www.baeldung.com/hibernate-field-naming-spring-boot) - [Spring Boot with Hibernate](https://www.baeldung.com/spring-boot-hibernate) +- [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) - More articles: [[more -->]](../spring-boot-persistence-2) \ No newline at end of file diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDao.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDao.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDao.java rename to persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDao.java diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java new file mode 100644 index 0000000000..ebedaf1045 --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java @@ -0,0 +1,27 @@ +package com.baeldung.dsrouting; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +/** + * Returns thread bound client lookup key for current context. + */ +public class ClientDataSourceRouter extends AbstractRoutingDataSource { + + @Override + protected Object determineCurrentLookupKey() { + return ClientDatabaseContextHolder.getClientDatabase(); + } + + public void initDatasource(DataSource clientADataSource, + DataSource clientBDataSource) { + Map dataSourceMap = new HashMap<>(); + dataSourceMap.put(ClientDatabase.CLIENT_A, clientADataSource); + dataSourceMap.put(ClientDatabase.CLIENT_A, clientBDataSource); + this.setTargetDataSources(dataSourceMap); + this.setDefaultTargetDataSource(clientADataSource); + } +} diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabase.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDatabase.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabase.java rename to persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDatabase.java diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java rename to persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientService.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientService.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientService.java rename to persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/ClientService.java diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientADetails.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientADetails.java new file mode 100644 index 0000000000..c7236fed3c --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientADetails.java @@ -0,0 +1,28 @@ +package com.baeldung.dsrouting.model; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "client-a.datasource") +public class ClientADetails { + + private String name; + private String script; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } +} diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientBDetails.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientBDetails.java new file mode 100644 index 0000000000..5776c79855 --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dsrouting/model/ClientBDetails.java @@ -0,0 +1,28 @@ +package com.baeldung.dsrouting.model; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "client-b.datasource") +public class ClientBDetails { + + private String name; + private String script; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } +} diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/dsrouting/DataSourceRoutingIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/DataSourceRoutingIntegrationTest.java similarity index 100% rename from persistence-modules/spring-jpa/src/test/java/com/baeldung/dsrouting/DataSourceRoutingIntegrationTest.java rename to persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/DataSourceRoutingIntegrationTest.java diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java similarity index 92% rename from persistence-modules/spring-jpa/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java rename to persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java index cec9343892..957114eba5 100644 --- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/DataSourceRoutingTestConfiguration.java @@ -34,11 +34,11 @@ public class DataSourceRoutingTestConfiguration { private DataSource clientADatasource() { EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); - return dbBuilder.setType(EmbeddedDatabaseType.H2).setName("CLIENT_A").addScript("classpath:dsrouting-db.sql").build(); + return dbBuilder.setType(EmbeddedDatabaseType.H2).setName("CLIENT_A").addScript("dsrouting-db.sql").build(); } private DataSource clientBDatasource() { EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); - return dbBuilder.setType(EmbeddedDatabaseType.H2).setName("CLIENT_B").addScript("classpath:dsrouting-db.sql").build(); + return dbBuilder.setType(EmbeddedDatabaseType.H2).setName("CLIENT_B").addScript("dsrouting-db.sql").build(); } } diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingIntegrationTest.java new file mode 100644 index 0000000000..75829c2153 --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingIntegrationTest.java @@ -0,0 +1,62 @@ +package com.baeldung.dsrouting; + +import static org.junit.Assert.assertEquals; + +import javax.sql.DataSource; + +import com.baeldung.dsrouting.model.ClientADetails; +import com.baeldung.dsrouting.model.ClientBDetails; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest( + classes = {ClientADetails.class, ClientBDetails.class}) +@ContextConfiguration(classes = SpringBootDataSourceRoutingTestConfiguration.class) +@DirtiesContext +@EnableConfigurationProperties(ClientBDetails.class) +public class SpringBootDataSourceRoutingIntegrationTest { + + @Autowired + DataSource routingDatasource; + + @Autowired + ClientService clientService; + + @Before + public void setup() { + final String SQL_CLIENT_A = "insert into client (id, name) values (1, 'CLIENT A')"; + final String SQL_CLIENT_B = "insert into client (id, name) values (2, 'CLIENT B')"; + + JdbcTemplate jdbcTemplate = new JdbcTemplate(); + jdbcTemplate.setDataSource(routingDatasource); + + ClientDatabaseContextHolder.set(ClientDatabase.CLIENT_A); + jdbcTemplate.execute(SQL_CLIENT_A); + ClientDatabaseContextHolder.clear(); + + ClientDatabaseContextHolder.set(ClientDatabase.CLIENT_B); + jdbcTemplate.execute(SQL_CLIENT_B); + ClientDatabaseContextHolder.clear(); + } + + @Test + public void givenClientDbs_whenContextsSwitch_thenRouteToCorrectDatabase() throws Exception { + + // test ACME WIDGETS + String clientName = clientService.getClientName(ClientDatabase.CLIENT_A); + assertEquals(clientName, "CLIENT A"); + + // test WIDGETS_ARE_US + clientName = clientService.getClientName(ClientDatabase.CLIENT_B); + assertEquals(clientName, "CLIENT B"); + } +} diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingTestConfiguration.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingTestConfiguration.java new file mode 100644 index 0000000000..01f157998f --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/dsrouting/SpringBootDataSourceRoutingTestConfiguration.java @@ -0,0 +1,55 @@ +package com.baeldung.dsrouting; + +import com.baeldung.dsrouting.model.ClientADetails; +import com.baeldung.dsrouting.model.ClientBDetails; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.*; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +@Configuration +public class SpringBootDataSourceRoutingTestConfiguration { + @Autowired + private ClientADetails clientADetails; + @Autowired + private ClientBDetails clientBDetails; + + @Bean + public ClientService clientService() { + return new ClientService(new ClientDao(clientDatasource())); + } + + @Bean + public DataSource clientDatasource() { + Map targetDataSources = new HashMap<>(); + DataSource clientADatasource = clientADatasource(); + DataSource clientBDatasource = clientBDatasource(); + targetDataSources.put(ClientDatabase.CLIENT_A, clientADatasource); + targetDataSources.put(ClientDatabase.CLIENT_B, clientBDatasource); + + ClientDataSourceRouter clientRoutingDatasource = new ClientDataSourceRouter(); + clientRoutingDatasource.setTargetDataSources(targetDataSources); + clientRoutingDatasource.setDefaultTargetDataSource(clientADatasource); + return clientRoutingDatasource; + } + + private DataSource clientADatasource() { + EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); + return dbBuilder.setType(EmbeddedDatabaseType.H2) + .setName(clientADetails.getName()) + .addScript(clientADetails.getScript()) + .build(); + } + + private DataSource clientBDatasource() { + EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); + return dbBuilder.setType(EmbeddedDatabaseType.H2) + .setName(clientBDetails.getName()) + .addScript(clientBDetails.getScript()) + .build(); + } +} diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties index d22bd38426..b268f46094 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties @@ -4,6 +4,14 @@ spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 spring.datasource.username=sa spring.datasource.password=sa +#database details for CLIENT_A +client-a.datasource.name=CLIENT_A +client-a.datasource.script=dsrouting-db.sql + +#database details for CLIENT_B +client-b.datasource.name=CLIENT_B +client-b.datasource.script=dsrouting-db.sql + # hibernate.X hibernate.dialect=org.hibernate.dialect.H2Dialect hibernate.show_sql=true diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql b/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql new file mode 100644 index 0000000000..c9ca52907a --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql @@ -0,0 +1,5 @@ +create table client ( + id numeric, + name varchar(50), + constraint pk_client primary key (id) +); \ No newline at end of file diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index db70259005..e849ec4a83 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -5,7 +5,7 @@ - [JPA Pagination](https://www.baeldung.com/jpa-pagination) - [Sorting with JPA](https://www.baeldung.com/jpa-sort) - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database) -- [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) +- [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) - [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) - More articles: [[next -->]](/spring-jpa-2) diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java deleted file mode 100644 index a9f5d83b55..0000000000 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.dsrouting; - -import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; - -/** - * Returns thread bound client lookup key for current context. - */ -public class ClientDataSourceRouter extends AbstractRoutingDataSource { - - @Override - protected Object determineCurrentLookupKey() { - return ClientDatabaseContextHolder.getClientDatabase(); - } -} From 7ab19421e36a2340c60e51ba434da769f44abe43 Mon Sep 17 00:00:00 2001 From: Arash Ariani Date: Thu, 28 Oct 2021 07:55:34 +0330 Subject: [PATCH 083/551] BAEL-5058 : apache-derby added to dir (#11339) * BAEL-5058 : apache-derby added to dir * BAEL-5058 : apache-derby fixed changes * BAEL-5058 : apache-derby parent pom fixed --- persistence-modules/apache-derby/pom.xml | 32 +++++++++++++++ .../baeldung/derby/DerbyApplicationDemo.java | 39 +++++++++++++++++++ persistence-modules/pom.xml | 1 + 3 files changed, 72 insertions(+) create mode 100644 persistence-modules/apache-derby/pom.xml create mode 100644 persistence-modules/apache-derby/src/main/java/com/baeldung/derby/DerbyApplicationDemo.java diff --git a/persistence-modules/apache-derby/pom.xml b/persistence-modules/apache-derby/pom.xml new file mode 100644 index 0000000000..7728bd4d8f --- /dev/null +++ b/persistence-modules/apache-derby/pom.xml @@ -0,0 +1,32 @@ + + + + persistence-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + apache-derby + + + + + org.apache.derby + derby + 10.13.1.1 + + + + + org.apache.derby + derbyclient + 10.13.1.1 + + + + + + \ No newline at end of file diff --git a/persistence-modules/apache-derby/src/main/java/com/baeldung/derby/DerbyApplicationDemo.java b/persistence-modules/apache-derby/src/main/java/com/baeldung/derby/DerbyApplicationDemo.java new file mode 100644 index 0000000000..927293558f --- /dev/null +++ b/persistence-modules/apache-derby/src/main/java/com/baeldung/derby/DerbyApplicationDemo.java @@ -0,0 +1,39 @@ +package com.baeldung.derby; + +import java.sql.*; + +/** + * Created by arash on 14.10.21. + */ + +public class DerbyApplicationDemo { + public static void main(String[] args) { + runner("jdbc:derby:baeldung;create=true"); + } + + private static void runner(String urlConnection) { + try { + Connection con = DriverManager.getConnection(urlConnection); + Statement statement = con.createStatement(); + if (!isTableExists("authors", con)) { + String createSQL = "CREATE TABLE authors (id INT PRIMARY KEY,first_name VARCHAR(255),last_name VARCHAR(255))"; + statement.execute(createSQL); + String insertSQL = "INSERT INTO authors VALUES (1, 'arash','ariani')"; + statement.execute(insertSQL); + } + String selectSQL = "SELECT * FROM authors"; + ResultSet result = statement.executeQuery(selectSQL); + while (result.next()) { + // use result here + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private static boolean isTableExists(String tableName, Connection connection) throws SQLException { + DatabaseMetaData meta = connection.getMetaData(); + ResultSet result = meta.getTables(null, null, tableName.toUpperCase(), null); + return result.next(); + } +} diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index a8f1d5c103..0373cc78ec 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -17,6 +17,7 @@ activejdbc apache-bookkeeper apache-cayenne + apache-derby core-java-persistence core-java-persistence-2 deltaspike From 8401e09bd2006f2d525c1be2e3ca384de20706c2 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Thu, 28 Oct 2021 11:23:57 +0530 Subject: [PATCH 084/551] JAVA-8128 : Update How to Convert List to Map in Java article --- java-collections-conversions/pom.xml | 2 +- parent-java/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java-collections-conversions/pom.xml b/java-collections-conversions/pom.xml index e76181c9af..ae800b21c1 100644 --- a/java-collections-conversions/pom.xml +++ b/java-collections-conversions/pom.xml @@ -39,7 +39,7 @@ - 4.1 + 4.4 \ No newline at end of file diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 09d7f4c96d..103b5f179c 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -41,7 +41,7 @@ - 29.0-jre + 31.0.1-jre 2.3.7 2.2 From 48e194e9f725c64fb3d15e3774bd2cd263327960 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Thu, 28 Oct 2021 15:42:05 +0530 Subject: [PATCH 085/551] JAVA-8130 : Update Spring Boot in the spring-mvc-basics-2 --- spring-web-modules/spring-mvc-basics-2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web-modules/spring-mvc-basics-2/pom.xml b/spring-web-modules/spring-mvc-basics-2/pom.xml index 9136676d20..9748c5295a 100644 --- a/spring-web-modules/spring-mvc-basics-2/pom.xml +++ b/spring-web-modules/spring-mvc-basics-2/pom.xml @@ -164,7 +164,7 @@ 5.1.0 20180130 1.6.1 - 2.3.4.RELEASE + 2.5.6 \ No newline at end of file From 1ab0a19d254c115375f68f2b7043cff7979588a9 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Fri, 29 Oct 2021 09:37:04 +0530 Subject: [PATCH 086/551] Java 3590 (#11367) (#11380) * Java 3590 (#11367) * JAVA-3590: updating junit-jupiter dependency in the main pom.xml * resolving unnecessary mockito stubbings exception * adding junit-bom in dependency management * fixing tests which were not getting discovered * Revert "fixing tests which were not getting discovered" This reverts commit 2e9ed8df42eb96f7e0929167aabbc2ddd374a263. * fixing tests in ninja, open-liberty and spring-ejb * removing junit4 dependency and replacing it with junit-vintage-engine * removing junit4 dependency and replacing it with junit-vintage-engine in testing-modules, maven-modules and aws-lambda * removing junit dependency and replacing it with junit-vintage-engine * removing junit and replacing it with junit-vintage-engine * fixing tests that were not getting discovered due to old version of junit:junit * updated failsafe plugin configuration to skip integration tests in blade * fixing tests that were not getting discovered due to old version of junit:junit * fixing tests in libraries and libraries-2 modules Co-authored-by: chaos2418 <> * Java 3590 - fixing integration tests in restx and spring-5-webflux (#11382) * JAVA-3590: updating junit-jupiter dependency in the main pom.xml * resolving unnecessary mockito stubbings exception * adding junit-bom in dependency management * fixing tests which were not getting discovered * Revert "fixing tests which were not getting discovered" This reverts commit 2e9ed8df42eb96f7e0929167aabbc2ddd374a263. * fixing tests in ninja, open-liberty and spring-ejb * removing junit4 dependency and replacing it with junit-vintage-engine * removing junit4 dependency and replacing it with junit-vintage-engine in testing-modules, maven-modules and aws-lambda * removing junit dependency and replacing it with junit-vintage-engine * removing junit and replacing it with junit-vintage-engine * fixing tests that were not getting discovered due to old version of junit:junit * updated failsafe plugin configuration to skip integration tests in blade * fixing tests that were not getting discovered due to old version of junit:junit * fixing tests in libraries and libraries-2 modules * fixing integration tests in restx and spring-5-webflux Co-authored-by: chaos2418 <> Co-authored-by: chaos2418 <92030908+chaos2418@users.noreply.github.com> --- algorithms-miscellaneous-5/pom.xml | 3 +- algorithms-miscellaneous-6/pom.xml | 3 +- algorithms-sorting-2/pom.xml | 3 +- algorithms-sorting/pom.xml | 3 +- apache-shiro/pom.xml | 4 -- atomikos/pom.xml | 6 +-- aws-lambda/lambda/pom.xml | 7 ++++ .../shipping-tracker/ShippingFunction/pom.xml | 18 ++++---- aws-lambda/todo-reminder/ToDoFunction/pom.xml | 41 ++++++++++++------- blade/pom.xml | 1 + core-groovy-2/gmavenplus-pom.xml | 5 +-- core-groovy-2/pom.xml | 5 +-- core-groovy-collections/pom.xml | 5 +-- core-groovy-strings/pom.xml | 5 +-- core-groovy/pom.xml | 5 +-- core-java-modules/core-java-11-2/pom.xml | 7 ++-- .../core-java-9-improvements/pom.xml | 3 +- .../core-java-9-new-features/pom.xml | 3 +- core-java-modules/core-java-9/pom.xml | 3 +- .../core-java-collections-2/pom.xml | 3 +- .../core-java-concurrency-2/pom.xml | 6 +-- core-java-modules/core-java-jndi/pom.xml | 7 ++-- core-java-modules/core-java-jvm-2/pom.xml | 5 +-- core-java-modules/core-java-jvm/pom.xml | 5 +-- .../core-java-networking-3/pom.xml | 5 +-- core-java-modules/core-java-os/pom.xml | 3 +- .../example/soundapi/AppUnitTest.java | 3 ++ core-java-modules/core-java-streams-2/pom.xml | 6 +-- .../core-java-string-conversions-2/pom.xml | 5 +-- .../multimodulemavenproject/pom.xml | 6 --- core-java-modules/pom.xml | 1 - ddd-modules/pom.xml | 1 - ethereum/pom.xml | 17 +++++--- google-web-toolkit/pom.xml | 6 +-- grpc/pom.xml | 6 +-- guava-modules/guava-collections-list/pom.xml | 1 - guava-modules/guava-collections-map/pom.xml | 3 -- guava-modules/guava-collections-set/pom.xml | 1 - guava-modules/guava-collections/pom.xml | 1 - guava-modules/guava-io/pom.xml | 4 -- guava-modules/guava-utilities/pom.xml | 1 - guava-modules/pom.xml | 1 - guest/core-kotlin/pom.xml | 6 +-- guest/junit5-example/pom.xml | 7 +--- jackson-modules/pom.xml | 4 -- jackson-simple/pom.xml | 1 - java-collections-conversions-2/pom.xml | 6 +-- json-2/pom.xml | 8 ++-- libraries-2/pom.xml | 7 ++++ libraries-data/pom.xml | 6 +-- libraries-primitive/pom.xml | 28 ++++++++++--- libraries-security/pom.xml | 4 +- libraries-server/pom.xml | 6 +-- libraries/pom.xml | 6 +-- logging-modules/log-mdc/pom.xml | 1 - logging-modules/pom.xml | 4 -- .../copy-rename-maven-plugin/pom.xml | 11 +---- .../maven-antrun-plugin/pom.xml | 11 +---- .../maven-resources-plugin/pom.xml | 11 +---- maven-modules/maven-copy-files/pom.xml | 7 ++-- .../maven-custom-plugin/usage-example/pom.xml | 8 ++-- maven-modules/maven-dependency/pom.xml | 12 ++---- maven-modules/maven-integration-test/pom.xml | 6 +-- maven-modules/maven-properties/pom.xml | 8 ++-- maven-modules/pom.xml | 21 ++++++++++ micronaut/pom.xml | 6 +-- ninja/pom.xml | 20 +++++++++ open-liberty/pom.xml | 14 +++++-- parent-boot-2/pom.xml | 13 ++++++ patterns/cqrs-es/pom.xml | 6 +-- patterns/pom.xml | 6 +++ persistence-modules/deltaspike/pom.xml | 8 ++++ persistence-modules/java-jpa-3/pom.xml | 6 +-- persistence-modules/pom.xml | 2 - .../controller/BooksControllerUnitTest.java | 21 ++++------ .../repository/BooksRepositoryUnitTest.java | 23 ++++------- .../spring-data-cassandra/pom.xml | 7 ++++ pom.xml | 22 +++++----- quarkus-vs-springboot/quarkus-project/pom.xml | 6 --- quarkus/pom.xml | 18 +++++++- restx/pom.xml | 12 ++++-- spring-5-webflux/pom.xml | 21 ++++++++++ spring-boot-modules/pom.xml | 1 - .../spring-boot-basic-customization-2/pom.xml | 4 -- .../spring-boot-logging-log4j2/pom.xml | 22 ++++++++++ .../spring-boot-with-starter-parent/pom.xml | 4 -- spring-cloud/spring-cloud-archaius/pom.xml | 3 +- spring-cloud/spring-cloud-aws/pom.xml | 14 +++++++ .../twitterhdfs/pom.xml | 26 ++++++++++++ spring-ejb/ejb-beans/pom.xml | 29 +++++++++---- spring-ejb/pom.xml | 8 ++++ .../pom.xml | 13 ++++-- spring-web-modules/spring-boot-jsp/pom.xml | 9 +++- spring-web-modules/spring-rest-simple/pom.xml | 4 +- .../spring-resttemplate/pom.xml | 6 +-- testing-modules/assertion-libraries/pom.xml | 14 +++++++ testing-modules/junit-5-advanced/pom.xml | 7 +--- testing-modules/junit-5-basics/pom.xml | 7 +--- testing-modules/junit-5/pom.xml | 17 ++++---- testing-modules/junit5-annotations/pom.xml | 12 +++--- testing-modules/junit5-migration/pom.xml | 7 +--- .../MockitoUnecessaryStubUnitTest.java | 4 +- .../math-test-functions/pom.xml | 6 +-- .../string-test-functions/pom.xml | 6 +-- testing-modules/selenium-junit-testng/pom.xml | 11 ++--- testing-modules/spring-testing/pom.xml | 10 ++--- testing-modules/test-containers/pom.xml | 8 ++-- testing-modules/testing-assertions/pom.xml | 1 - testing-modules/testing-libraries-2/pom.xml | 20 ++++++--- testing-modules/testing-libraries/pom.xml | 11 +++++ xml/pom.xml | 1 - 111 files changed, 536 insertions(+), 376 deletions(-) diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 1ba535dfbc..32ecce58a6 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -37,7 +37,7 @@ org.junit.platform junit-platform-commons - ${junit.platform.version} + ${junit-platform.version} org.assertj @@ -53,7 +53,6 @@ 1.11 3.6.1 28.1-jre - 1.6.0 \ No newline at end of file diff --git a/algorithms-miscellaneous-6/pom.xml b/algorithms-miscellaneous-6/pom.xml index c9479d160e..6d5f211c8a 100644 --- a/algorithms-miscellaneous-6/pom.xml +++ b/algorithms-miscellaneous-6/pom.xml @@ -22,7 +22,7 @@ org.junit.platform junit-platform-commons - ${junit.platform.version} + ${junit-platform.version} org.assertj @@ -46,7 +46,6 @@ 28.1-jre 3.9.0 - 1.6.0 3.6.1 diff --git a/algorithms-sorting-2/pom.xml b/algorithms-sorting-2/pom.xml index f2a31d957d..b673af9d70 100644 --- a/algorithms-sorting-2/pom.xml +++ b/algorithms-sorting-2/pom.xml @@ -32,7 +32,7 @@ org.junit.jupiter junit-jupiter-api - ${junit-jupiter-api.version} + ${junit-jupiter.version} test @@ -47,7 +47,6 @@ 3.6.1 3.9.0 1.11 - 5.3.1 \ No newline at end of file diff --git a/algorithms-sorting/pom.xml b/algorithms-sorting/pom.xml index cae5eb6efc..b853fd80ee 100644 --- a/algorithms-sorting/pom.xml +++ b/algorithms-sorting/pom.xml @@ -33,7 +33,7 @@ org.junit.jupiter junit-jupiter-api - ${junit-jupiter-api.version} + ${junit-jupiter.version} test @@ -48,7 +48,6 @@ 3.6.1 3.9.0 1.11 - 5.3.1 \ No newline at end of file diff --git a/apache-shiro/pom.xml b/apache-shiro/pom.xml index f956883d5f..325a9939b9 100644 --- a/apache-shiro/pom.xml +++ b/apache-shiro/pom.xml @@ -39,10 +39,6 @@ runtime - - org.springframework.boot - spring-boot-starter-web - org.springframework.boot spring-boot-starter-security diff --git a/atomikos/pom.xml b/atomikos/pom.xml index 405231fea7..cb10168c0d 100644 --- a/atomikos/pom.xml +++ b/atomikos/pom.xml @@ -72,9 +72,9 @@ ${derby.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/aws-lambda/lambda/pom.xml b/aws-lambda/lambda/pom.xml index b6074f16d3..dea951d1b3 100644 --- a/aws-lambda/lambda/pom.xml +++ b/aws-lambda/lambda/pom.xml @@ -62,6 +62,13 @@ com.googlecode.json-simple json-simple ${json-simple.version} + + + + junit + junit + + diff --git a/aws-lambda/shipping-tracker/ShippingFunction/pom.xml b/aws-lambda/shipping-tracker/ShippingFunction/pom.xml index 99f9c1d051..72e3ac7959 100644 --- a/aws-lambda/shipping-tracker/ShippingFunction/pom.xml +++ b/aws-lambda/shipping-tracker/ShippingFunction/pom.xml @@ -12,23 +12,17 @@ com.amazonaws aws-lambda-java-core - 1.2.0 + ${aws-lambda-java-core.version} com.amazonaws aws-lambda-java-events - 3.1.0 + ${aws-lambda-java-events.version} com.fasterxml.jackson.core jackson-databind - 2.11.2 - - - junit - junit - 4.12 - test + ${jackson-databind.version} org.hibernate @@ -43,7 +37,7 @@ org.postgresql postgresql - 42.2.16 + ${postgresql.version} @@ -71,6 +65,10 @@ 1.8 1.8 5.4.21.Final + 1.2.0 + 3.1.0 + 2.11.2 + 42.2.16 \ No newline at end of file diff --git a/aws-lambda/todo-reminder/ToDoFunction/pom.xml b/aws-lambda/todo-reminder/ToDoFunction/pom.xml index 832cee841d..c17ff8bf15 100644 --- a/aws-lambda/todo-reminder/ToDoFunction/pom.xml +++ b/aws-lambda/todo-reminder/ToDoFunction/pom.xml @@ -12,70 +12,70 @@ com.amazonaws aws-lambda-java-core - 1.2.1 + ${aws-lambda-java-core.version} com.amazonaws aws-lambda-java-events - 3.6.0 + ${aws-lambda-java-events.version} uk.org.webcompere lightweight-config - 1.1.0 + ${lightweight-config.version} com.amazonaws aws-lambda-java-log4j2 - 1.2.0 + ${aws-lambda-java-log4j2.version} org.apache.logging.log4j log4j-slf4j-impl - 2.13.2 + ${log4j-slf4j-impl.version} io.github.openfeign feign-core - 11.2 + ${feign-core.version} io.github.openfeign feign-slf4j - 11.2 + ${feign-core.version} io.github.openfeign feign-gson - 11.2 + ${feign-core.version} com.google.inject guice - 5.0.1 + ${guice.version} - junit - junit - 4.13.1 + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test uk.org.webcompere system-stubs-junit4 - 1.2.0 + ${system-stubs-junit4.version} test org.mockito mockito-core - 3.3.0 + ${mockito-core.version} test org.assertj assertj-core - 3.19.0 + ${assertj-core.version} test @@ -103,6 +103,17 @@ 1.8 1.8 + 1.2.1 + 3.6.0 + 1.1.0 + 1.2.0 + 2.13.2 + 11.2 + 5.0.1 + 1.2.0 + 3.3.0 + 3.19.0 + 5.8.1 \ No newline at end of file diff --git a/blade/pom.xml b/blade/pom.xml index 6ab3a594f2..8fc517e966 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -70,6 +70,7 @@ maven-failsafe-plugin ${maven-failsafe-plugin.version} + true **/*LiveTest.java diff --git a/core-groovy-2/gmavenplus-pom.xml b/core-groovy-2/gmavenplus-pom.xml index 54c89b9834..4dbdfe7d42 100644 --- a/core-groovy-2/gmavenplus-pom.xml +++ b/core-groovy-2/gmavenplus-pom.xml @@ -33,7 +33,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -95,7 +95,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit.platform.version} + ${junit-platform-surefire-provider.version} @@ -165,7 +165,6 @@ UTF-8 - 1.0.0 2.4.0 1.1-groovy-2.4 3.9 diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index 89df666333..6b78e21080 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -34,7 +34,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -94,7 +94,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit.platform.version} + ${junit-platform-surefire-provider.version} @@ -162,7 +162,6 @@ - 1.0.0 2.4.0 1.1-groovy-2.4 1.1.3 diff --git a/core-groovy-collections/pom.xml b/core-groovy-collections/pom.xml index c4e02cfed8..d589fc74e5 100644 --- a/core-groovy-collections/pom.xml +++ b/core-groovy-collections/pom.xml @@ -39,7 +39,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -80,7 +80,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit.platform.version} + ${junit-platform-surefire-provider.version} @@ -119,7 +119,6 @@ - 1.0.0 2.5.6 2.5.6 2.5.6 diff --git a/core-groovy-strings/pom.xml b/core-groovy-strings/pom.xml index 76d1754b98..333b15cdbe 100644 --- a/core-groovy-strings/pom.xml +++ b/core-groovy-strings/pom.xml @@ -39,7 +39,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -80,7 +80,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit.platform.version} + ${junit-platform-surefire-provider.version} @@ -109,7 +109,6 @@ - 1.0.0 2.5.6 2.5.6 2.5.6 diff --git a/core-groovy/pom.xml b/core-groovy/pom.xml index 3e1913dd7b..c24982c6a2 100644 --- a/core-groovy/pom.xml +++ b/core-groovy/pom.xml @@ -39,7 +39,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -80,7 +80,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit.platform.version} + ${junit-platform-surefire-provider.version} @@ -109,7 +109,6 @@ - 1.0.0 2.5.6 2.5.6 2.5.6 diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index e26e31da44..68e8b66d67 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -35,19 +35,19 @@ org.junit.jupiter junit-jupiter-engine - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-params - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-api - ${junit.jupiter.version} + ${junit-jupiter.version} test @@ -106,7 +106,6 @@ 11 11 29.0-jre - 5.7.0 3.17.2 5.11.1 3.12.0 diff --git a/core-java-modules/core-java-9-improvements/pom.xml b/core-java-modules/core-java-9-improvements/pom.xml index b047e15969..6abdd7dab8 100644 --- a/core-java-modules/core-java-9-improvements/pom.xml +++ b/core-java-modules/core-java-9-improvements/pom.xml @@ -40,7 +40,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -70,7 +70,6 @@ 3.10.0 - 1.2.0 1.7.0 1.9 1.9 diff --git a/core-java-modules/core-java-9-new-features/pom.xml b/core-java-modules/core-java-9-new-features/pom.xml index 00480a28e1..7dca8d5f88 100644 --- a/core-java-modules/core-java-9-new-features/pom.xml +++ b/core-java-modules/core-java-9-new-features/pom.xml @@ -29,7 +29,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -158,7 +158,6 @@ 3.0.0 3.10.0 - 1.2.0 4.0.2 1.9 1.9 diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 543c3891ee..1bd650f7d2 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -35,7 +35,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -80,7 +80,6 @@ 3.10.0 - 1.2.0 1.7.0 1.9 1.9 diff --git a/core-java-modules/core-java-collections-2/pom.xml b/core-java-modules/core-java-collections-2/pom.xml index 4e171eed48..0f1f1ee2fe 100644 --- a/core-java-modules/core-java-collections-2/pom.xml +++ b/core-java-modules/core-java-collections-2/pom.xml @@ -43,7 +43,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -52,7 +52,6 @@ 7.1.0 4.1 3.11.1 - 1.2.0 1.3 diff --git a/core-java-modules/core-java-concurrency-2/pom.xml b/core-java-modules/core-java-concurrency-2/pom.xml index 5196872e21..b8a1d641d4 100644 --- a/core-java-modules/core-java-concurrency-2/pom.xml +++ b/core-java-modules/core-java-concurrency-2/pom.xml @@ -16,9 +16,8 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine test @@ -96,7 +95,6 @@ - 4.13 0.2 1.1 1.01 diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index dae0e9bb35..f1b374b2b5 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -18,19 +18,19 @@ org.junit.jupiter junit-jupiter - ${jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-api - ${jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-engine - ${jupiter.version} + ${junit-jupiter.version} org.springframework @@ -76,7 +76,6 @@ 5.0.9.RELEASE 1.4.199 - 5.5.1 1.8 1.8 diff --git a/core-java-modules/core-java-jvm-2/pom.xml b/core-java-modules/core-java-jvm-2/pom.xml index 5bc5b5e3a5..173cf27955 100644 --- a/core-java-modules/core-java-jvm-2/pom.xml +++ b/core-java-modules/core-java-jvm-2/pom.xml @@ -16,9 +16,8 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine test diff --git a/core-java-modules/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml index 58934065a3..afbe0b0ee3 100644 --- a/core-java-modules/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -17,9 +17,8 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine test diff --git a/core-java-modules/core-java-networking-3/pom.xml b/core-java-modules/core-java-networking-3/pom.xml index de2408ec0d..4a05af8b25 100644 --- a/core-java-modules/core-java-networking-3/pom.xml +++ b/core-java-modules/core-java-networking-3/pom.xml @@ -36,9 +36,8 @@ test - junit - junit - 4.11 + org.junit.vintage + junit-vintage-engine test diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 572000a714..b279e3d6cb 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -19,7 +19,7 @@ org.junit.jupiter junit-jupiter-engine - ${junit-jupiter-engine.version} + ${junit-jupiter.version} test @@ -94,7 +94,6 @@ 25.1-jre 0.4 1.8.7 - 5.7.2 \ No newline at end of file diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java index 38f21320e3..27bc750d8a 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/example/soundapi/AppUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.example.soundapi; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; @@ -37,6 +38,7 @@ public class AppUnitTest { } @Test + @Disabled public void Given_TargetLineDataObject_When_Run_Then_GeneratesOutputStream() { soundRecorder.setFormat(af); @@ -52,6 +54,7 @@ public class AppUnitTest { } @Test + @Disabled public void Given_AudioInputStream_When_NotNull_Then_SaveToWavFile() { soundRecorder.setFormat(af); soundRecorder.build(af); diff --git a/core-java-modules/core-java-streams-2/pom.xml b/core-java-modules/core-java-streams-2/pom.xml index 5f25a2d9fb..087a8378b1 100644 --- a/core-java-modules/core-java-streams-2/pom.xml +++ b/core-java-modules/core-java-streams-2/pom.xml @@ -31,11 +31,9 @@ ${log4j.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine test - jar org.assertj diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index 44968678f2..ff4955726b 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -21,9 +21,8 @@ ${guava.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine test diff --git a/core-java-modules/multimodulemavenproject/pom.xml b/core-java-modules/multimodulemavenproject/pom.xml index f45774ae00..79d884cd86 100644 --- a/core-java-modules/multimodulemavenproject/pom.xml +++ b/core-java-modules/multimodulemavenproject/pom.xml @@ -25,12 +25,6 @@ - - junit - junit - ${junit.version} - test - org.assertj assertj-core diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 5291c8c3ca..9f184310e9 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -136,7 +136,6 @@ 2.22.2 - 5.6.2 diff --git a/ddd-modules/pom.xml b/ddd-modules/pom.xml index 376dad89e5..fe3aaf1160 100644 --- a/ddd-modules/pom.xml +++ b/ddd-modules/pom.xml @@ -81,7 +81,6 @@ 1.0 - 5.6.2 3.12.2 diff --git a/ethereum/pom.xml b/ethereum/pom.xml index b9a3870702..7fc4057341 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung.ethereum ethereum @@ -112,6 +112,13 @@ spring-boot-starter-test test ${spring.boot.version} + + + + junit + junit + + org.springframework @@ -138,9 +145,9 @@ test - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/google-web-toolkit/pom.xml b/google-web-toolkit/pom.xml index 6b93ccbc71..1a49ced021 100644 --- a/google-web-toolkit/pom.xml +++ b/google-web-toolkit/pom.xml @@ -45,9 +45,9 @@ provided - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/grpc/pom.xml b/grpc/pom.xml index 50700b0785..f034b2b517 100644 --- a/grpc/pom.xml +++ b/grpc/pom.xml @@ -38,9 +38,9 @@ test - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/guava-modules/guava-collections-list/pom.xml b/guava-modules/guava-collections-list/pom.xml index d281be2235..e57198ec40 100644 --- a/guava-modules/guava-collections-list/pom.xml +++ b/guava-modules/guava-collections-list/pom.xml @@ -70,7 +70,6 @@ 3.6.1 2.0.0.0 - 5.6.2 \ No newline at end of file diff --git a/guava-modules/guava-collections-map/pom.xml b/guava-modules/guava-collections-map/pom.xml index a03a779b3e..7f3e470fc3 100644 --- a/guava-modules/guava-collections-map/pom.xml +++ b/guava-modules/guava-collections-map/pom.xml @@ -40,7 +40,4 @@ - - 5.6.2 - \ No newline at end of file diff --git a/guava-modules/guava-collections-set/pom.xml b/guava-modules/guava-collections-set/pom.xml index b989966a54..09e3f42e83 100644 --- a/guava-modules/guava-collections-set/pom.xml +++ b/guava-modules/guava-collections-set/pom.xml @@ -43,7 +43,6 @@ 3.6.1 - 5.6.2 \ No newline at end of file diff --git a/guava-modules/guava-collections/pom.xml b/guava-modules/guava-collections/pom.xml index 021c4c6037..6dc7510a1e 100644 --- a/guava-modules/guava-collections/pom.xml +++ b/guava-modules/guava-collections/pom.xml @@ -76,7 +76,6 @@ 3.6.1 2.0.0.0 - 5.6.2 \ No newline at end of file diff --git a/guava-modules/guava-io/pom.xml b/guava-modules/guava-io/pom.xml index f6ebac8ba4..11a5d4ada6 100644 --- a/guava-modules/guava-io/pom.xml +++ b/guava-modules/guava-io/pom.xml @@ -39,8 +39,4 @@ - - 5.6.2 - - \ No newline at end of file diff --git a/guava-modules/guava-utilities/pom.xml b/guava-modules/guava-utilities/pom.xml index a9aca0ee08..6049a62e85 100644 --- a/guava-modules/guava-utilities/pom.xml +++ b/guava-modules/guava-utilities/pom.xml @@ -53,7 +53,6 @@ - 5.6.2 3.6.1 diff --git a/guava-modules/pom.xml b/guava-modules/pom.xml index 8ffac98b51..cbfb47fa0f 100644 --- a/guava-modules/pom.xml +++ b/guava-modules/pom.xml @@ -50,7 +50,6 @@ 2.22.2 - 5.6.2 29.0-jre diff --git a/guest/core-kotlin/pom.xml b/guest/core-kotlin/pom.xml index ad0368c6ab..91bc7fa170 100644 --- a/guest/core-kotlin/pom.xml +++ b/guest/core-kotlin/pom.xml @@ -19,7 +19,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -160,7 +160,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit.platform.version} + ${junit-platform-surefire-provider.version} @@ -191,8 +191,6 @@ 0.22.5 1.5.0 3.6.1 - 1.0.0 - 5.2.0 3.10.0 3.7.0 1.1.5 diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml index 05e320f96d..a88f739891 100644 --- a/guest/junit5-example/pom.xml +++ b/guest/junit5-example/pom.xml @@ -18,12 +18,12 @@ org.junit.jupiter junit-jupiter-params - ${junit.jupiter.version} + ${junit-jupiter.version} org.junit.vintage junit-vintage-engine - ${junit-vintage.version} + ${junit-jupiter.version} com.h2database @@ -59,9 +59,6 @@ - 5.0.0-M4 - 4.12.0-M4 2.8.2 - 1.0.0-M4 \ No newline at end of file diff --git a/jackson-modules/pom.xml b/jackson-modules/pom.xml index 3d9d83553e..1bb684af0a 100644 --- a/jackson-modules/pom.xml +++ b/jackson-modules/pom.xml @@ -49,8 +49,4 @@ - - 5.6.2 - - \ No newline at end of file diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index 204954ce60..72e31ee5e3 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -54,7 +54,6 @@ - 5.6.2 3.11.0 diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index a81b245b33..55dc6e30b6 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -33,9 +33,9 @@ ${modelmapper.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/json-2/pom.xml b/json-2/pom.xml index 733fbc6668..53d67320ba 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -8,8 +8,8 @@ 0.0.1-SNAPSHOT - parent-modules com.baeldung + parent-modules 1.0.0-SNAPSHOT @@ -25,9 +25,9 @@ ${jsoniter.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 104d3cbabc..700a0a02d4 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -53,6 +53,13 @@ org.jbpm jbpm-test ${jbpm.version} + + + + junit + junit + + info.picocli diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index c5ad08448f..3db34709e7 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -15,9 +15,9 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/libraries-primitive/pom.xml b/libraries-primitive/pom.xml index 06c42bd6c9..ed4982d91c 100644 --- a/libraries-primitive/pom.xml +++ b/libraries-primitive/pom.xml @@ -15,11 +15,16 @@ fastutil ${fastutil.version} - - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test @@ -43,14 +48,27 @@ + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + 8.2.2 - 4.12 10.0.0 1.8 1.8 1.28 1.28 + 5.8.1 + 2.22.2 \ No newline at end of file diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index 46e12eb655..001ecc54a0 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -49,8 +49,8 @@ ${bouncycastle.version} - junit - junit + org.junit.vintage + junit-vintage-engine test diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml index b283164daa..a9c340b319 100644 --- a/libraries-server/pom.xml +++ b/libraries-server/pom.xml @@ -62,9 +62,9 @@ ${netty.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/libraries/pom.xml b/libraries/pom.xml index 59e79f0775..4ecf82aa87 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -147,9 +147,9 @@ ${jmh-core.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/logging-modules/log-mdc/pom.xml b/logging-modules/log-mdc/pom.xml index ddf1f23f8c..a21b9a8fb7 100644 --- a/logging-modules/log-mdc/pom.xml +++ b/logging-modules/log-mdc/pom.xml @@ -97,7 +97,6 @@ 2.7 3.3.6 3.3.0.Final - 5.6.2 \ No newline at end of file diff --git a/logging-modules/pom.xml b/logging-modules/pom.xml index d7b820040a..7e358ae490 100644 --- a/logging-modules/pom.xml +++ b/logging-modules/pom.xml @@ -22,8 +22,4 @@ log-mdc - - 5.6.2 - - \ No newline at end of file diff --git a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml index e2f0d57e3a..6feb8284e6 100644 --- a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml +++ b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml @@ -9,20 +9,11 @@ copy-rename-maven-plugin - maven-copy-files com.baeldung + maven-copy-files 1.0-SNAPSHOT - - - junit - junit - 4.11 - test - - - diff --git a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml index 97e714d9ff..5168e0e965 100644 --- a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml @@ -9,20 +9,11 @@ maven-antrun-plugin - maven-copy-files com.baeldung + maven-copy-files 1.0-SNAPSHOT - - - junit - junit - 4.11 - test - - - diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml index 8942c84f6f..6829898b45 100644 --- a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml @@ -9,20 +9,11 @@ maven-resources-plugin - maven-copy-files com.baeldung + maven-copy-files 1.0-SNAPSHOT - - - junit - junit - 4.11 - test - - - diff --git a/maven-modules/maven-copy-files/pom.xml b/maven-modules/maven-copy-files/pom.xml index d2208d68eb..94bf952361 100644 --- a/maven-modules/maven-copy-files/pom.xml +++ b/maven-modules/maven-copy-files/pom.xml @@ -12,8 +12,8 @@ http://www.example.com - maven-modules com.baeldung + maven-modules 0.0.1-SNAPSHOT @@ -25,9 +25,8 @@ - junit - junit - 4.11 + org.junit.vintage + junit-vintage-engine test diff --git a/maven-modules/maven-custom-plugin/usage-example/pom.xml b/maven-modules/maven-custom-plugin/usage-example/pom.xml index bf5a69146b..1791bd6627 100644 --- a/maven-modules/maven-custom-plugin/usage-example/pom.xml +++ b/maven-modules/maven-custom-plugin/usage-example/pom.xml @@ -15,9 +15,9 @@ ${commons.lang3.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test @@ -44,7 +44,7 @@ 3.9 - 4.12 + 5.8.1 \ No newline at end of file diff --git a/maven-modules/maven-dependency/pom.xml b/maven-modules/maven-dependency/pom.xml index 7f80ea1222..f17998c327 100644 --- a/maven-modules/maven-dependency/pom.xml +++ b/maven-modules/maven-dependency/pom.xml @@ -9,19 +9,13 @@ pom - maven-modules com.baeldung + maven-modules 0.0.1-SNAPSHOT - - junit - junit - 4.13.2 - test - org.apache.commons commons-lang3 @@ -32,8 +26,8 @@ - junit - junit + org.junit.vintage + junit-vintage-engine org.apache.commons diff --git a/maven-modules/maven-integration-test/pom.xml b/maven-modules/maven-integration-test/pom.xml index 692751366d..4283baf63b 100644 --- a/maven-modules/maven-integration-test/pom.xml +++ b/maven-modules/maven-integration-test/pom.xml @@ -27,9 +27,9 @@ ${jersey.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/maven-modules/maven-properties/pom.xml b/maven-modules/maven-properties/pom.xml index f4c657c2e4..b3169a7fb0 100644 --- a/maven-modules/maven-properties/pom.xml +++ b/maven-modules/maven-properties/pom.xml @@ -16,9 +16,10 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test @@ -46,7 +47,6 @@ ${project.name} property-from-pom - 4.13 \ No newline at end of file diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index 54dc5e6ff6..0aadb873e5 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -40,4 +40,25 @@ maven-dependency + + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + + + + 5.8.1 + + \ No newline at end of file diff --git a/micronaut/pom.xml b/micronaut/pom.xml index e9b5a0409f..f36f565a94 100644 --- a/micronaut/pom.xml +++ b/micronaut/pom.xml @@ -65,9 +65,9 @@ runtime - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/ninja/pom.xml b/ninja/pom.xml index 93f22cf718..1cc13afb15 100644 --- a/ninja/pom.xml +++ b/ninja/pom.xml @@ -35,6 +35,25 @@ ninja-test-utilities ${ninja.version} test + + + + junit + junit + + + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test @@ -188,6 +207,7 @@ 1.3.1 2.8.2 2.2 + 5.8.1 \ No newline at end of file diff --git a/open-liberty/pom.xml b/open-liberty/pom.xml index 268b65c07e..df54d9f136 100644 --- a/open-liberty/pom.xml +++ b/open-liberty/pom.xml @@ -30,9 +30,15 @@ - junit - junit - ${version.junit} + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test @@ -100,7 +106,6 @@ 10.14.2.0 3.3-M3 3.2.3 - 4.12 1.0.5 3.2.6 1.0.4 @@ -110,6 +115,7 @@ 9080 9443 7070 + 5.8.1 \ No newline at end of file diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index 2e520640ec..8e8dbba54d 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -17,6 +17,13 @@ + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + org.springframework.boot spring-boot-dependencies @@ -51,6 +58,11 @@ + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + @@ -85,6 +97,7 @@ 1.9.1 3.4.0 + 2.22.2 \ No newline at end of file diff --git a/patterns/cqrs-es/pom.xml b/patterns/cqrs-es/pom.xml index 826440b45d..20eeb09e35 100644 --- a/patterns/cqrs-es/pom.xml +++ b/patterns/cqrs-es/pom.xml @@ -19,9 +19,8 @@ ${lombok.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine test @@ -29,7 +28,6 @@ 1.8 1.8 - 4.13 1.18.12 diff --git a/patterns/pom.xml b/patterns/pom.xml index 6e92ad2813..3c93f00478 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -33,6 +33,12 @@ + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + javax.servlet javax.servlet-api diff --git a/persistence-modules/deltaspike/pom.xml b/persistence-modules/deltaspike/pom.xml index 1255e5ab27..5003ef9daf 100644 --- a/persistence-modules/deltaspike/pom.xml +++ b/persistence-modules/deltaspike/pom.xml @@ -18,6 +18,14 @@ + + + junit + junit + ${junit.version} + test + 2.22.2 - 5.6.2 - 4.13 \ No newline at end of file diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java index 757b32385b..4f2bff18d9 100644 --- a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java +++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java @@ -1,21 +1,18 @@ package com.baeldung.spring.redis.configuration.controller; +import com.baeldung.spring.redis.configuration.entity.Book; +import com.baeldung.spring.redis.configuration.repository.BooksRepository; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.when; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.baeldung.spring.redis.configuration.entity.Book; -import com.baeldung.spring.redis.configuration.repository.BooksRepository; - @RunWith(MockitoJUnitRunner.class) public class BooksControllerUnitTest { @@ -44,8 +41,6 @@ public class BooksControllerUnitTest { @Test public void whenFindOneNotFound_thenReturnsNull() { - Book book = new Book(BOOK_ID, BOOK_NAME); - when(booksRepository.findById(BOOK_ID)).thenReturn(book); assertNull(booksController.findOne(OTHER_BOOK_ID)); } diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java index f32800e165..454447c9c9 100644 --- a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java +++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java @@ -1,23 +1,20 @@ package com.baeldung.spring.redis.configuration.repository; +import com.baeldung.spring.redis.configuration.entity.Book; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.baeldung.spring.redis.configuration.entity.Book; - @RunWith(MockitoJUnitRunner.class) public class BooksRepositoryUnitTest { @@ -55,9 +52,7 @@ public class BooksRepositoryUnitTest { @Test public void whenFindByIdNotFound_thenReturnsNull() { - Book book = new Book(BOOK_ID, BOOK_NAME); when(redisTemplate.opsForValue()).thenReturn(valueOperations); - when(valueOperations.get(BOOK_ID)).thenReturn(book); assertNull(booksRepository.findById(OTHER_BOOK_ID)); verify(redisTemplate, times(1)).opsForValue(); verify(valueOperations, times(1)).get(OTHER_BOOK_ID); diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index e2b47ce024..8092c05a40 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -48,6 +48,13 @@ cassandra-unit-shaded ${cassandra-unit-shaded.version} test + + + + junit + junit + + org.hectorclient diff --git a/pom.xml b/pom.xml index 7a415ad976..220e417869 100644 --- a/pom.xml +++ b/pom.xml @@ -34,12 +34,6 @@ - - junit - junit - ${junit.version} - test - org.junit.jupiter junit-jupiter-engine @@ -58,6 +52,12 @@ ${junit-jupiter.version} test + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + org.hamcrest hamcrest @@ -116,7 +116,7 @@ org.junit.platform junit-platform-surefire-provider - ${junit-platform.version} + ${junit-platform-surefire-provider.version} org.junit.jupiter @@ -1385,7 +1385,8 @@ false true - 4.12 + + 4.13.2 2.2 1.3 3.3.0 @@ -1417,8 +1418,9 @@ 1.2 2.13.0 1.4 - 1.2.0 - 5.2.0 + 1.8.1 + 5.8.1 + 1.3.2 0.3.1 2.5.2 0.0.1 diff --git a/quarkus-vs-springboot/quarkus-project/pom.xml b/quarkus-vs-springboot/quarkus-project/pom.xml index c9eae79a88..58d547f3b0 100644 --- a/quarkus-vs-springboot/quarkus-project/pom.xml +++ b/quarkus-vs-springboot/quarkus-project/pom.xml @@ -67,12 +67,6 @@ rest-assured test - - junit - junit - 4.8.2 - test - diff --git a/quarkus/pom.xml b/quarkus/pom.xml index e88fd4dc5a..d826729ad7 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -16,6 +16,20 @@ + + + junit + junit + ${junit.version} + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + io.quarkus quarkus-bom @@ -54,7 +68,7 @@ org.projectlombok lombok - 1.18.6 + ${lombok.version} provided @@ -157,7 +171,7 @@ 1.7.0.Final - 5.6.0 + 1.18.6 \ No newline at end of file diff --git a/restx/pom.xml b/restx/pom.xml index 83dd2afd58..ea9f927563 100644 --- a/restx/pom.xml +++ b/restx/pom.xml @@ -106,11 +106,17 @@ restx-specs-tests ${restx.version} test + + + junit + junit + + - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index b37e93ded8..69de83c227 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -17,6 +17,13 @@ + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + org.springframework.boot spring-boot-dependencies @@ -44,6 +51,20 @@ org.springframework.boot spring-boot-starter-test test + + + org.junit.jupiter + junit-jupiter + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.platform + junit-plaform-commons + + io.projectreactor diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 7a93cabb82..9f179dd97f 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -107,7 +107,6 @@ - 5.6.2 2.22.2 diff --git a/spring-boot-modules/spring-boot-basic-customization-2/pom.xml b/spring-boot-modules/spring-boot-basic-customization-2/pom.xml index 8c1bc22600..6f3cb48b81 100644 --- a/spring-boot-modules/spring-boot-basic-customization-2/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization-2/pom.xml @@ -24,10 +24,6 @@ org.springframework.boot spring-boot-starter-test - - junit - junit - \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml index 2f69870961..dafbddb93f 100644 --- a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -16,6 +16,25 @@ + + + + + junit + junit + ${junit.version} + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + + org.springframework.boot @@ -80,6 +99,9 @@ 1.3.8.RELEASE 1.1.16 1.18.4 + + 4.13.2 + 5.8.1 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml index 5633e4d260..2568714278 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml @@ -30,10 +30,6 @@ org.springframework.boot spring-boot-starter-web - - junit - junit - diff --git a/spring-cloud/spring-cloud-archaius/pom.xml b/spring-cloud/spring-cloud-archaius/pom.xml index 9edd5d24c5..efd912f8db 100644 --- a/spring-cloud/spring-cloud-archaius/pom.xml +++ b/spring-cloud/spring-cloud-archaius/pom.xml @@ -54,14 +54,13 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test 2.0.3.RELEASE - 1.2.0 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml index 06448cc2ee..c9cd56bea6 100644 --- a/spring-cloud/spring-cloud-aws/pom.xml +++ b/spring-cloud/spring-cloud-aws/pom.xml @@ -18,6 +18,20 @@ + + + junit + junit + ${junit.version} + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + org.springframework.cloud spring-cloud-aws diff --git a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml index 9c8d4ac707..ba6cee1fce 100644 --- a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml +++ b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml @@ -16,6 +16,25 @@ + + + + + junit + junit + ${junit.version} + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + + @@ -38,6 +57,10 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + @@ -52,6 +75,9 @@ 2.1.2.RELEASE + + 4.13.2 + 5.8.1 \ No newline at end of file diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index d820819a78..10bc6d3104 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -32,11 +32,13 @@ javaee-api provided + - org.apache.openejb + org.apache.tomee tomee-embedded ${tomee-embedded.version} + org.springframework spring-context @@ -78,6 +80,18 @@ arquillian-junit-container test + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + + joda-time + joda-time + ${joda-time.version} + @@ -174,18 +188,19 @@ - 1.1.13.Final - 1.7.5 - 3.1.2 - 1.0.0.CR4 + 1.6.0.Final + 8.0.8 + 6.2.2 + 1.0.2 8.2.1.Final 3.2 5.2.3.RELEASE - 5.10.2 - 5.13.1 + 5.16.3 + 5.16.3 2.21.0 2.8 8.2.1.Final + 2.10.12 \ No newline at end of file diff --git a/spring-ejb/pom.xml b/spring-ejb/pom.xml index 383cde1e69..0b52fa52b1 100755 --- a/spring-ejb/pom.xml +++ b/spring-ejb/pom.xml @@ -26,6 +26,14 @@ + + + junit + junit + ${junit.version} + test + com.baeldung.spring.ejb spring-ejb-remote diff --git a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml index c3e694ba80..3e2bae73e2 100644 --- a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml +++ b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml @@ -86,11 +86,16 @@ - junit - junit - ${junit-version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test + + javax.annotation + javax.annotation-api + 1.3.2 + @@ -262,7 +267,7 @@ 0.2.1 2.9.10 1.0.0 - 4.13 + 5.8.1 \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/pom.xml b/spring-web-modules/spring-boot-jsp/pom.xml index 30335fcc65..222facd100 100644 --- a/spring-web-modules/spring-boot-jsp/pom.xml +++ b/spring-web-modules/spring-boot-jsp/pom.xml @@ -16,6 +16,13 @@ + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + org.springframework.boot spring-boot-dependencies @@ -84,8 +91,8 @@ 1.2 - 5.7.1 2.4.4 + 2.22.2 \ No newline at end of file diff --git a/spring-web-modules/spring-rest-simple/pom.xml b/spring-web-modules/spring-rest-simple/pom.xml index e7671e0af0..46bfa5d04c 100644 --- a/spring-web-modules/spring-rest-simple/pom.xml +++ b/spring-web-modules/spring-rest-simple/pom.xml @@ -121,8 +121,8 @@ - junit - junit + org.junit.vintage + junit-vintage-engine test diff --git a/spring-web-modules/spring-resttemplate/pom.xml b/spring-web-modules/spring-resttemplate/pom.xml index 221efd77ee..1379e40d23 100644 --- a/spring-web-modules/spring-resttemplate/pom.xml +++ b/spring-web-modules/spring-resttemplate/pom.xml @@ -110,9 +110,8 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine org.hamcrest @@ -284,7 +283,6 @@ 3.5.11 1.8 1.8 - 4.12 3.7.0 diff --git a/testing-modules/assertion-libraries/pom.xml b/testing-modules/assertion-libraries/pom.xml index 19ebebce05..14e0379a3c 100644 --- a/testing-modules/assertion-libraries/pom.xml +++ b/testing-modules/assertion-libraries/pom.xml @@ -18,6 +18,13 @@ com.google.truth truth ${truth.version} + + + + junit + junit + + com.google.truth.extensions @@ -46,6 +53,13 @@ jgotesting ${jgotesting.version} test + + + + junit + junit + + diff --git a/testing-modules/junit-5-advanced/pom.xml b/testing-modules/junit-5-advanced/pom.xml index 5fc466bb67..3f11c215ff 100644 --- a/testing-modules/junit-5-advanced/pom.xml +++ b/testing-modules/junit-5-advanced/pom.xml @@ -30,14 +30,9 @@ org.junit.vintage junit-vintage-engine - ${junit.vintage.version} + ${junit-jupiter.version} test - - 5.4.2 - 5.4.2 - - \ No newline at end of file diff --git a/testing-modules/junit-5-basics/pom.xml b/testing-modules/junit-5-basics/pom.xml index cf39068ae7..d92ee55682 100644 --- a/testing-modules/junit-5-basics/pom.xml +++ b/testing-modules/junit-5-basics/pom.xml @@ -25,13 +25,13 @@ org.junit.vintage junit-vintage-engine - ${junit.vintage.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-migrationsupport - ${junit.vintage.version} + ${junit-jupiter.version} test @@ -147,9 +147,6 @@ - 5.4.2 - 1.2.0 - 5.4.2 5.0.6.RELEASE diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index 4e1a7740ee..148abecb0f 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -20,42 +20,42 @@ org.junit.platform junit-platform-engine - ${junit.platform.version} + ${junit-platform.version} org.junit.jupiter junit-jupiter-engine - ${junit.jupiter.version} + ${junit-jupiter.version} org.junit.jupiter junit-jupiter-api - ${junit.jupiter.version} + ${junit-jupiter.version} org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test org.junit.platform junit-platform-console-standalone - 1.7.0 + ${junit-platform.version} test org.junit.vintage junit-vintage-engine - ${junit.vintage.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-migrationsupport - ${junit.vintage.version} + ${junit-jupiter.version} test @@ -137,10 +137,7 @@ - 5.4.2 2.23.0 - 1.4.2 - 5.4.2 2.8.2 2.0.0 2.22.0 diff --git a/testing-modules/junit5-annotations/pom.xml b/testing-modules/junit5-annotations/pom.xml index 127a1bf33f..79600eb589 100644 --- a/testing-modules/junit5-annotations/pom.xml +++ b/testing-modules/junit5-annotations/pom.xml @@ -19,22 +19,22 @@ org.junit.platform junit-platform-engine - ${junit.platform.version} + ${junit-platform.version} org.junit.jupiter junit-jupiter-engine - ${junit.jupiter.version} + ${junit-jupiter.version} org.junit.jupiter junit-jupiter-params - ${junit.jupiter.version} + ${junit-jupiter.version} org.junit.jupiter junit-jupiter-api - ${junit.jupiter.version} + ${junit-jupiter.version} org.apache.logging.log4j @@ -44,7 +44,7 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test @@ -56,8 +56,6 @@ - 5.7.0 - 1.7.0 2.8.2 3.11.1 diff --git a/testing-modules/junit5-migration/pom.xml b/testing-modules/junit5-migration/pom.xml index 2e864f6434..07f11e2b3a 100644 --- a/testing-modules/junit5-migration/pom.xml +++ b/testing-modules/junit5-migration/pom.xml @@ -30,13 +30,13 @@ org.junit.vintage junit-vintage-engine - ${junit.vintage.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-migrationsupport - ${junit.vintage.version} + ${junit-jupiter.version} test @@ -51,9 +51,6 @@ - 5.2.0 - 1.2.0 - 5.2.0 2.21.0 diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java index 828d31f6f9..c9ed8a5969 100644 --- a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java @@ -30,7 +30,9 @@ public class MockitoUnecessaryStubUnitTest { public void givenUnusedStub_whenInvokingGetThenThrowUnnecessaryStubbingException() { rule.expectedFailure(UnnecessaryStubbingException.class); - when(mockList.add("one")).thenReturn(true); + // Commenting this stubbing so that it doesn't affect the builds. + // If you want to reproduce UnnecessaryStubbingException then uncomment below line and execute the test. + // when(mockList.add("one")).thenReturn(true); when(mockList.get(anyInt())).thenReturn("hello"); assertEquals("List should contain hello", "hello", mockList.get(1)); diff --git a/testing-modules/parallel-tests-junit/math-test-functions/pom.xml b/testing-modules/parallel-tests-junit/math-test-functions/pom.xml index 39199834b9..eae1bf61e7 100644 --- a/testing-modules/parallel-tests-junit/math-test-functions/pom.xml +++ b/testing-modules/parallel-tests-junit/math-test-functions/pom.xml @@ -15,9 +15,9 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/testing-modules/parallel-tests-junit/string-test-functions/pom.xml b/testing-modules/parallel-tests-junit/string-test-functions/pom.xml index 39847444b5..c838558fc2 100644 --- a/testing-modules/parallel-tests-junit/string-test-functions/pom.xml +++ b/testing-modules/parallel-tests-junit/string-test-functions/pom.xml @@ -15,9 +15,9 @@ - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} test diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index f06d47247c..9f132c7562 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 selenium-junit-testng 0.0.1-SNAPSHOT @@ -32,9 +32,10 @@ ${testng.version} - junit - junit - ${junit.version} + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test org.hamcrest diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index bf4c1e7a69..e687f8d6fd 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -74,24 +74,24 @@ org.junit.jupiter junit-jupiter - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-engine - ${junit.jupiter.version} + ${junit-jupiter.version} org.junit.jupiter junit-jupiter-api - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.platform junit-platform-commons - ${junit.commons.version} + ${junit-platform.version} org.awaitility @@ -120,8 +120,6 @@ 2.0.0.0 3.1.6 - 5.7.0 - 1.7.0 5.3.4 4.0.1 2.1.1 diff --git a/testing-modules/test-containers/pom.xml b/testing-modules/test-containers/pom.xml index 4a65611c7a..24f686d741 100644 --- a/testing-modules/test-containers/pom.xml +++ b/testing-modules/test-containers/pom.xml @@ -20,19 +20,19 @@ org.junit.platform junit-platform-runner - ${junit.platform.version} + ${junit-platform.version} test org.junit.platform junit-platform-commons - ${junit.platform.version} + ${junit-platform.version} test org.junit.vintage junit-vintage-engine - ${junit.vintage.version} + ${junit-jupiter.version} test @@ -83,13 +83,11 @@ 1.5.0 - 5.5.0 2.12.0 1.11.4 42.2.6 3.141.59 2.22.2 - 1.3.2 \ No newline at end of file diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml index 82a507a985..d5c5981b33 100644 --- a/testing-modules/testing-assertions/pom.xml +++ b/testing-modules/testing-assertions/pom.xml @@ -53,7 +53,6 @@ 3.16.1 4.4 - 5.6.2 \ No newline at end of file diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml index dcbddd60b4..82e4bbfdf0 100644 --- a/testing-modules/testing-libraries-2/pom.xml +++ b/testing-modules/testing-libraries-2/pom.xml @@ -12,6 +12,17 @@ ../ + + + + junit + junit + ${junit.version} + test + + + + org.projectlombok @@ -53,25 +64,25 @@ org.junit.jupiter junit-jupiter - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-engine - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-params - ${junit.jupiter.version} + ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-api - ${junit.jupiter.version} + ${junit-jupiter.version} test @@ -128,7 +139,6 @@ 1.19.0 1.0.0 1.1.0 - 5.6.2 3.16.1 diff --git a/testing-modules/testing-libraries/pom.xml b/testing-modules/testing-libraries/pom.xml index 4bbe56fc18..f9443fa792 100644 --- a/testing-modules/testing-libraries/pom.xml +++ b/testing-modules/testing-libraries/pom.xml @@ -12,6 +12,17 @@ 1.0.0-SNAPSHOT + + + + junit + junit + ${junit.version} + test + + + + com.insightfullogic diff --git a/xml/pom.xml b/xml/pom.xml index b4c78b514d..6bae312452 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -367,7 +367,6 @@ 1.0-2 3.12.2 2.6.3 - 5.5.0 2.3.29 0.9.6 From c06df0225cff88ca3902c74f0c37b10602952567 Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Sat, 30 Oct 2021 01:18:37 +0200 Subject: [PATCH 087/551] BAEL-4546: sample app to show-case docker compose with the latest image --- docker/docker-sample-app/Dockerfile | 3 + docker/docker-sample-app/README.md | 3 + .../docker-compose-build-image.yaml | 8 + .../docker-compose-with-image.yaml | 9 + docker/docker-sample-app/mvnw | 310 ++++++++++++++++++ docker/docker-sample-app/mvnw.cmd | 182 ++++++++++ docker/docker-sample-app/pom.xml | 45 +++ .../personal/dockapp/DockAppApplication.java | 13 + .../dockapp/endpoint/MyController.java | 13 + .../src/main/resources/application.properties | 1 + .../dockapp/DockAppApplicationUnitTest.java | 13 + docker/pom.xml | 1 + 12 files changed, 601 insertions(+) create mode 100644 docker/docker-sample-app/Dockerfile create mode 100644 docker/docker-sample-app/README.md create mode 100644 docker/docker-sample-app/docker-compose-build-image.yaml create mode 100644 docker/docker-sample-app/docker-compose-with-image.yaml create mode 100755 docker/docker-sample-app/mvnw create mode 100644 docker/docker-sample-app/mvnw.cmd create mode 100644 docker/docker-sample-app/pom.xml create mode 100644 docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java create mode 100644 docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java create mode 100644 docker/docker-sample-app/src/main/resources/application.properties create mode 100644 docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java diff --git a/docker/docker-sample-app/Dockerfile b/docker/docker-sample-app/Dockerfile new file mode 100644 index 0000000000..71fc1a29d9 --- /dev/null +++ b/docker/docker-sample-app/Dockerfile @@ -0,0 +1,3 @@ +FROM openjdk:11 +COPY target/docker-sample-app-0.0.1.jar app.jar +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/docker/docker-sample-app/README.md b/docker/docker-sample-app/README.md new file mode 100644 index 0000000000..6aeaa1d2a3 --- /dev/null +++ b/docker/docker-sample-app/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- How to Get Docker-Compose to Always Use the Latest Image diff --git a/docker/docker-sample-app/docker-compose-build-image.yaml b/docker/docker-sample-app/docker-compose-build-image.yaml new file mode 100644 index 0000000000..27c1d8ee44 --- /dev/null +++ b/docker/docker-sample-app/docker-compose-build-image.yaml @@ -0,0 +1,8 @@ +version: '2.4' +services: + db: + image: postgres + my_app: + build: . + ports: + - "8080:8080" diff --git a/docker/docker-sample-app/docker-compose-with-image.yaml b/docker/docker-sample-app/docker-compose-with-image.yaml new file mode 100644 index 0000000000..9a8822f762 --- /dev/null +++ b/docker/docker-sample-app/docker-compose-with-image.yaml @@ -0,0 +1,9 @@ +version: '2.4' +services: + db: + image: postgres + my_app: + image: "eugen/test-app:latest" + ports: + - "8080:8080" + diff --git a/docker/docker-sample-app/mvnw b/docker/docker-sample-app/mvnw new file mode 100755 index 0000000000..a16b5431b4 --- /dev/null +++ b/docker/docker-sample-app/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/docker/docker-sample-app/mvnw.cmd b/docker/docker-sample-app/mvnw.cmd new file mode 100644 index 0000000000..c8d43372c9 --- /dev/null +++ b/docker/docker-sample-app/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/docker/docker-sample-app/pom.xml b/docker/docker-sample-app/pom.xml new file mode 100644 index 0000000000..416ec45b10 --- /dev/null +++ b/docker/docker-sample-app/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + com.baeldung.docker + docker + 0.0.1 + + + docker-sample-app + docker-sample-app + Demo project for Spring Boot and Docker + + + 11 + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java b/docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java new file mode 100644 index 0000000000..b0f031d25a --- /dev/null +++ b/docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java @@ -0,0 +1,13 @@ +package com.personal.dockapp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DockAppApplication { + + public static void main(String[] args) { + SpringApplication.run(DockAppApplication.class, args); + } + +} diff --git a/docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java b/docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java new file mode 100644 index 0000000000..bf2886f19d --- /dev/null +++ b/docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java @@ -0,0 +1,13 @@ +package com.personal.dockapp.endpoint; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class MyController { + + @GetMapping + public String version() { + return "1.7"; + } +} diff --git a/docker/docker-sample-app/src/main/resources/application.properties b/docker/docker-sample-app/src/main/resources/application.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/docker/docker-sample-app/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java b/docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java new file mode 100644 index 0000000000..2f8abafe70 --- /dev/null +++ b/docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java @@ -0,0 +1,13 @@ +package com.personal.dockapp; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DockAppApplicationUnitTest { + + @Test + void contextLoads() { + } + +} diff --git a/docker/pom.xml b/docker/pom.xml index 3fcc9ca94f..0a397dd966 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -25,6 +25,7 @@ docker-internal-dto docker-spring-boot + docker-sample-app From 1e9e55daf9adc04fd8f9d959da452017603742fb Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Sat, 30 Oct 2021 01:39:48 +0200 Subject: [PATCH 088/551] BAEL-4546: formatting changes --- .../docker/app}/DockAppApplication.java | 8 ++++---- .../docker/app}/endpoint/MyController.java | 2 +- .../docker/app}/DockAppApplicationUnitTest.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) rename docker/docker-sample-app/src/main/java/com/{personal/dockapp => baeldung/docker/app}/DockAppApplication.java (55%) rename docker/docker-sample-app/src/main/java/com/{personal/dockapp => baeldung/docker/app}/endpoint/MyController.java (85%) rename docker/docker-sample-app/src/test/java/com/{personal/dockapp => baeldung/docker/app}/DockAppApplicationUnitTest.java (67%) diff --git a/docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java b/docker/docker-sample-app/src/main/java/com/baeldung/docker/app/DockAppApplication.java similarity index 55% rename from docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java rename to docker/docker-sample-app/src/main/java/com/baeldung/docker/app/DockAppApplication.java index b0f031d25a..e7ff52015c 100644 --- a/docker/docker-sample-app/src/main/java/com/personal/dockapp/DockAppApplication.java +++ b/docker/docker-sample-app/src/main/java/com/baeldung/docker/app/DockAppApplication.java @@ -1,4 +1,4 @@ -package com.personal.dockapp; +package com.baeldung.docker.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DockAppApplication { - public static void main(String[] args) { - SpringApplication.run(DockAppApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(DockAppApplication.class, args); + } } diff --git a/docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java b/docker/docker-sample-app/src/main/java/com/baeldung/docker/app/endpoint/MyController.java similarity index 85% rename from docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java rename to docker/docker-sample-app/src/main/java/com/baeldung/docker/app/endpoint/MyController.java index bf2886f19d..d46c57e606 100644 --- a/docker/docker-sample-app/src/main/java/com/personal/dockapp/endpoint/MyController.java +++ b/docker/docker-sample-app/src/main/java/com/baeldung/docker/app/endpoint/MyController.java @@ -1,4 +1,4 @@ -package com.personal.dockapp.endpoint; +package com.baeldung.docker.app.endpoint; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java b/docker/docker-sample-app/src/test/java/com/baeldung/docker/app/DockAppApplicationUnitTest.java similarity index 67% rename from docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java rename to docker/docker-sample-app/src/test/java/com/baeldung/docker/app/DockAppApplicationUnitTest.java index 2f8abafe70..7220766988 100644 --- a/docker/docker-sample-app/src/test/java/com/personal/dockapp/DockAppApplicationUnitTest.java +++ b/docker/docker-sample-app/src/test/java/com/baeldung/docker/app/DockAppApplicationUnitTest.java @@ -1,4 +1,4 @@ -package com.personal.dockapp; +package com.baeldung.docker.app; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @@ -6,8 +6,8 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class DockAppApplicationUnitTest { - @Test - void contextLoads() { - } + @Test + void contextLoads() { + } } From e29cfda933ba0ecbc16d969dba0bb53b9ccd8683 Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Sat, 30 Oct 2021 02:01:47 +0200 Subject: [PATCH 089/551] BAEL-4546: Reverting evaluation article code --- .../hexagonal/HexagonalSpringApplication.java | 20 ---- .../adapter/BookingPersistenceAdapter.java | 22 ---- .../adapter/RestAPIEndpointAdapter.java | 32 ----- .../adapter/TheatreServiceAdapter.java | 30 ----- .../adapter/WalletServiceAdapter.java | 19 --- .../baeldung/hexagonal/domain/Booking.java | 87 -------------- .../service/CustomerWalletService.java | 8 -- .../service/MockCustomerWalletService.java | 11 -- .../external/service/MockTheatreService.java | 21 ---- .../external/service/TheatreService.java | 24 ---- .../port/BookingPersistencePort.java | 8 -- .../hexagonal/port/BookingServicePort.java | 73 ------------ .../hexagonal/port/TheatreServicePort.java | 9 -- .../hexagonal/port/WalletServicePort.java | 5 - .../repository/BookingRepository.java | 9 -- .../repository/MockBookingRepository.java | 16 --- .../hexagonal/usecase/BookTicketUseCase.java | 57 --------- .../RestAPIEndpointAdapterUnitTest.java | 87 -------------- .../usecase/BookTicketUseCaseUnitTest.java | 110 ------------------ 19 files changed, 648 deletions(-) delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java delete mode 100644 ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java delete mode 100644 ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java delete mode 100644 ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java diff --git a/ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java b/ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java deleted file mode 100644 index c679d459f0..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/HexagonalSpringApplication.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.hexagonal; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; -import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; -import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; - - -@SpringBootApplication(exclude={ - CassandraAutoConfiguration.class, - MongoDataAutoConfiguration.class, - MongoAutoConfiguration.class -}) -public class HexagonalSpringApplication { - - public static void main(final String[] args) { - SpringApplication.run(HexagonalSpringApplication.class, args); - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java deleted file mode 100644 index 1b191bde86..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/BookingPersistenceAdapter.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.hexagonal.adapter; - -import com.baeldung.hexagonal.domain.Booking; -import com.baeldung.hexagonal.port.BookingPersistencePort; -import com.baeldung.hexagonal.repository.BookingRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class BookingPersistenceAdapter implements BookingPersistencePort { - - @Autowired - private BookingRepository bookingRepository; - - public boolean persist(Booking booking) { - return bookingRepository.save(booking); - } - - public boolean updateStatus(String bookingId, String status) { - return bookingRepository.updateStatus(bookingId, status); - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java deleted file mode 100644 index 3e1b1fc90f..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapter.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.hexagonal.adapter; - -import com.baeldung.hexagonal.port.BookingServicePort; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import static com.baeldung.hexagonal.port.BookingServicePort.BookingRequest; -import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse; -import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.SUCCESS; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.FAILED_DEPENDENCY; - -@RestController -public class RestAPIEndpointAdapter { - - private BookingServicePort bookingServicePort; - - @Autowired - public RestAPIEndpointAdapter(BookingServicePort bookingServicePort) { - this.bookingServicePort = bookingServicePort; - } - - @PostMapping(path = "/booking") - public ResponseEntity createBooking(@RequestBody BookingRequest request) { - BookingResponse response = bookingServicePort.book(request); - return new ResponseEntity<>(response, - response.getStatusCode() == SUCCESS ? CREATED : FAILED_DEPENDENCY); - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java deleted file mode 100644 index fa19483b13..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/TheatreServiceAdapter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.hexagonal.adapter; - -import com.baeldung.hexagonal.external.service.TheatreService; -import com.baeldung.hexagonal.port.TheatreServicePort; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; - -import java.util.Optional; -import java.util.Set; - -import static com.baeldung.hexagonal.external.service.TheatreService.Reservation; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.NO_CONTENT; - -@Component -public class TheatreServiceAdapter implements TheatreServicePort { - - @Autowired - private TheatreService theatreService; - - public Optional reserveSeats(String movieShowId, Set seats) { - ResponseEntity response = theatreService.postReservation(movieShowId, seats); - return response.getStatusCode() == CREATED ? Optional.of(response.getBody().getId()): Optional.empty(); - } - - public boolean releaseSeats(String resrevationId) { - return theatreService.deleteReservation(resrevationId).getStatusCode() == NO_CONTENT; - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java b/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java deleted file mode 100644 index 1d8db867b7..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/adapter/WalletServiceAdapter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.hexagonal.adapter; - -import com.baeldung.hexagonal.external.service.CustomerWalletService; -import com.baeldung.hexagonal.port.WalletServicePort; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import static org.springframework.http.HttpStatus.CREATED; - -@Component -public class WalletServiceAdapter implements WalletServicePort { - - @Autowired - private CustomerWalletService customerWalletService; - - public boolean debit(String customerId, Double amount) { - return customerWalletService.postDebit(customerId, amount) == CREATED; - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java b/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java deleted file mode 100644 index ed9b7281f2..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/domain/Booking.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.baeldung.hexagonal.domain; - -import com.baeldung.hexagonal.port.BookingServicePort; - -import java.util.Set; -import java.util.UUID; - -public class Booking { - - public static final String STATUS_INITIAL = "INITIAL"; - public static final String STATUS_SUCCESS = "SUCCESS"; - public static final String STATUS_FAILURE = "FAILED"; - - private String bookingId; - private String movieShowId; - private String customerId; - private Set seats; - private Double amount; - private String status; - - public Booking( - String bookingId, String movieShowId, String customerId, Set seats, Double amount, String status) { - this.bookingId = bookingId; - this.movieShowId = movieShowId; - this.customerId = customerId; - this.seats = seats; - this.amount = amount; - this.status = status; - } - - public Booking(BookingServicePort.BookingRequest request) { - this.bookingId = UUID.randomUUID().toString(); - this.movieShowId = request.getMovieShowId(); - this.customerId = request.getCustomerId(); - this.seats = request.getSeats(); - this.amount = request.getAmount(); - this.status = STATUS_INITIAL; - } - - public String getMovieShowId() { - return movieShowId; - } - - public Set getSeats() { - return seats; - } - - public String getCustomerId() { - return customerId; - } - - public String getBookingId() { - return bookingId; - } - - public Double getAmount() { - return amount; - } - - public String getStatus() { - return status; - } - - public void setBookingId(String bookingId) { - this.bookingId = bookingId; - } - - public void setMovieShowId(String movieShowId) { - this.movieShowId = movieShowId; - } - - public void setCustomerId(String customerId) { - this.customerId = customerId; - } - - public void setSeats(Set seats) { - this.seats = seats; - } - - public void setAmount(Double amount) { - this.amount = amount; - } - - public void setStatus(String status) { - this.status = status; - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java deleted file mode 100644 index 102cef788e..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/external/service/CustomerWalletService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.hexagonal.external.service; - -import org.springframework.http.HttpStatus; - -public interface CustomerWalletService { - - HttpStatus postDebit(String customerId, Double amount); -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java deleted file mode 100644 index 4a76368b19..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockCustomerWalletService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.hexagonal.external.service; - -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; - -@Service -public class MockCustomerWalletService implements CustomerWalletService { - public HttpStatus postDebit(String customerId, Double amount) { - return HttpStatus.CREATED; - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java deleted file mode 100644 index eb018e69b2..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/external/service/MockTheatreService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal.external.service; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; - -import java.util.Set; -import java.util.UUID; - -@Service -public class MockTheatreService implements TheatreService { - - public ResponseEntity postReservation(String movieShowId, Set seats) { - return new ResponseEntity<>( - new Reservation(UUID.randomUUID().toString()), HttpStatus.CREATED); - } - - public ResponseEntity deleteReservation(String reservationId) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java b/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java deleted file mode 100644 index 8107bfb418..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/external/service/TheatreService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.hexagonal.external.service; - -import org.springframework.http.ResponseEntity; - -import java.util.Set; - -public interface TheatreService { - - ResponseEntity postReservation(String movieShowId, Set seats); - - ResponseEntity deleteReservation(String reservationId); - - class Reservation { - private final String id; - - public Reservation(String id) { - this.id = id; - } - - public String getId() { - return id; - } - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java deleted file mode 100644 index c1d1d73630..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingPersistencePort.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.hexagonal.port; - -import com.baeldung.hexagonal.domain.Booking; - -public interface BookingPersistencePort { - boolean persist(Booking booking); - public boolean updateStatus(String bookingId, String status); -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java deleted file mode 100644 index 12710a6014..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/BookingServicePort.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.baeldung.hexagonal.port; - -import java.util.Set; - -public interface BookingServicePort { - - BookingResponse book(BookingRequest request); - - class BookingRequest { - private String movieShowId; - private String customerId; - private Set seats; - private Double amount; - - public String getMovieShowId() { - return movieShowId; - } - - public void setMovieShowId(String movieShowId) { - this.movieShowId = movieShowId; - } - - public String getCustomerId() { - return customerId; - } - - public void setCustomerId(String customerId) { - this.customerId = customerId; - } - - public Set getSeats() { - return seats; - } - - public void setSeats(Set seats) { - this.seats = seats; - } - - public Double getAmount() { - return amount; - } - - public void setAmount(Double amount) { - this.amount = amount; - } - } - - class BookingResponse { - public static final int SUCCESS = 0; - public static final int SEAT_NOT_AVAILABLE = 1; - public static final int PAYMENT_FAILED = 2; - public static final int UNKNOWN_ERROR = 3; - - private final int statusCode; - private String bookingId; - - public BookingResponse(String bookingId, int statusCode) { - this.bookingId = bookingId; - this.statusCode = statusCode; - } - - public BookingResponse(int statusCode) { - this.statusCode = statusCode; - } - - public int getStatusCode() { - return statusCode; - } - public String getBookingId() { - return bookingId; - } - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java deleted file mode 100644 index 8e5fab8b46..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/TheatreServicePort.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.hexagonal.port; - -import java.util.Optional; -import java.util.Set; - -public interface TheatreServicePort { - Optional reserveSeats(String movieShowId, Set seats); - boolean releaseSeats(String resrevationId); -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java b/ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java deleted file mode 100644 index 102bb619e8..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/port/WalletServicePort.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.hexagonal.port; - -public interface WalletServicePort { - boolean debit(String customerId, Double amount); -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java b/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java deleted file mode 100644 index 7dd20290ba..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/repository/BookingRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.hexagonal.repository; - -import com.baeldung.hexagonal.domain.Booking; - -public interface BookingRepository { - - boolean save(Booking booking); - boolean updateStatus(String bookingId, String status); -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java b/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java deleted file mode 100644 index 1738e606d0..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/repository/MockBookingRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.hexagonal.repository; - -import com.baeldung.hexagonal.domain.Booking; -import org.springframework.stereotype.Repository; - -@Repository -public class MockBookingRepository implements BookingRepository { - public boolean save(Booking booking) { - return true; - } - - @Override - public boolean updateStatus(String bookingId, String status) { - return true; - } -} diff --git a/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java b/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java deleted file mode 100644 index 8d3112bd37..0000000000 --- a/ddd/src/main/java/com/baeldung/hexagonal/usecase/BookTicketUseCase.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.baeldung.hexagonal.usecase; - -import com.baeldung.hexagonal.domain.Booking; -import com.baeldung.hexagonal.port.BookingPersistencePort; -import com.baeldung.hexagonal.port.BookingServicePort; -import com.baeldung.hexagonal.port.TheatreServicePort; -import com.baeldung.hexagonal.port.WalletServicePort; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Optional; - -import static com.baeldung.hexagonal.domain.Booking.STATUS_FAILURE; -import static com.baeldung.hexagonal.domain.Booking.STATUS_SUCCESS; -import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; - -@Component -public class BookTicketUseCase implements BookingServicePort { - - private BookingPersistencePort bookingPersistencePort; - private TheatreServicePort theatreServicePort; - private WalletServicePort walletServicePort; - - @Autowired - public BookTicketUseCase(BookingPersistencePort bookingPersistencePort, TheatreServicePort theatreServicePort, WalletServicePort walletServicePort) { - this.bookingPersistencePort = bookingPersistencePort; - this.theatreServicePort = theatreServicePort; - this.walletServicePort = walletServicePort; - } - - public BookingResponse book(BookingRequest request) { - - Booking booking = new Booking(request); - - if (!bookingPersistencePort.persist(booking)) { - return new BookingResponse(UNKNOWN_ERROR); - } - - String bookingId = booking.getBookingId(); - - Optional reservationIdOptional = theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats()); - if (!reservationIdOptional.isPresent()) { - bookingPersistencePort.updateStatus(bookingId, STATUS_FAILURE); - return new BookingResponse(bookingId, SEAT_NOT_AVAILABLE); - } - - if (!walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) { - reservationIdOptional.ifPresent(reservationId -> theatreServicePort.releaseSeats(reservationId)); - bookingPersistencePort.updateStatus(bookingId, STATUS_FAILURE); - return new BookingResponse(bookingId, PAYMENT_FAILED); - } - - bookingPersistencePort.updateStatus(bookingId, STATUS_SUCCESS); - - return new BookingResponse(bookingId, SUCCESS); - } -} diff --git a/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java b/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java deleted file mode 100644 index cb22f5f37a..0000000000 --- a/ddd/src/test/java/com/baeldung/hexagonal/adapter/RestAPIEndpointAdapterUnitTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.baeldung.hexagonal.adapter; - -import com.baeldung.hexagonal.port.BookingServicePort; -import com.baeldung.hexagonal.port.BookingServicePort.BookingRequest; -import com.baeldung.hexagonal.port.BookingServicePort.BookingResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import java.util.Arrays; -import java.util.HashSet; - -import static com.baeldung.hexagonal.port.BookingServicePort.BookingResponse.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; - -class RestAPIEndpointAdapterUnitTest { - - private BookingServicePort bookingServicePort; - private RestAPIEndpointAdapter restAPIEndpointAdapter; - - @BeforeEach - void setUp() { - bookingServicePort = mock(BookingServicePort.class); - restAPIEndpointAdapter = new RestAPIEndpointAdapter(bookingServicePort); - } - - private BookingServicePort.BookingRequest getBookingRequest() { - BookingServicePort.BookingRequest request = new BookingServicePort.BookingRequest(); - request.setMovieShowId("movie-show-id"); - request.setCustomerId("customer-id"); - request.setSeats(new HashSet<>(Arrays.asList("A1", "A2"))); - request.setAmount(100.00); - return request; - } - - @Test - void whenBookingServicePortReturnsUnknownError_thenReturnInternalServerError() { - BookingServicePort.BookingRequest request = getBookingRequest(); - when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(UNKNOWN_ERROR)); - - ResponseEntity response = restAPIEndpointAdapter.createBooking(request); - - verify(bookingServicePort).book(any(BookingRequest.class)); - assertNotNull(response); - assertEquals(HttpStatus.FAILED_DEPENDENCY, response.getStatusCode()); - } - - @Test - void whenBookingServicePortReturnsSeatUnavailable_thenReturnPreconditionFailed() { - BookingServicePort.BookingRequest request = getBookingRequest(); - when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(SEAT_NOT_AVAILABLE)); - - ResponseEntity response = restAPIEndpointAdapter.createBooking(request); - - verify(bookingServicePort).book(any(BookingRequest.class)); - assertNotNull(response); - assertEquals(HttpStatus.FAILED_DEPENDENCY, response.getStatusCode()); - } - - @Test - void whenBookingServicePortReturnsPaymentFailed_thenReturnPreconditionFailed() { - BookingServicePort.BookingRequest request = getBookingRequest(); - when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(PAYMENT_FAILED)); - - ResponseEntity response = restAPIEndpointAdapter.createBooking(request); - - verify(bookingServicePort).book(any(BookingRequest.class)); - assertNotNull(response); - assertEquals(HttpStatus.FAILED_DEPENDENCY, response.getStatusCode()); - } - - @Test - void whenBookingServicePortReturnsSuccess_thenReturnCreated() { - BookingServicePort.BookingRequest request = getBookingRequest(); - when(bookingServicePort.book(any(BookingRequest.class))).thenReturn(new BookingResponse(SUCCESS)); - - ResponseEntity response = restAPIEndpointAdapter.createBooking(request); - - verify(bookingServicePort).book(any(BookingRequest.class)); - assertNotNull(response); - assertEquals(HttpStatus.CREATED, response.getStatusCode()); - } -} \ No newline at end of file diff --git a/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java b/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java deleted file mode 100644 index ffb4246f79..0000000000 --- a/ddd/src/test/java/com/baeldung/hexagonal/usecase/BookTicketUseCaseUnitTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.baeldung.hexagonal.usecase; - -import com.baeldung.hexagonal.domain.Booking; -import com.baeldung.hexagonal.port.BookingPersistencePort; -import com.baeldung.hexagonal.port.BookingServicePort; -import com.baeldung.hexagonal.port.TheatreServicePort; -import com.baeldung.hexagonal.port.WalletServicePort; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; - -class BookTicketUseCaseUnitTest { - - private BookingPersistencePort bookingPersistencePort; - private TheatreServicePort theatreServicePort; - private WalletServicePort walletServicePort; - private BookTicketUseCase bookTicketUseCase; - - @BeforeEach - void setUp() { - bookingPersistencePort = mock(BookingPersistencePort.class); - theatreServicePort = mock(TheatreServicePort.class); - walletServicePort = mock(WalletServicePort.class); - bookTicketUseCase = new BookTicketUseCase(bookingPersistencePort, theatreServicePort, walletServicePort); - } - - private BookingServicePort.BookingRequest getBookingRequest() { - BookingServicePort.BookingRequest request = new BookingServicePort.BookingRequest(); - request.setMovieShowId("movie-show-id"); - request.setCustomerId("customer-id"); - request.setSeats(new HashSet<>(Arrays.asList("A1", "A2"))); - request.setAmount(100.00); - return request; - } - - @Test - void whenErrorInInitialPersistence_thenReturnUnknownError() { - BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = new Booking(request); - when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(false); - BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - - verify(bookingPersistencePort, times(1)).persist(any(Booking.class)); - assertNotNull(response); - assertEquals(BookingServicePort.BookingResponse.UNKNOWN_ERROR, response.getStatusCode()); - } - - @Test - void whenErrorInReserveSeats_thenReturnSeatNotAvailable() { - BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = new Booking(request); - when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); - when(theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats())) - .thenReturn(Optional.empty()); - BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - - verify(bookingPersistencePort).persist(any(Booking.class)); - verify(bookingPersistencePort).updateStatus(any(String.class), any(String.class)); - verify(theatreServicePort).reserveSeats(any(String.class), any(HashSet.class)); - assertNotNull(response); - assertEquals(BookingServicePort.BookingResponse.SEAT_NOT_AVAILABLE, response.getStatusCode()); - } - - @Test - void whenErrorInWalletDebit_thenReturnPaymentFailed() { - BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = new Booking(request); - when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); - when(theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats())) - .thenReturn(Optional.of("reservation-id")); - when(walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) - .thenReturn(false); - BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - - verify(bookingPersistencePort).persist(any(Booking.class)); - verify(bookingPersistencePort).updateStatus(any(String.class), any(String.class)); - verify(theatreServicePort).reserveSeats(any(String.class), any(HashSet.class)); - verify(walletServicePort).debit(any(String.class), any(Double.class)); - verify(theatreServicePort).releaseSeats(any(String.class)); - assertNotNull(response); - assertEquals(BookingServicePort.BookingResponse.PAYMENT_FAILED, response.getStatusCode()); - } - - @Test - void whenNoErrorInAnyPorts_thenReturnSuccess() { - BookingServicePort.BookingRequest request = getBookingRequest(); - Booking booking = new Booking(request); - when(bookingPersistencePort.persist(any(Booking.class))).thenReturn(true); - when(theatreServicePort.reserveSeats(booking.getMovieShowId(), booking.getSeats())) - .thenReturn(Optional.of("reservation-id")); - when(walletServicePort.debit(booking.getCustomerId(), booking.getAmount())) - .thenReturn(true); - BookingServicePort.BookingResponse response = bookTicketUseCase.book(request); - - verify(bookingPersistencePort).persist(any(Booking.class)); - verify(bookingPersistencePort).updateStatus(any(String.class), any(String.class)); - verify(theatreServicePort).reserveSeats( any(String.class), any(HashSet.class)); - verify(walletServicePort).debit(any(String.class), any(Double.class)); - assertNotNull(response); - assertEquals(BookingServicePort.BookingResponse.SUCCESS, response.getStatusCode()); - } -} \ No newline at end of file From d17c2be71248df936601748f40b508724c16a423 Mon Sep 17 00:00:00 2001 From: Teica Date: Sat, 30 Oct 2021 16:37:54 +0200 Subject: [PATCH 090/551] BAEL-5195 split string by multiple delimiters (#11356) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BAEL-5195 split string by multiple delimiters * Delete baeldun * added assertions of the content Co-authored-by: Matea Pejčinović --- .../core-java-string-operations-3/pom.xml | 6 ++ .../MultipleDelimitersSplitUnitTest.java | 66 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java diff --git a/core-java-modules/core-java-string-operations-3/pom.xml b/core-java-modules/core-java-string-operations-3/pom.xml index 642ade5ab3..20e9bcb39a 100644 --- a/core-java-modules/core-java-string-operations-3/pom.xml +++ b/core-java-modules/core-java-string-operations-3/pom.xml @@ -52,6 +52,11 @@ semver4j ${semver4j.version} + + com.google.guava + guava + ${guava.version} + @@ -80,6 +85,7 @@ 3.6.1 5.3.9 3.12.0 + 31.0.1-jre 3.6.3 6.1.1 2.11.1 diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java new file mode 100644 index 0000000000..c8f8fc2d98 --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java @@ -0,0 +1,66 @@ +package com.baeldung.multipledelimiterssplit; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterators; +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +import java.util.Arrays; +import java.util.regex.Pattern; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class MultipleDelimitersSplitUnitTest { + + @Test + public void givenString_whenSplittingByMultipleDelimitersWithRegEx_thenStringSplit() { + String example = "Mary;Thomas:Jane-Kate"; + String[] names = example.split(";|:|-"); + String[] expectedNames = new String[]{"Mary", "Thomas", "Jane", "Kate"}; + Assertions.assertEquals(4, names.length); + Assertions.assertArrayEquals(expectedNames, names); + } + + @Test + public void givenString_whenSplittingByWithCharMatcherAndOnMethod_thenStringSplit() { + String example = "Mary;Thomas:Jane-Kate"; + String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"}; + Iterable expected = Arrays.asList(expectedArray); + Iterable names = Splitter.on(CharMatcher.anyOf(";:-")).split(example); + Assertions.assertEquals(4, Iterators.size(names.iterator())); + Assertions.assertIterableEquals(expected, names); + } + + @Test + public void givenString_whenSplittingByWithRegexAndOnPatternMethod_thenStringSplit() { + String example = "Mary;Thomas:Jane-Kate"; + String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"}; + Iterable expected = Arrays.asList(expectedArray); + Iterable names = Splitter.on(Pattern.compile(";|:|-")).split(example); + Assertions.assertEquals(4, Iterators.size(names.iterator())); + Assertions.assertIterableEquals(expected, names); + } + + @Test + public void givenString_whenSplittingByMultipleDelimitersWithGuava_thenStringSplit() { + String example = "Mary;Thomas:Jane-Kate"; + String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"}; + Iterable expected = Arrays.asList(expectedArray); + Iterable names = Splitter.onPattern(";|:|-").split(example); + Assertions.assertEquals(4, Iterators.size(names.iterator())); + Assertions.assertIterableEquals(expected, names); + } + + @Test + public void givenString_whenSplittingByMultipleDelimitersWithApache_thenStringSplit() { + String example = "Mary;Thomas:Jane-Kate"; + String[] expectedNames = new String[]{"Mary", "Thomas", "Jane", "Kate"}; + String[] names = StringUtils.split(example, ";:-"); + Assertions.assertEquals(4, names.length); + Assertions.assertArrayEquals(expectedNames, names); + } + +} + From bd6dee5376a91b36803e1b797f86ac72fb49bc9d Mon Sep 17 00:00:00 2001 From: sharifi Date: Mon, 1 Nov 2021 11:01:44 +0330 Subject: [PATCH 091/551] bael-4604: add main class --- .../main/java/com/baeldung/hmac/HMACUtil.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 core-java-modules/core-java-security-3/src/main/java/com/baeldung/hmac/HMACUtil.java diff --git a/core-java-modules/core-java-security-3/src/main/java/com/baeldung/hmac/HMACUtil.java b/core-java-modules/core-java-security-3/src/main/java/com/baeldung/hmac/HMACUtil.java new file mode 100644 index 0000000000..3b504d9338 --- /dev/null +++ b/core-java-modules/core-java-security-3/src/main/java/com/baeldung/hmac/HMACUtil.java @@ -0,0 +1,68 @@ +package com.baeldung.hmac; + +import org.apache.commons.codec.digest.HmacUtils; +import org.bouncycastle.crypto.Digest; +import org.bouncycastle.crypto.digests.MD5Digest; +import org.bouncycastle.crypto.digests.SHA256Digest; +import org.bouncycastle.crypto.digests.SHA384Digest; +import org.bouncycastle.crypto.digests.SHA512Digest; +import org.bouncycastle.crypto.macs.HMac; +import org.bouncycastle.crypto.params.KeyParameter; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + + +public class HMACUtil { + + public static String hmacWithJava(String algorithm, String data, String key) + throws NoSuchAlgorithmException, InvalidKeyException { + SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), algorithm); + Mac mac = Mac.getInstance(algorithm); + mac.init(secretKeySpec); + return bytesToHex(mac.doFinal(data.getBytes())); + } + + public static String hmacWithApacheCommons(String algorithm, String data, String key) { + String hmac = new HmacUtils(algorithm, key).hmacHex(data); + return hmac; + } + + public static String hmacWithBouncyCastle(String algorithm, String data, String key) { + Digest digest = getHashDigest(algorithm); + HMac hMac = new HMac(digest); + hMac.init(new KeyParameter(key.getBytes())); + byte[] hmacIn = data.getBytes(); + hMac.update(hmacIn, 0, hmacIn.length); + byte[] hmacOut = new byte[hMac.getMacSize()]; + hMac.doFinal(hmacOut, 0); + return bytesToHex(hmacOut); + } + + private static Digest getHashDigest(String algorithm) { + switch (algorithm) { + case "HmacMD5": + return new MD5Digest(); + case "HmacSHA256": + return new SHA256Digest(); + case "HmacSHA384": + return new SHA384Digest(); + case "HmacSHA512": + return new SHA512Digest(); + } + return new SHA256Digest(); + } + + public static String bytesToHex(byte[] hash) { + StringBuilder hexString = new StringBuilder(2 * hash.length); + for (byte h : hash) { + String hex = Integer.toHexString(0xff & h); + if (hex.length() == 1) + hexString.append('0'); + hexString.append(hex); + } + return hexString.toString(); + } +} From 28845d038e0f7187a9a6ed4d6c410c9ed02edf1a Mon Sep 17 00:00:00 2001 From: sharifi Date: Mon, 1 Nov 2021 11:01:53 +0330 Subject: [PATCH 092/551] bael-4604: add test class --- .../com/baeldung/hmac/HMACUtilUnitTest.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java diff --git a/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java new file mode 100644 index 0000000000..86e81f5895 --- /dev/null +++ b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.hmac; + +import org.junit.Test; + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import static org.junit.Assert.assertEquals; + +public class HMACUtilUnitTest { + + private static String hmacSHA256Value = "5b50d80c7dc7ae8bb1b1433cc0b99ecd2ac8397a555c6f75cb8a619ae35a0c35"; + private static String hmacMD5Value = "621dc816b3bf670212e0c261dc9bcdb6"; + private static String hmacSHA512Value = "b313a21908df55c9e322e3c65a4b0b7561ab1594ca806b3affbc0d769a1290c1922aa6622587bea3c0c4d871470a6d06f54dbd20dbda84250e2741eb01f08e33"; + + //given + String hmacSHA256Algorithm = "HmacSHA256"; + String hmacSHA512Algorithm = "HmacSHA512"; + String hmacMD5Algorithm = "HmacMD5"; + String data = "baeldung"; + String key = "123456"; + + @Test + public void givenDataAndKeyAndAlgorithm_whenHmacWithJava_thenSuccess() + throws NoSuchAlgorithmException, InvalidKeyException { + //when + String result = HMACUtil.hmacWithJava(hmacSHA256Algorithm, data, key); + + //then + assertEquals(hmacSHA256Value, result); + } + + @Test + public void givenDataAndKeyAndAlgorithm_whenHmacWithApacheCommons_thenSuccess() { + //when + String result = HMACUtil.hmacWithApacheCommons(hmacMD5Algorithm, data, key); + + //then + assertEquals(hmacMD5Value, result); + } + + @Test + public void givenDataAndKeyAndAlgorithm_whenHmacWithBouncyCastle_thenSuccess() { + //when + String result = HMACUtil.hmacWithBouncyCastle(hmacSHA512Algorithm, data, key); + + //then + assertEquals(hmacSHA512Value, result); + } +} From 9bbd34d45f0fbc52c9e73531d95eefde7aaf422e Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Sat, 30 Oct 2021 19:55:18 +0530 Subject: [PATCH 093/551] JAVA-1664: upgrading parent-boot-2 junit and surefire configurations --- jhipster-5/bookstore-monolith/pom.xml | 2 +- libraries-security/pom.xml | 5 ---- patterns/clean-architecture/pom.xml | 13 --------- persistence-modules/spring-data-redis/pom.xml | 5 ---- persistence-modules/spring-jooq/pom.xml | 1 - spring-boot-modules/pom.xml | 15 ---------- .../spring-boot-environment/pom.xml | 11 -------- .../spring-boot-flowable/pom.xml | 5 ---- .../spring-boot-testing/pom.xml | 11 -------- spring-boot-modules/spring-boot/pom.xml | 11 -------- .../spring-cloud-config/client/pom.xml | 11 -------- .../spring-cloud-config/server/pom.xml | 11 -------- .../docker-message-server/pom.xml | 11 -------- .../docker-product-server/pom.xml | 11 -------- .../spring-cloud-ribbon-retry/pom.xml | 1 - spring-web-modules/spring-rest-simple/pom.xml | 5 ---- .../spring-resttemplate/pom.xml | 5 ---- testing-modules/spring-testing-2/pom.xml | 1 - testing-modules/spring-testing/pom.xml | 28 ------------------- 19 files changed, 1 insertion(+), 162 deletions(-) diff --git a/jhipster-5/bookstore-monolith/pom.xml b/jhipster-5/bookstore-monolith/pom.xml index 8403c2d1d4..411de0e712 100644 --- a/jhipster-5/bookstore-monolith/pom.xml +++ b/jhipster-5/bookstore-monolith/pom.xml @@ -1136,7 +1136,7 @@ 3.0.0-M2 2.2.1 3.1.0 - 2.22.1 + 2.22.2 3.2.2 0.9.11 1.6 diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index 001ecc54a0..6d3bbcd26c 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -48,11 +48,6 @@ bcpkix-jdk15on ${bouncycastle.version} - - org.junit.vintage - junit-vintage-engine - test - org.passay passay diff --git a/patterns/clean-architecture/pom.xml b/patterns/clean-architecture/pom.xml index c36f9b83af..4a1f512240 100644 --- a/patterns/clean-architecture/pom.xml +++ b/patterns/clean-architecture/pom.xml @@ -29,11 +29,6 @@ org.springframework.boot spring-boot-starter-data-jpa - - org.junit.jupiter - junit-jupiter-engine - test - org.springframework.boot spring-boot-starter-test @@ -54,14 +49,6 @@ org.junit.platform junit-platform-engine - - org.junit.jupiter - junit-jupiter-engine - - - org.junit.jupiter - junit-jupiter-api - org.junit.platform junit-platform-runner diff --git a/persistence-modules/spring-data-redis/pom.xml b/persistence-modules/spring-data-redis/pom.xml index 5e17f27c06..330f0d975a 100644 --- a/persistence-modules/spring-data-redis/pom.xml +++ b/persistence-modules/spring-data-redis/pom.xml @@ -42,10 +42,6 @@ spring-boot-starter-test test - - org.junit.jupiter - junit-jupiter-api - org.junit.platform junit-platform-runner @@ -78,7 +74,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} true false diff --git a/persistence-modules/spring-jooq/pom.xml b/persistence-modules/spring-jooq/pom.xml index 4c195a6c92..c842922fe5 100644 --- a/persistence-modules/spring-jooq/pom.xml +++ b/persistence-modules/spring-jooq/pom.xml @@ -76,7 +76,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} 0 diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 9f179dd97f..1b2f6ffa06 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -95,19 +95,4 @@ - - - org.junit.jupiter - junit-jupiter - - - org.junit.vintage - junit-vintage-engine - - - - - 2.22.2 - - \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index d4b260ee3d..9c852986a1 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -30,17 +30,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - org.springframework.boot spring-boot-starter-data-jpa diff --git a/spring-boot-modules/spring-boot-flowable/pom.xml b/spring-boot-modules/spring-boot-flowable/pom.xml index 320a684880..7d89c665cd 100644 --- a/spring-boot-modules/spring-boot-flowable/pom.xml +++ b/spring-boot-modules/spring-boot-flowable/pom.xml @@ -40,11 +40,6 @@ spring-boot-starter-test test - - org.junit.jupiter - junit-jupiter-engine - test - diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index f70e77b31a..a846227290 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -49,17 +49,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - it.ozimov diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index 8df16a1f9c..026c48c148 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -54,17 +54,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - io.dropwizard.metrics metrics-core diff --git a/spring-cloud/spring-cloud-config/client/pom.xml b/spring-cloud/spring-cloud-config/client/pom.xml index 55c6e77a72..0f463b6d6d 100644 --- a/spring-cloud/spring-cloud-config/client/pom.xml +++ b/spring-cloud/spring-cloud-config/client/pom.xml @@ -26,17 +26,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - diff --git a/spring-cloud/spring-cloud-config/server/pom.xml b/spring-cloud/spring-cloud-config/server/pom.xml index 36d1b5b3aa..b41277113f 100644 --- a/spring-cloud/spring-cloud-config/server/pom.xml +++ b/spring-cloud/spring-cloud-config/server/pom.xml @@ -30,17 +30,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - diff --git a/spring-cloud/spring-cloud-docker/docker-message-server/pom.xml b/spring-cloud/spring-cloud-docker/docker-message-server/pom.xml index 1c8c58c762..91cd587ff3 100644 --- a/spring-cloud/spring-cloud-docker/docker-message-server/pom.xml +++ b/spring-cloud/spring-cloud-docker/docker-message-server/pom.xml @@ -23,17 +23,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - diff --git a/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml b/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml index be65a6d7d3..9645dd3dff 100644 --- a/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml +++ b/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml @@ -23,17 +23,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - diff --git a/spring-cloud/spring-cloud-ribbon-retry/pom.xml b/spring-cloud/spring-cloud-ribbon-retry/pom.xml index e0075b4f41..02fc103533 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/pom.xml +++ b/spring-cloud/spring-cloud-ribbon-retry/pom.xml @@ -45,7 +45,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} 0 diff --git a/spring-web-modules/spring-rest-simple/pom.xml b/spring-web-modules/spring-rest-simple/pom.xml index 46bfa5d04c..69d88d6456 100644 --- a/spring-web-modules/spring-rest-simple/pom.xml +++ b/spring-web-modules/spring-rest-simple/pom.xml @@ -120,11 +120,6 @@ ${com.squareup.okhttp3.version} - - org.junit.vintage - junit-vintage-engine - test - org.hamcrest hamcrest diff --git a/spring-web-modules/spring-resttemplate/pom.xml b/spring-web-modules/spring-resttemplate/pom.xml index 1379e40d23..3066a82242 100644 --- a/spring-web-modules/spring-resttemplate/pom.xml +++ b/spring-web-modules/spring-resttemplate/pom.xml @@ -108,11 +108,6 @@ ${com.squareup.okhttp3.version} - - - org.junit.vintage - junit-vintage-engine - org.hamcrest hamcrest diff --git a/testing-modules/spring-testing-2/pom.xml b/testing-modules/spring-testing-2/pom.xml index 419b8d512a..f3e4f098b4 100644 --- a/testing-modules/spring-testing-2/pom.xml +++ b/testing-modules/spring-testing-2/pom.xml @@ -55,7 +55,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} methods true diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index e687f8d6fd..ff5265eab8 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -36,17 +36,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - org.springframework spring-core @@ -71,23 +60,6 @@ org.springframework.data spring-data-jpa - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - org.junit.platform junit-platform-commons From 1f6c74ecabdac1ccdd1032b6df115cce8e158f5d Mon Sep 17 00:00:00 2001 From: Azhwani Date: Tue, 2 Nov 2021 20:25:06 +0100 Subject: [PATCH 094/551] conflits resolution --- testing-modules/junit-5/pom.xml | 3 ++ .../order/AlphanumericOrderUnitTest.java | 14 ++++---- .../junit5/order/DefaultOrderUnitTest.java | 36 +++++++++++++++++++ .../junit5/order/RandomOrderUnitTest.java | 35 ++++++++++++++++++ .../test/resources/junit-platform.properties | 2 ++ 5 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/DefaultOrderUnitTest.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/RandomOrderUnitTest.java create mode 100644 testing-modules/junit-5/src/test/resources/junit-platform.properties diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index 148abecb0f..9b2518d10b 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -137,7 +137,10 @@ + 5.8.1 2.23.0 + 1.8.1 + 5.8.1 2.8.2 2.0.0 2.22.0 diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/AlphanumericOrderUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/AlphanumericOrderUnitTest.java index d62ca0c666..873df30400 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/AlphanumericOrderUnitTest.java +++ b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/AlphanumericOrderUnitTest.java @@ -3,29 +3,29 @@ package com.baeldung.junit5.order; import static org.junit.Assert.assertEquals; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.MethodOrderer.Alphanumeric; +import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -@TestMethodOrder(Alphanumeric.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class AlphanumericOrderUnitTest { private static StringBuilder output = new StringBuilder(""); - + @Test public void myATest() { output.append("A"); } - + @Test public void myBTest() { - output.append("B"); + output.append("B"); } - + @Test public void myaTest() { output.append("a"); } - + @AfterAll public static void assertOutput() { assertEquals(output.toString(), "ABa"); diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/DefaultOrderUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/DefaultOrderUnitTest.java new file mode 100644 index 0000000000..65cee3e987 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/DefaultOrderUnitTest.java @@ -0,0 +1,36 @@ +package com.baeldung.junit5.order; + +import static org.junit.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class DefaultOrderUnitTest { + + private static StringBuilder output = new StringBuilder(""); + + @Test + @DisplayName("Test A") + public void myATest() { + output.append("A"); + } + + @Test + @DisplayName("Test B") + public void myBTest() { + output.append("B"); + } + + @Test + @DisplayName("Test C") + public void myCTest() { + output.append("C"); + } + + @AfterAll + public static void assertOutput() { + assertEquals(output.toString(), "ABC"); + } + +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/RandomOrderUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/RandomOrderUnitTest.java new file mode 100644 index 0000000000..0f64f5bb31 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/order/RandomOrderUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.junit5.order; + +import static org.junit.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +@TestMethodOrder(MethodOrderer.Random.class) +public class RandomOrderUnitTest { + + private static StringBuilder output = new StringBuilder(""); + + @Test + public void myATest() { + output.append("A"); + } + + @Test + public void myBTest() { + output.append("B"); + } + + @Test + public void myCTest() { + output.append("C"); + } + + @AfterAll + public static void assertOutput() { + assertEquals(output.toString(), "ACB"); + } + +} diff --git a/testing-modules/junit-5/src/test/resources/junit-platform.properties b/testing-modules/junit-5/src/test/resources/junit-platform.properties new file mode 100644 index 0000000000..d25e866b43 --- /dev/null +++ b/testing-modules/junit-5/src/test/resources/junit-platform.properties @@ -0,0 +1,2 @@ +junit.jupiter.execution.order.random.seed=100 +junit.jupiter.testmethod.order.default = org.junit.jupiter.api.MethodOrderer$DisplayName \ No newline at end of file From 54e7d312dc04a291a07a4b0e6847105e904157ee Mon Sep 17 00:00:00 2001 From: Azhwani Date: Tue, 2 Nov 2021 19:58:44 +0100 Subject: [PATCH 095/551] init commit --- .../junit-5/src/test/resources/junit-platform.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/junit-5/src/test/resources/junit-platform.properties b/testing-modules/junit-5/src/test/resources/junit-platform.properties index d25e866b43..a02be290e0 100644 --- a/testing-modules/junit-5/src/test/resources/junit-platform.properties +++ b/testing-modules/junit-5/src/test/resources/junit-platform.properties @@ -1,2 +1,2 @@ junit.jupiter.execution.order.random.seed=100 -junit.jupiter.testmethod.order.default = org.junit.jupiter.api.MethodOrderer$DisplayName \ No newline at end of file +junit.jupiter.testmethod.order.default = org.junit.jupiter.api.MethodOrderer$DisplayName From 000ae20d5dcbc1786510439ea3b36afc00589544 Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Sun, 3 Oct 2021 22:11:58 +0200 Subject: [PATCH 096/551] BAEL-5134: an example of constructor chaining, added unit tests --- .../constructorchaining/Customer.java | 34 +++++++++++++ .../baeldung/constructorchaining/Person.java | 51 +++++++++++++++++++ .../constructorchaining/CustomerUnitTest.java | 31 +++++++++++ .../constructorchaining/PersonUnitTest.java | 29 +++++++++++ 4 files changed, 145 insertions(+) create mode 100644 core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Customer.java create mode 100644 core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Person.java create mode 100644 core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/CustomerUnitTest.java create mode 100644 core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/PersonUnitTest.java diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Customer.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Customer.java new file mode 100644 index 0000000000..62dbdef297 --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Customer.java @@ -0,0 +1,34 @@ +package com.baeldung.constructorchaining; + +import java.util.Objects; + +public class Customer extends Person { + private final String loyaltyCardId; + + public Customer(String firstName, String lastName, int age, String loyaltyCardId) { + this(firstName, null, lastName, age, loyaltyCardId); + } + + public Customer(String firstName, String middleName, String lastName, int age, String loyaltyCardId) { + super(firstName, middleName, lastName, age); + this.loyaltyCardId = loyaltyCardId; + } + + public String getLoyaltyCardId() { + return loyaltyCardId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Customer customer = (Customer) o; + return Objects.equals(loyaltyCardId, customer.loyaltyCardId); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), loyaltyCardId); + } +} diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Person.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Person.java new file mode 100644 index 0000000000..02ce2220ba --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/constructorchaining/Person.java @@ -0,0 +1,51 @@ +package com.baeldung.constructorchaining; + +import java.util.Objects; + +public class Person { + private final String firstName; + private final String middleName; + private final String lastName; + private final int age; + + public Person(String firstName, String lastName, int age) { + this(firstName, null, lastName, age); + } + + + public Person(String firstName, String middleName, String lastName, int age) { + this.firstName = firstName; + this.middleName = middleName; + this.lastName = lastName; + this.age = age; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public int getAge() { + return age; + } + + public String getMiddleName() { + return middleName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Person person = (Person) o; + return age == person.age && Objects.equals(firstName, person.firstName) && Objects.equals(middleName, person.middleName) && Objects.equals(lastName, person.lastName); + } + + @Override + public int hashCode() { + return Objects.hash(firstName, middleName, lastName, age); + } +} diff --git a/core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/CustomerUnitTest.java b/core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/CustomerUnitTest.java new file mode 100644 index 0000000000..ad00ea65b8 --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/CustomerUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.constructorchaining; + +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +public class CustomerUnitTest { + + @Test + public void givenNameLastNameAndAge_whenUsingDedicatedConstructor_shouldInitializeFieldsAndNullifyMiddleName() { + Customer mark = new Customer("Mark", "Johnson", 23, "abcd1234"); + + assertEquals(23, mark.getAge()); + assertEquals("Mark", mark.getFirstName()); + assertEquals("Johnson", mark.getLastName()); + assertEquals("abcd1234", mark.getLoyaltyCardId()); + assertNull(mark.getMiddleName()); + } + + @Test + public void givenAllFieldsRequired_whenUsingDedicatedConstructor_shouldInitializeAllFields() { + Customer mark = new Customer("Mark", "Andrew", "Johnson", 23, "abcd1234"); + + assertEquals(23, mark.getAge()); + assertEquals("Mark", mark.getFirstName()); + assertEquals("Andrew", mark.getMiddleName()); + assertEquals("Johnson", mark.getLastName()); + assertEquals("abcd1234", mark.getLoyaltyCardId()); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/PersonUnitTest.java b/core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/PersonUnitTest.java new file mode 100644 index 0000000000..8322917951 --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/test/java/com/baeldung/constructorchaining/PersonUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.constructorchaining; + +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +public class PersonUnitTest { + + @Test + public void givenNameLastNameAndAge_whenUsingDedicatedConstructor_shouldInitializeFieldsAndNullifyMiddleName() { + Person mark = new Person("Mark", "Johnson", 23); + + assertEquals(23, mark.getAge()); + assertEquals("Mark", mark.getFirstName()); + assertEquals("Johnson", mark.getLastName()); + assertNull(mark.getMiddleName()); + } + + @Test + public void givenAllFieldsRequired_whenUsingDedicatedConstructor_shouldInitializeAllFields() { + Person mark = new Person("Mark", "Andrew", "Johnson", 23); + + assertEquals(23, mark.getAge()); + assertEquals("Mark", mark.getFirstName()); + assertEquals("Andrew", mark.getMiddleName()); + assertEquals("Johnson", mark.getLastName()); + } +} \ No newline at end of file From 64a134f05e2ceec645a0e1cdf2cf061f6fbf552e Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Tue, 2 Nov 2021 17:27:04 +0530 Subject: [PATCH 097/551] JAVA-1665: updated parent-java's junit and surefire configurations --- core-java-modules/core-java-11-2/pom.xml | 18 ------------------ core-java-modules/core-java-14/pom.xml | 12 ------------ core-java-modules/core-java-15/pom.xml | 12 ------------ core-java-modules/core-java-16/pom.xml | 12 ------------ core-java-modules/core-java-17/pom.xml | 12 ------------ .../core-java-concurrency-2/pom.xml | 11 ++++++----- core-java-modules/core-java-jndi/pom.xml | 17 ----------------- core-java-modules/core-java-jvm-2/pom.xml | 5 ----- core-java-modules/core-java-jvm/pom.xml | 5 ----- .../core-java-networking-3/pom.xml | 5 ----- core-java-modules/core-java-os/pom.xml | 6 ------ core-java-modules/core-java-streams-2/pom.xml | 5 ----- .../core-java-string-algorithms-3/pom.xml | 5 ----- .../core-java-string-conversions-2/pom.xml | 5 ----- .../core-java-time-measurements/pom.xml | 4 +--- core-java-modules/pom.xml | 4 ---- guava-modules/guava-collections-list/pom.xml | 12 ------------ guava-modules/guava-collections-map/pom.xml | 15 --------------- guava-modules/guava-collections-set/pom.xml | 12 ------------ guava-modules/guava-collections/pom.xml | 12 ------------ guava-modules/guava-io/pom.xml | 15 --------------- guava-modules/guava-utilities/pom.xml | 12 ------------ guava-modules/pom.xml | 13 ------------- jackson-modules/pom.xml | 12 ------------ jackson-simple/pom.xml | 12 ------------ java-collections-conversions-2/pom.xml | 6 ------ parent-java/pom.xml | 17 +++++++++++++++-- .../math-test-functions/pom.xml | 14 -------------- .../string-test-functions/pom.xml | 14 -------------- testing-modules/testing-assertions/pom.xml | 12 ------------ 30 files changed, 22 insertions(+), 294 deletions(-) diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 68e8b66d67..3ab8e883b0 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -32,24 +32,6 @@ mockserver-junit-jupiter ${mockserver.version} - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - org.apache.commons commons-lang3 diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index a03332d8bc..de01d17b0d 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -22,18 +22,6 @@ ${assertj.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/core-java-modules/core-java-15/pom.xml b/core-java-modules/core-java-15/pom.xml index 091f0568a7..a71987c23a 100644 --- a/core-java-modules/core-java-15/pom.xml +++ b/core-java-modules/core-java-15/pom.xml @@ -27,18 +27,6 @@ ${assertj.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/core-java-modules/core-java-16/pom.xml b/core-java-modules/core-java-16/pom.xml index 5d10325f03..790b7dd057 100644 --- a/core-java-modules/core-java-16/pom.xml +++ b/core-java-modules/core-java-16/pom.xml @@ -28,18 +28,6 @@ commons-lang3 3.12.0 - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml index f9a7ec326b..f1f4edc484 100644 --- a/core-java-modules/core-java-17/pom.xml +++ b/core-java-modules/core-java-17/pom.xml @@ -23,18 +23,6 @@ ${assertj.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/core-java-modules/core-java-concurrency-2/pom.xml b/core-java-modules/core-java-concurrency-2/pom.xml index b8a1d641d4..c61f28a6b3 100644 --- a/core-java-modules/core-java-concurrency-2/pom.xml +++ b/core-java-modules/core-java-concurrency-2/pom.xml @@ -15,11 +15,6 @@ - - org.junit.vintage - junit-vintage-engine - test - com.googlecode.thread-weaver threadweaver @@ -31,6 +26,12 @@ tempus-fugit ${tempus-fugit.version} test + + + junit + junit + + com.googlecode.multithreadedtc diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index f1b374b2b5..1728c0b5d9 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -15,23 +15,6 @@ - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - org.springframework spring-core diff --git a/core-java-modules/core-java-jvm-2/pom.xml b/core-java-modules/core-java-jvm-2/pom.xml index 173cf27955..08c8de75a9 100644 --- a/core-java-modules/core-java-jvm-2/pom.xml +++ b/core-java-modules/core-java-jvm-2/pom.xml @@ -15,11 +15,6 @@ - - org.junit.vintage - junit-vintage-engine - test - org.assertj assertj-core diff --git a/core-java-modules/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml index afbe0b0ee3..a8ab4d9f2e 100644 --- a/core-java-modules/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -16,11 +16,6 @@ - - org.junit.vintage - junit-vintage-engine - test - org.apache.commons commons-lang3 diff --git a/core-java-modules/core-java-networking-3/pom.xml b/core-java-modules/core-java-networking-3/pom.xml index 4a05af8b25..1579418b54 100644 --- a/core-java-modules/core-java-networking-3/pom.xml +++ b/core-java-modules/core-java-networking-3/pom.xml @@ -35,11 +35,6 @@ ${assertj.version} test - - org.junit.vintage - junit-vintage-engine - test - com.sun.mail javax.mail diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index b279e3d6cb..34afbec210 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -16,12 +16,6 @@ - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - org.apache.commons commons-collections4 diff --git a/core-java-modules/core-java-streams-2/pom.xml b/core-java-modules/core-java-streams-2/pom.xml index 087a8378b1..08b82bcc11 100644 --- a/core-java-modules/core-java-streams-2/pom.xml +++ b/core-java-modules/core-java-streams-2/pom.xml @@ -30,11 +30,6 @@ log4j ${log4j.version} - - org.junit.vintage - junit-vintage-engine - test - org.assertj assertj-core diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 6376bfa677..4287696332 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -26,11 +26,6 @@ guava ${guava.version} - - org.junit.jupiter - junit-jupiter - test - commons-validator commons-validator diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index ff4955726b..68be7d2c08 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -20,11 +20,6 @@ guava ${guava.version} - - org.junit.vintage - junit-vintage-engine - test - org.hamcrest hamcrest diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index 663cf6708b..5a2a13290b 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -75,8 +75,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar @@ -97,8 +97,6 @@ 1.8.9 2.0.7 1.44 - - 2.22.1 \ No newline at end of file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 9f184310e9..872161c2bd 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -134,8 +134,4 @@ - - 2.22.2 - - diff --git a/guava-modules/guava-collections-list/pom.xml b/guava-modules/guava-collections-list/pom.xml index e57198ec40..671cbea39d 100644 --- a/guava-modules/guava-collections-list/pom.xml +++ b/guava-modules/guava-collections-list/pom.xml @@ -27,18 +27,6 @@ ${commons-lang3.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core diff --git a/guava-modules/guava-collections-map/pom.xml b/guava-modules/guava-collections-map/pom.xml index 7f3e470fc3..e4d33ce0cc 100644 --- a/guava-modules/guava-collections-map/pom.xml +++ b/guava-modules/guava-collections-map/pom.xml @@ -15,21 +15,6 @@ ../ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - guava-collections-map diff --git a/guava-modules/guava-collections-set/pom.xml b/guava-modules/guava-collections-set/pom.xml index 09e3f42e83..97e03155e7 100644 --- a/guava-modules/guava-collections-set/pom.xml +++ b/guava-modules/guava-collections-set/pom.xml @@ -16,18 +16,6 @@ - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core diff --git a/guava-modules/guava-collections/pom.xml b/guava-modules/guava-collections/pom.xml index 6dc7510a1e..f3356cf982 100644 --- a/guava-modules/guava-collections/pom.xml +++ b/guava-modules/guava-collections/pom.xml @@ -32,18 +32,6 @@ ${jool.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core diff --git a/guava-modules/guava-io/pom.xml b/guava-modules/guava-io/pom.xml index 11a5d4ada6..f1f75b43a8 100644 --- a/guava-modules/guava-io/pom.xml +++ b/guava-modules/guava-io/pom.xml @@ -14,21 +14,6 @@ ../ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - guava-io diff --git a/guava-modules/guava-utilities/pom.xml b/guava-modules/guava-utilities/pom.xml index 6049a62e85..b33ea16c11 100644 --- a/guava-modules/guava-utilities/pom.xml +++ b/guava-modules/guava-utilities/pom.xml @@ -21,18 +21,6 @@ ${commons-lang3.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core diff --git a/guava-modules/pom.xml b/guava-modules/pom.xml index cbfb47fa0f..019776ad3d 100644 --- a/guava-modules/pom.xml +++ b/guava-modules/pom.xml @@ -34,22 +34,9 @@ guava ${guava.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - 2.22.2 29.0-jre diff --git a/jackson-modules/pom.xml b/jackson-modules/pom.xml index 1bb684af0a..14e34a41bf 100644 --- a/jackson-modules/pom.xml +++ b/jackson-modules/pom.xml @@ -35,18 +35,6 @@ jackson-dataformat-xml ${jackson.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - \ No newline at end of file diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index 72e31ee5e3..ae8e380b33 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -22,18 +22,6 @@ ${jackson.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index 55dc6e30b6..cd4366e87c 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -32,12 +32,6 @@ modelmapper ${modelmapper.version} - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.hamcrest hamcrest diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 103b5f179c..ae6eeb40a9 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -1,7 +1,7 @@ + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 parent-java 0.0.1-SNAPSHOT @@ -40,10 +40,23 @@ + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + 31.0.1-jre 2.3.7 2.2 + 2.22.2 \ No newline at end of file diff --git a/testing-modules/parallel-tests-junit/math-test-functions/pom.xml b/testing-modules/parallel-tests-junit/math-test-functions/pom.xml index eae1bf61e7..7ead2051e2 100644 --- a/testing-modules/parallel-tests-junit/math-test-functions/pom.xml +++ b/testing-modules/parallel-tests-junit/math-test-functions/pom.xml @@ -13,21 +13,11 @@ 0.0.1-SNAPSHOT - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} all 10 @@ -45,8 +35,4 @@ - - 2.22.0 - - \ No newline at end of file diff --git a/testing-modules/parallel-tests-junit/string-test-functions/pom.xml b/testing-modules/parallel-tests-junit/string-test-functions/pom.xml index c838558fc2..86b4078eb3 100644 --- a/testing-modules/parallel-tests-junit/string-test-functions/pom.xml +++ b/testing-modules/parallel-tests-junit/string-test-functions/pom.xml @@ -13,21 +13,11 @@ 0.0.1-SNAPSHOT - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} all true @@ -37,8 +27,4 @@ - - 2.22.0 - - \ No newline at end of file diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml index d5c5981b33..f9cd35c5e5 100644 --- a/testing-modules/testing-assertions/pom.xml +++ b/testing-modules/testing-assertions/pom.xml @@ -18,18 +18,6 @@ logback-classic ${logback.version} - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - org.assertj assertj-core From 1adb96e3846ae28d78a80c9be7da2f0e139f08cc Mon Sep 17 00:00:00 2001 From: vunamtien Date: Wed, 3 Nov 2021 16:22:59 +0700 Subject: [PATCH 098/551] BAEL-5193-Deserialize Snake Case With Jackson (#11341) * BAEL-5193-deserialize-snake-case * refactor * refactor Co-authored-by: tienvn4 --- .../com/baeldung/jackson/snakecase/User.java | 22 ++++++++++ .../snakecase/UserWithPropertyNames.java | 26 +++++++++++ .../snakecase/UserWithSnakeStrategy.java | 26 +++++++++++ .../jackson/snakecase/SnakeCaseUnitTest.java | 44 +++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/User.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithPropertyNames.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithSnakeStrategy.java create mode 100644 jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/snakecase/SnakeCaseUnitTest.java diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/User.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/User.java new file mode 100644 index 0000000000..17bf6f898b --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/User.java @@ -0,0 +1,22 @@ +package com.baeldung.jackson.snakecase; + +public class User { + private String firstName; + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithPropertyNames.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithPropertyNames.java new file mode 100644 index 0000000000..f9f36243ad --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithPropertyNames.java @@ -0,0 +1,26 @@ +package com.baeldung.jackson.snakecase; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class UserWithPropertyNames { + @JsonProperty("first_name") + private String firstName; + @JsonProperty("last_name") + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithSnakeStrategy.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithSnakeStrategy.java new file mode 100644 index 0000000000..ffec940ed8 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/snakecase/UserWithSnakeStrategy.java @@ -0,0 +1,26 @@ +package com.baeldung.jackson.snakecase; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class UserWithSnakeStrategy { + private String firstName; + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/snakecase/SnakeCaseUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/snakecase/SnakeCaseUnitTest.java new file mode 100644 index 0000000000..c72908ccce --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/snakecase/SnakeCaseUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.jackson.snakecase; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class SnakeCaseUnitTest { + + private static final String JSON = "{\"first_name\": \"Jackie\", \"last_name\": \"Chan\"}"; + + @Test(expected = UnrecognizedPropertyException.class) + public void whenExceptionThrown_thenExpectationSatisfied() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.readValue(JSON, User.class); + } + + @Test + public void givenSnakeCaseJson_whenParseWithJsonPropertyAnnotation_thenGetExpectedObject() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + UserWithPropertyNames user = objectMapper.readValue(JSON, UserWithPropertyNames.class); + assertEquals("Jackie", user.getFirstName()); + assertEquals("Chan", user.getLastName()); + } + + @Test + public void givenSnakeCaseJson_whenParseWithJsonNamingAnnotation_thenGetExpectedObject() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + UserWithSnakeStrategy user = objectMapper.readValue(JSON, UserWithSnakeStrategy.class); + assertEquals("Jackie", user.getFirstName()); + assertEquals("Chan", user.getLastName()); + } + + @Test + public void givenSnakeCaseJson_whenParseWithCustomMapper_thenGetExpectedObject() throws Exception { + ObjectMapper objectMapper = new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); + User user = objectMapper.readValue(JSON, User.class); + assertEquals("Jackie", user.getFirstName()); + assertEquals("Chan", user.getLastName()); + } + +} From d716de4a4f81c0669c0743d6a6c7ba3d4144e463 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Wed, 3 Nov 2021 16:11:27 +0530 Subject: [PATCH 099/551] JAVA-1668: updating parent-spring-5's junit and surefire configurations --- ethereum/pom.xml | 12 ------------ parent-spring-5/pom.xml | 19 +++++++++++++------ spring-core-3/pom.xml | 12 ------------ spring-core-4/pom.xml | 12 ------------ 4 files changed, 13 insertions(+), 42 deletions(-) diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 7fc4057341..95dd1c0955 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -144,18 +144,6 @@ test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - org.hamcrest - hamcrest-core - - - org.hamcrest hamcrest diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index c4446ddda8..01e8671099 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -21,18 +21,25 @@ spring-core ${spring.version} - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + 5.3.9 5.2.3.RELEASE 1.5.10.RELEASE + 2.22.2 \ No newline at end of file diff --git a/spring-core-3/pom.xml b/spring-core-3/pom.xml index 50d2e7ac5e..9e777a4a03 100644 --- a/spring-core-3/pom.xml +++ b/spring-core-3/pom.xml @@ -55,18 +55,6 @@ ${spring.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/spring-core-4/pom.xml b/spring-core-4/pom.xml index 5706b2ee75..f9665a672b 100644 --- a/spring-core-4/pom.xml +++ b/spring-core-4/pom.xml @@ -55,18 +55,6 @@ ${spring.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - org.awaitility awaitility From a2abf42fc331348df8bcf40220c1432810b55adb Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Wed, 3 Nov 2021 19:40:46 +0530 Subject: [PATCH 100/551] JAVA-1667: updating parent-spring-4's junit and surefire configurations --- parent-spring-4/pom.xml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/parent-spring-4/pom.xml b/parent-spring-4/pom.xml index e0e91cec9a..630fa0baf3 100644 --- a/parent-spring-4/pom.xml +++ b/parent-spring-4/pom.xml @@ -21,15 +21,18 @@ spring-core ${spring.version} - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.codehaus.cargo @@ -54,6 +57,7 @@ 4.3.27.RELEASE 1.6.1 + 2.22.2 \ No newline at end of file From 86a01f519f69858fd1e7f210e13806f81c3f9fd1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:21:34 +0800 Subject: [PATCH 101/551] Create README.md --- persistence-modules/apache-derby/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 persistence-modules/apache-derby/README.md diff --git a/persistence-modules/apache-derby/README.md b/persistence-modules/apache-derby/README.md new file mode 100644 index 0000000000..502115da5e --- /dev/null +++ b/persistence-modules/apache-derby/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Getting Started With Apache Derby](https://www.baeldung.com/java-apache-derby) From e4f75b51a21f0f882c0695c3702c29b45265dfd7 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:41:51 +0800 Subject: [PATCH 102/551] Update README.md --- apache-poi/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apache-poi/README.md b/apache-poi/README.md index d500787536..d19af8d6ef 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -12,3 +12,4 @@ This module contains articles about Apache POI - [Read Excel Cell Value Rather Than Formula With Apache POI](https://www.baeldung.com/apache-poi-read-cell-value-formula) - [Setting Formulas in Excel with Apache POI](https://www.baeldung.com/java-apache-poi-set-formulas) - [Insert a Row in Excel Using Apache POI](https://www.baeldung.com/apache-poi-insert-excel-row) +- [Multiline Text in Excel Cell Using Apache POI](https://www.baeldung.com/apache-poi-write-multiline-text) From ab8356c1e3f7fe4b9ea3d9604e05e1dd51adb1a9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:43:30 +0800 Subject: [PATCH 103/551] Update README.md --- core-java-modules/core-java-jndi/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-jndi/README.md b/core-java-modules/core-java-jndi/README.md index d9fb324c9a..b0b23fc0d0 100644 --- a/core-java-modules/core-java-jndi/README.md +++ b/core-java-modules/core-java-jndi/README.md @@ -2,3 +2,4 @@ ### Relevant Articles: - [Java Naming and Directory Interface Overview](https://www.baeldung.com/jndi) +- [LDAP Authentication Using Pure Java](https://www.baeldung.com/java-ldap-auth) From c369f22d2a5ed07fb327079c4d81174cd9045d10 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:45:13 +0800 Subject: [PATCH 104/551] Update README.md --- core-java-modules/core-java-string-operations-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-3/README.md b/core-java-modules/core-java-string-operations-3/README.md index 1a131c57ac..f4c8f42f0b 100644 --- a/core-java-modules/core-java-string-operations-3/README.md +++ b/core-java-modules/core-java-string-operations-3/README.md @@ -7,3 +7,4 @@ - [Validate String as Filename in Java](https://www.baeldung.com/java-validate-filename) - [Count Spaces in a Java String](https://www.baeldung.com/java-string-count-spaces) - [Remove Accents and Diacritics From a String in Java](https://www.baeldung.com/java-remove-accents-from-text) +- [Remove Beginning and Ending Double Quotes from a String](https://www.baeldung.com/java-remove-start-end-double-quote) From c1232efeba82812f8550a5c75c15ace605d21737 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:47:30 +0800 Subject: [PATCH 105/551] Update README.md --- core-java-modules/core-java-string-operations-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-3/README.md b/core-java-modules/core-java-string-operations-3/README.md index f4c8f42f0b..dc42862e5d 100644 --- a/core-java-modules/core-java-string-operations-3/README.md +++ b/core-java-modules/core-java-string-operations-3/README.md @@ -8,3 +8,4 @@ - [Count Spaces in a Java String](https://www.baeldung.com/java-string-count-spaces) - [Remove Accents and Diacritics From a String in Java](https://www.baeldung.com/java-remove-accents-from-text) - [Remove Beginning and Ending Double Quotes from a String](https://www.baeldung.com/java-remove-start-end-double-quote) +- [Splitting a Java String by Multiple Delimiters](https://www.baeldung.com/java-string-split-multiple-delimiters) From abaaf21c1f04285da818ab3c5e74eb0dcb5f7b83 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:50:18 +0800 Subject: [PATCH 106/551] Update README.md --- spring-boot-modules/spring-boot-keycloak/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-keycloak/README.md b/spring-boot-modules/spring-boot-keycloak/README.md index 2aff4664a6..7a1323d10e 100644 --- a/spring-boot-modules/spring-boot-keycloak/README.md +++ b/spring-boot-modules/spring-boot-keycloak/README.md @@ -8,4 +8,4 @@ This module contains articles about Keycloak in Spring Boot projects. - [Customizing the Login Page for Keycloak](https://www.baeldung.com/keycloak-custom-login-page) - [Keycloak User Self-Registration](https://www.baeldung.com/keycloak-user-registration) - [Customizing Themes for Keycloak](https://www.baeldung.com/spring-keycloak-custom-themes) - +- [Securing SOAP Web Services With Keycloak](https://www.baeldung.com/soap-keycloak) From 01a1849a27bc80b1e01651f525da052200ae5ed8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:52:00 +0800 Subject: [PATCH 107/551] Update README.md --- jackson-modules/jackson-conversions-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson-modules/jackson-conversions-2/README.md b/jackson-modules/jackson-conversions-2/README.md index 9986fe75b5..bddbb60bd7 100644 --- a/jackson-modules/jackson-conversions-2/README.md +++ b/jackson-modules/jackson-conversions-2/README.md @@ -10,4 +10,5 @@ This module contains articles about Jackson conversions. - [How to Process YAML with Jackson](https://www.baeldung.com/jackson-yaml) - [Jackson Streaming API](https://www.baeldung.com/jackson-streaming-api) - [Jackson: java.util.LinkedHashMap cannot be cast to X](https://www.baeldung.com/jackson-linkedhashmap-cannot-be-cast) +- [Deserialize Snake Case to Camel Case With Jackson](https://www.baeldung.com/jackson-deserialize-snake-to-camel-case) - More articles: [[<-- prev]](../jackson-conversions) From d01252575450f481f42b7797fbbac865519cfe0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matea=20Pej=C4=8Dinovi=C4=87?= Date: Wed, 3 Nov 2021 21:07:13 +0100 Subject: [PATCH 108/551] Modified the regex pattern --- .../MultipleDelimitersSplitUnitTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java index c8f8fc2d98..2da8955645 100644 --- a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/multipledelimiterssplit/MultipleDelimitersSplitUnitTest.java @@ -17,7 +17,7 @@ public class MultipleDelimitersSplitUnitTest { @Test public void givenString_whenSplittingByMultipleDelimitersWithRegEx_thenStringSplit() { String example = "Mary;Thomas:Jane-Kate"; - String[] names = example.split(";|:|-"); + String[] names = example.split("[;:-]"); String[] expectedNames = new String[]{"Mary", "Thomas", "Jane", "Kate"}; Assertions.assertEquals(4, names.length); Assertions.assertArrayEquals(expectedNames, names); @@ -38,7 +38,7 @@ public class MultipleDelimitersSplitUnitTest { String example = "Mary;Thomas:Jane-Kate"; String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"}; Iterable expected = Arrays.asList(expectedArray); - Iterable names = Splitter.on(Pattern.compile(";|:|-")).split(example); + Iterable names = Splitter.on(Pattern.compile("[;:-]")).split(example); Assertions.assertEquals(4, Iterators.size(names.iterator())); Assertions.assertIterableEquals(expected, names); } @@ -48,7 +48,7 @@ public class MultipleDelimitersSplitUnitTest { String example = "Mary;Thomas:Jane-Kate"; String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"}; Iterable expected = Arrays.asList(expectedArray); - Iterable names = Splitter.onPattern(";|:|-").split(example); + Iterable names = Splitter.onPattern("[;:-]").split(example); Assertions.assertEquals(4, Iterators.size(names.iterator())); Assertions.assertIterableEquals(expected, names); } From d800af95b83ad9414d74827dde311b15729230e9 Mon Sep 17 00:00:00 2001 From: gjohnson Date: Wed, 3 Nov 2021 23:05:01 +0000 Subject: [PATCH 109/551] For 3rd PR (POM fixed) - [BAEL-4451] LDAP Authentication using Pure Java --- core-java-modules/core-java-jndi/pom.xml | 13 ++ .../ldap/auth/JndiLdapAuthManualTest.java | 165 ++++++++++++++++++ .../src/test/resources/logback.xml | 13 ++ .../src/test/resources/users.ldif | 20 +++ 4 files changed, 211 insertions(+) create mode 100644 core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/ldap/auth/JndiLdapAuthManualTest.java create mode 100644 core-java-modules/core-java-jndi/src/test/resources/logback.xml create mode 100644 core-java-modules/core-java-jndi/src/test/resources/users.ldif diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index 1728c0b5d9..6b7c4e1359 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -41,6 +41,18 @@ h2 ${h2.version} + + org.apache.directory.server + apacheds-test-framework + ${apacheds.version} + test + + + org.assertj + assertj-core + 3.21.0 + test + @@ -59,6 +71,7 @@ 5.0.9.RELEASE 1.4.199 + 2.0.0.AM26 1.8 1.8 diff --git a/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/ldap/auth/JndiLdapAuthManualTest.java b/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/ldap/auth/JndiLdapAuthManualTest.java new file mode 100644 index 0000000000..5a675c62c9 --- /dev/null +++ b/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/ldap/auth/JndiLdapAuthManualTest.java @@ -0,0 +1,165 @@ +package com.baeldung.jndi.ldap.auth; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +import java.util.Hashtable; + +import javax.naming.AuthenticationException; +import javax.naming.Context; +import javax.naming.NamingEnumeration; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; + +import org.apache.directory.server.annotations.CreateLdapServer; +import org.apache.directory.server.annotations.CreateTransport; +import org.apache.directory.server.core.annotations.ApplyLdifFiles; +import org.apache.directory.server.core.annotations.CreateDS; +import org.apache.directory.server.core.annotations.CreatePartition; +import org.apache.directory.server.core.integ.AbstractLdapTestUnit; +import org.apache.directory.server.core.integ.FrameworkRunner; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(FrameworkRunner.class) +@CreateLdapServer(transports = { @CreateTransport(protocol = "LDAP", address = "localhost", port = 10390)}) +@CreateDS( + allowAnonAccess = false, partitions = {@CreatePartition(name = "TestPartition", suffix = "dc=baeldung,dc=com")}) +@ApplyLdifFiles({"users.ldif"}) +// class marked as manual test, as it has to run independently from the other unit tests in the module +public class JndiLdapAuthManualTest extends AbstractLdapTestUnit { + + private static void authenticateUser(Hashtable environment) throws Exception { + DirContext context = new InitialDirContext(environment); + context.close(); + } + + @Test + public void givenPreloadedLDAPUserJoe_whenAuthUserWithCorrectPW_thenAuthSucceeds() throws Exception { + + Hashtable environment = new Hashtable(); + environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + environment.put(Context.PROVIDER_URL, "ldap://localhost:10390"); + environment.put(Context.SECURITY_AUTHENTICATION, "simple"); + + environment.put(Context.SECURITY_PRINCIPAL, "cn=Joe Simms,ou=Users,dc=baeldung,dc=com"); + environment.put(Context.SECURITY_CREDENTIALS, "12345"); + + assertThatCode(() -> authenticateUser(environment)).doesNotThrowAnyException(); + } + + @Test + public void givenPreloadedLDAPUserJoe_whenAuthUserWithWrongPW_thenAuthFails() throws Exception { + + Hashtable environment = new Hashtable(); + environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + environment.put(Context.PROVIDER_URL, "ldap://localhost:10390"); + environment.put(Context.SECURITY_AUTHENTICATION, "simple"); + + environment.put(Context.SECURITY_PRINCIPAL, "cn=Joe Simms,ou=Users,dc=baeldung,dc=com"); + environment.put(Context.SECURITY_CREDENTIALS, "wronguserpw"); + + assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> authenticateUser(environment)); + } + + @Test + public void givenPreloadedLDAPUserJoe_whenSearchAndAuthUserWithCorrectPW_thenAuthSucceeds() throws Exception { + + // first authenticate against LDAP as admin to search up DN of user : Joe Simms + + Hashtable environment = new Hashtable(); + environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + environment.put(Context.PROVIDER_URL, "ldap://localhost:10390"); + environment.put(Context.SECURITY_AUTHENTICATION, "simple"); + environment.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); + environment.put(Context.SECURITY_CREDENTIALS, "secret"); + + DirContext adminContext = new InitialDirContext(environment); + + // define the search filter to find the person with CN : Joe Simms + String filter = "(&(objectClass=person)(cn=Joe Simms))"; + + // declare the attributes we want returned for the object being searched + String[] attrIDs = { "cn" }; + + // define the search controls + SearchControls searchControls = new SearchControls(); + searchControls.setReturningAttributes(attrIDs); + searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); + + // search for User with filter cn=Joe Simms + NamingEnumeration searchResults = adminContext.search("dc=baeldung,dc=com", filter, searchControls); + if (searchResults.hasMore()) { + + SearchResult result = (SearchResult) searchResults.next(); + Attributes attrs = result.getAttributes(); + + String distinguishedName = result.getNameInNamespace(); + assertThat(distinguishedName).isEqualTo("cn=Joe Simms,ou=Users,dc=baeldung,dc=com"); + + String commonName = attrs.get("cn").toString(); + assertThat(commonName).isEqualTo("cn: Joe Simms"); + + // authenticate new context with DN for user Joe Simms, using correct password + + environment.put(Context.SECURITY_PRINCIPAL, distinguishedName); + environment.put(Context.SECURITY_CREDENTIALS, "12345"); + + assertThatCode(() -> authenticateUser(environment)).doesNotThrowAnyException(); + } + + adminContext.close(); + } + + @Test + public void givenPreloadedLDAPUserJoe_whenSearchAndAuthUserWithWrongPW_thenAuthFails() throws Exception { + + // first authenticate against LDAP as admin to search up DN of user : Joe Simms + + Hashtable environment = new Hashtable(); + environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + environment.put(Context.PROVIDER_URL, "ldap://localhost:10390"); + environment.put(Context.SECURITY_AUTHENTICATION, "simple"); + environment.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); + environment.put(Context.SECURITY_CREDENTIALS, "secret"); + DirContext adminContext = new InitialDirContext(environment); + + // define the search filter to find the person with CN : Joe Simms + String filter = "(&(objectClass=person)(cn=Joe Simms))"; + + // declare the attributes we want returned for the object being searched + String[] attrIDs = { "cn" }; + + // define the search controls + SearchControls searchControls = new SearchControls(); + searchControls.setReturningAttributes(attrIDs); + searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); + + // search for User with filter cn=Joe Simms + NamingEnumeration searchResults = adminContext.search("dc=baeldung,dc=com", filter, searchControls); + if (searchResults.hasMore()) { + + SearchResult result = (SearchResult) searchResults.next(); + Attributes attrs = result.getAttributes(); + + String distinguishedName = result.getNameInNamespace(); + assertThat(distinguishedName).isEqualTo("cn=Joe Simms,ou=Users,dc=baeldung,dc=com"); + + String commonName = attrs.get("cn").toString(); + assertThat(commonName).isEqualTo("cn: Joe Simms"); + + // authenticate new context with DN for user Joe Simms, using wrong password + + environment.put(Context.SECURITY_PRINCIPAL, distinguishedName); + environment.put(Context.SECURITY_CREDENTIALS, "wronguserpassword"); + + assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> authenticateUser(environment)); + } + + adminContext.close(); + } +} diff --git a/core-java-modules/core-java-jndi/src/test/resources/logback.xml b/core-java-modules/core-java-jndi/src/test/resources/logback.xml new file mode 100644 index 0000000000..e55b365ba4 --- /dev/null +++ b/core-java-modules/core-java-jndi/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/core-java-modules/core-java-jndi/src/test/resources/users.ldif b/core-java-modules/core-java-jndi/src/test/resources/users.ldif new file mode 100644 index 0000000000..c1996586d5 --- /dev/null +++ b/core-java-modules/core-java-jndi/src/test/resources/users.ldif @@ -0,0 +1,20 @@ +version: 1 +dn: dc=baeldung,dc=com +objectClass: domain +objectClass: top +dc: baeldung + +dn: ou=Users,dc=baeldung,dc=com +objectClass: organizationalUnit +objectClass: top +ou: Users + +dn: cn=Joe Simms,ou=Users,dc=baeldung,dc=com +objectClass: inetOrgPerson +objectClass: organizationalPerson +objectClass: person +objectClass: top +cn: Joe Simms +sn: Simms +uid: user1 +userPassword: 12345 From 79b2bb09ba640188f690a654d026acda6115a3a8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Nov 2021 13:00:54 +0800 Subject: [PATCH 110/551] Update README.md --- persistence-modules/spring-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index e849ec4a83..202f5b0293 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -7,6 +7,7 @@ - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database) - [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) - [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) +- [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) - More articles: [[next -->]](/spring-jpa-2) ### Eclipse Config From af715aa493743cb34593d46c70bd6b57df244efa Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 4 Nov 2021 10:20:28 +0100 Subject: [PATCH 111/551] JAVA-8269: Do not use project.basedir in the xjc config --- spring-boot-modules/spring-boot-keycloak/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-keycloak/pom.xml b/spring-boot-modules/spring-boot-keycloak/pom.xml index c1bff066e3..adad6bb2d2 100644 --- a/spring-boot-modules/spring-boot-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-keycloak/pom.xml @@ -109,7 +109,7 @@ com.baeldung - ${project.basedir}/src/main/resources/products.xsd + src/main/resources/products.xsd From af4b37592bda1b1e5a6fd98273c10751dca1e6ec Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Thu, 4 Nov 2021 16:11:12 +0530 Subject: [PATCH 112/551] JAVA-8267: updating testing-modules's junit and surefire configurations --- testing-modules/assertion-libraries/pom.xml | 1 + testing-modules/easy-random/pom.xml | 4 +-- testing-modules/easymock/pom.xml | 1 + testing-modules/gatling/pom.xml | 4 +-- testing-modules/groovy-spock/pom.xml | 4 +-- testing-modules/junit-4/pom.xml | 4 +-- testing-modules/junit-5-advanced/pom.xml | 24 ++----------- testing-modules/junit-5-basics/pom.xml | 34 +++---------------- testing-modules/junit-5/pom.xml | 22 ++---------- testing-modules/junit5-annotations/pom.xml | 14 ++------ testing-modules/junit5-migration/pom.xml | 14 ++------ testing-modules/mockito-2/pom.xml | 4 +-- testing-modules/mockito-3/pom.xml | 4 +-- testing-modules/mocks/pom.xml | 4 +-- testing-modules/mockserver/pom.xml | 4 +-- testing-modules/pom.xml | 16 +++++++++ testing-modules/powermock/pom.xml | 3 +- testing-modules/selenium-junit-testng/pom.xml | 10 ++---- testing-modules/test-containers/pom.xml | 11 ++---- testing-modules/testing-libraries-2/pom.xml | 25 -------------- testing-modules/testing-libraries/pom.xml | 1 + testing-modules/testng/pom.xml | 4 +-- testing-modules/xmlunit-2/pom.xml | 4 +-- testing-modules/zerocode/pom.xml | 3 +- 24 files changed, 60 insertions(+), 159 deletions(-) diff --git a/testing-modules/assertion-libraries/pom.xml b/testing-modules/assertion-libraries/pom.xml index 14e0379a3c..2c84549d20 100644 --- a/testing-modules/assertion-libraries/pom.xml +++ b/testing-modules/assertion-libraries/pom.xml @@ -11,6 +11,7 @@ com.baeldung testing-modules 1.0.0-SNAPSHOT + ../ diff --git a/testing-modules/easy-random/pom.xml b/testing-modules/easy-random/pom.xml index 1ea6fbc387..f338519df3 100644 --- a/testing-modules/easy-random/pom.xml +++ b/testing-modules/easy-random/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/easymock/pom.xml b/testing-modules/easymock/pom.xml index a8e37da8eb..fd7db5dbb1 100644 --- a/testing-modules/easymock/pom.xml +++ b/testing-modules/easymock/pom.xml @@ -11,6 +11,7 @@ com.baeldung testing-modules 1.0.0-SNAPSHOT + ../ diff --git a/testing-modules/gatling/pom.xml b/testing-modules/gatling/pom.xml index 281c74d6b3..c702b576c5 100644 --- a/testing-modules/gatling/pom.xml +++ b/testing-modules/gatling/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/groovy-spock/pom.xml b/testing-modules/groovy-spock/pom.xml index 3c1f00abdf..65db332acb 100644 --- a/testing-modules/groovy-spock/pom.xml +++ b/testing-modules/groovy-spock/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/junit-4/pom.xml b/testing-modules/junit-4/pom.xml index 0ae6b71f82..f58d1709d3 100644 --- a/testing-modules/junit-4/pom.xml +++ b/testing-modules/junit-4/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/junit-5-advanced/pom.xml b/testing-modules/junit-5-advanced/pom.xml index 3f11c215ff..f37a41690b 100644 --- a/testing-modules/junit-5-advanced/pom.xml +++ b/testing-modules/junit-5-advanced/pom.xml @@ -10,29 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - \ No newline at end of file diff --git a/testing-modules/junit-5-basics/pom.xml b/testing-modules/junit-5-basics/pom.xml index d92ee55682..62dc4321a8 100644 --- a/testing-modules/junit-5-basics/pom.xml +++ b/testing-modules/junit-5-basics/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ @@ -22,36 +22,12 @@ ${junit-platform.version} test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.junit.jupiter junit-jupiter-migrationsupport ${junit-jupiter.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - com.h2database h2 @@ -97,8 +73,8 @@ + org.apache.maven.surefire maven-surefire-plugin - ${maven-surefire-plugin.version} **/*IntegrationTest.java @@ -116,8 +92,8 @@ + org.apache.maven.surefire maven-surefire-plugin - ${maven-surefire-plugin.version} com.baeldung.categories.UnitTest com.baeldung.categories.IntegrationTest @@ -134,8 +110,8 @@ + org.apache.maven.surefire maven-surefire-plugin - ${maven-surefire-plugin.version} UnitTest IntegrationTest diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index 148abecb0f..ef6e92faa4 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ @@ -22,16 +22,6 @@ junit-platform-engine ${junit-platform.version} - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - org.junit.platform junit-platform-runner @@ -45,13 +35,6 @@ ${junit-platform.version} test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.junit.jupiter junit-jupiter-migrationsupport @@ -140,7 +123,6 @@ 2.23.0 2.8.2 2.0.0 - 2.22.0 5.0.1.RELEASE 3.0.0-M3 diff --git a/testing-modules/junit5-annotations/pom.xml b/testing-modules/junit5-annotations/pom.xml index 79600eb589..86e71110c8 100644 --- a/testing-modules/junit5-annotations/pom.xml +++ b/testing-modules/junit5-annotations/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ @@ -21,16 +21,6 @@ junit-platform-engine ${junit-platform.version} - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - org.junit.jupiter junit-jupiter-api diff --git a/testing-modules/junit5-migration/pom.xml b/testing-modules/junit5-migration/pom.xml index 07f11e2b3a..3e34c1dee5 100644 --- a/testing-modules/junit5-migration/pom.xml +++ b/testing-modules/junit5-migration/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ @@ -27,12 +27,6 @@ ${junit-platform.version} test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.junit.jupiter junit-jupiter-migrationsupport @@ -50,8 +44,4 @@ - - 2.21.0 - - \ No newline at end of file diff --git a/testing-modules/mockito-2/pom.xml b/testing-modules/mockito-2/pom.xml index 558ac59d08..cff7598edc 100644 --- a/testing-modules/mockito-2/pom.xml +++ b/testing-modules/mockito-2/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/mockito-3/pom.xml b/testing-modules/mockito-3/pom.xml index 5a150ccbf9..5a79d81080 100644 --- a/testing-modules/mockito-3/pom.xml +++ b/testing-modules/mockito-3/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/mocks/pom.xml b/testing-modules/mocks/pom.xml index 17700a835e..3fabde037c 100644 --- a/testing-modules/mocks/pom.xml +++ b/testing-modules/mocks/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/mockserver/pom.xml b/testing-modules/mockserver/pom.xml index c039d6a0ab..3495ddb09d 100644 --- a/testing-modules/mockserver/pom.xml +++ b/testing-modules/mockserver/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index 28c743b2b3..079c7fa792 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -50,4 +50,20 @@ zerocode + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + 2.22.2 + + \ No newline at end of file diff --git a/testing-modules/powermock/pom.xml b/testing-modules/powermock/pom.xml index 7179f3ffbe..fad338bb9b 100644 --- a/testing-modules/powermock/pom.xml +++ b/testing-modules/powermock/pom.xml @@ -6,9 +6,10 @@ powermock - testing-modules com.baeldung + testing-modules 1.0.0-SNAPSHOT + ../ diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index 9f132c7562..860397f229 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ @@ -31,12 +31,6 @@ testng ${testng.version} - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.hamcrest hamcrest-all diff --git a/testing-modules/test-containers/pom.xml b/testing-modules/test-containers/pom.xml index 24f686d741..aa2c85af21 100644 --- a/testing-modules/test-containers/pom.xml +++ b/testing-modules/test-containers/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ @@ -29,12 +29,6 @@ ${junit-platform.version} test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.apache.logging.log4j log4j-core @@ -87,7 +81,6 @@ 1.11.4 42.2.6 3.141.59 - 2.22.2 \ No newline at end of file diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml index 82e4bbfdf0..2e8a1b4ed2 100644 --- a/testing-modules/testing-libraries-2/pom.xml +++ b/testing-modules/testing-libraries-2/pom.xml @@ -60,31 +60,6 @@ ${system-stubs.version} test - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/testing-modules/testing-libraries/pom.xml b/testing-modules/testing-libraries/pom.xml index f9443fa792..8c0fca775b 100644 --- a/testing-modules/testing-libraries/pom.xml +++ b/testing-modules/testing-libraries/pom.xml @@ -10,6 +10,7 @@ com.baeldung testing-modules 1.0.0-SNAPSHOT + ../ diff --git a/testing-modules/testng/pom.xml b/testing-modules/testng/pom.xml index 8b6a46a694..99af6be5b4 100644 --- a/testing-modules/testng/pom.xml +++ b/testing-modules/testng/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/xmlunit-2/pom.xml b/testing-modules/xmlunit-2/pom.xml index 07153ab042..a35d9c2b87 100644 --- a/testing-modules/xmlunit-2/pom.xml +++ b/testing-modules/xmlunit-2/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-modules + testing-modules 1.0.0-SNAPSHOT - ../../ + ../ diff --git a/testing-modules/zerocode/pom.xml b/testing-modules/zerocode/pom.xml index 48030166b5..ea12385a26 100644 --- a/testing-modules/zerocode/pom.xml +++ b/testing-modules/zerocode/pom.xml @@ -7,9 +7,10 @@ 1.0-SNAPSHOT - testing-modules com.baeldung + testing-modules 1.0.0-SNAPSHOT + ../ From 04f000b4ba5704b52369207687520a2eda9fc0d7 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 4 Nov 2021 12:37:59 +0100 Subject: [PATCH 113/551] JAVA-8269: Temporarily disable spring-boot-keycloak --- spring-boot-modules/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 1b2f6ffa06..0e4c2fe60b 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -46,7 +46,7 @@ spring-boot-groovy spring-boot-jasypt - spring-boot-keycloak + spring-boot-libraries spring-boot-libraries-2 spring-boot-logging-log4j2 From 86ab50684b1d464b5adfdfbfcc3e3d201455151e Mon Sep 17 00:00:00 2001 From: Trixi Turny Date: Thu, 4 Nov 2021 18:15:45 +0000 Subject: [PATCH 114/551] BAEL-5209 example with JUnit5, Hamcrest and AssertJ --- .../com/baeldung/object/type/Deciduous.java | 15 ++++++++++ .../com/baeldung/object/type/Evergreen.java | 16 +++++++++++ .../java/com/baeldung/object/type/Tree.java | 6 ++++ .../com/baeldung/object/type/TreeSorter.java | 19 +++++++++++++ .../type/TreeSorterAssertJUnitTest.java | 22 +++++++++++++++ .../type/TreeSorterHamcrestUnitTest.java | 28 +++++++++++++++++++ 6 files changed, 106 insertions(+) create mode 100644 testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Deciduous.java create mode 100644 testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Evergreen.java create mode 100644 testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Tree.java create mode 100644 testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/TreeSorter.java create mode 100644 testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterAssertJUnitTest.java create mode 100644 testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterHamcrestUnitTest.java diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Deciduous.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Deciduous.java new file mode 100644 index 0000000000..ae96446a63 --- /dev/null +++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Deciduous.java @@ -0,0 +1,15 @@ +package com.baeldung.object.type; + +public class Deciduous implements Tree { + + private String name; + + public Deciduous(String name) { + this.name = name; + } + + @Override + public boolean isEvergreen() { + return false; + } +} diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Evergreen.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Evergreen.java new file mode 100644 index 0000000000..56cda60d22 --- /dev/null +++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Evergreen.java @@ -0,0 +1,16 @@ +package com.baeldung.object.type; + +public class Evergreen implements Tree { + + private String name; + + public Evergreen(String name) { + this.name = name; + } + + + @Override + public boolean isEvergreen() { + return true; + } +} diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Tree.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Tree.java new file mode 100644 index 0000000000..0230c61e38 --- /dev/null +++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/Tree.java @@ -0,0 +1,6 @@ +package com.baeldung.object.type; + +public interface Tree { + + public boolean isEvergreen(); +} diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/TreeSorter.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/TreeSorter.java new file mode 100644 index 0000000000..af4a6e5ef8 --- /dev/null +++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/object/type/TreeSorter.java @@ -0,0 +1,19 @@ +package com.baeldung.object.type; + +import java.util.List; + +public class TreeSorter { + protected Tree sortTree(String name) { + + final List deciduous = List.of("Beech", "Birch", "Ash", "Whitebeam", "Hornbeam", "Hazel & Willow"); + final List evergreen = List.of("Cedar", "Holly", "Laurel", "Olive", "Pine"); + + if (deciduous.contains(name)) { + return new Deciduous(name); + } else if (evergreen.contains(name)) { + return new Evergreen(name); + } else { + throw new RuntimeException("Tree could not be classified"); + } + } +} diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterAssertJUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterAssertJUnitTest.java new file mode 100644 index 0000000000..74b0eec4d9 --- /dev/null +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterAssertJUnitTest.java @@ -0,0 +1,22 @@ +package com.baeldung.object.type; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class TreeSorterAssertJUnitTest { + private final TreeSorter tested = new TreeSorter(); + + @Test + public void sortTreeShouldReturnEvergreen_WhenPineIsPassed() { + Tree tree = tested.sortTree("Pine"); + assertThat(tree).isExactlyInstanceOf(Evergreen.class); + } + + @Test + public void sortTreeShouldReturnDecidious_WhenBirchIsPassed() { + Tree tree = tested.sortTree("Birch"); + assertThat(tree).hasSameClassAs(new Deciduous("Birch")); + } + +} \ No newline at end of file diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterHamcrestUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterHamcrestUnitTest.java new file mode 100644 index 0000000000..7d35d5c0d0 --- /dev/null +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/object/type/TreeSorterHamcrestUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.object.type; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class TreeSorterHamcrestUnitTest { + private final TreeSorter tested = new TreeSorter(); + + @Test + public void sortTreeShouldReturnEvergreen_WhenPineIsPassed() { + Tree tree = tested.sortTree("Pine"); + //with JUnit assertEquals: + assertEquals(tree.getClass(), Evergreen.class); + //with Hamcrest instanceOf: + assertThat(tree, instanceOf(Evergreen.class)); + + } + + @Test + public void sortTreeShouldReturnDecidious_WhenBirchIsPassed() { + Tree tree = tested.sortTree("Birch"); + assertThat(tree, instanceOf(Deciduous.class)); + } + +} \ No newline at end of file From 502372a1decf519899eba83c5d0a7514b1e6cdd3 Mon Sep 17 00:00:00 2001 From: Benjamin Caure Date: Thu, 4 Nov 2021 21:13:22 +0100 Subject: [PATCH 115/551] BAEL-4792 Stateless REST API and CSRF (#11398) * Scan package for controller Migrate deprecated Spring config * BAEL-4792: enable CSRF + sample REST API request * Adjust CSRF logs --- .../java/com/baeldung/spring/MvcConfig.java | 10 ++--- .../com/baeldung/spring/RestController.java | 31 ++++++++++++++ .../baeldung/spring/SecSecurityConfig.java | 11 ++--- .../src/main/resources/logback.xml | 2 +- .../src/main/webapp/WEB-INF/view/homepage.jsp | 42 ++++++++++++++++++- .../webapp/WEB-INF/view/react/public/csrf.js | 3 ++ .../WEB-INF/view/react/public/index.html | 1 + .../webapp/WEB-INF/view/react/src/Form.js | 15 +++---- 8 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/RestController.java create mode 100644 spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/csrf.js diff --git a/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/MvcConfig.java b/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/MvcConfig.java index f8acdfe2ac..226459db75 100644 --- a/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/MvcConfig.java +++ b/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/MvcConfig.java @@ -1,18 +1,20 @@ package com.baeldung.spring; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; @EnableWebMvc @Configuration -public class MvcConfig extends WebMvcConfigurerAdapter { +@ComponentScan(basePackages = { "com.baeldung.spring" }) +public class MvcConfig implements WebMvcConfigurer { public MvcConfig() { super(); @@ -22,8 +24,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/anonymous.html"); registry.addViewController("/login.html"); @@ -35,7 +35,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("/WEB-INF/view/react/build/static/"); - + registry.addResourceHandler("/*.js").addResourceLocations("/WEB-INF/view/react/build/"); registry.addResourceHandler("/*.json").addResourceLocations("/WEB-INF/view/react/build/"); registry.addResourceHandler("/*.ico").addResourceLocations("/WEB-INF/view/react/build/"); diff --git a/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/RestController.java b/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/RestController.java new file mode 100644 index 0000000000..4084df9698 --- /dev/null +++ b/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/RestController.java @@ -0,0 +1,31 @@ +package com.baeldung.spring; +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.security.web.csrf.CsrfToken; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/rest") +public class RestController { + + private static final Logger LOGGER = LoggerFactory.getLogger(RestController.class); + + @GetMapping + public ResponseEntity get(HttpServletRequest request) { + CsrfToken token = (CsrfToken) request.getAttribute("_csrf"); + LOGGER.info("{}={}", token.getHeaderName(), token.getToken()); + return ResponseEntity.ok().build(); + } + + @PostMapping + public ResponseEntity post(HttpServletRequest request) { + // Same impl as GET for testing purpose + return this.get(request); + } +} diff --git a/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/SecSecurityConfig.java b/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/SecSecurityConfig.java index 7b67028647..d560589cce 100644 --- a/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-modules/spring-security-web-react/src/main/java/com/baeldung/spring/SecSecurityConfig.java @@ -7,6 +7,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.csrf.CookieCsrfTokenRepository; @Configuration @EnableWebSecurity @@ -21,11 +22,11 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(final AuthenticationManagerBuilder auth) throws Exception { // @formatter:off auth.inMemoryAuthentication() - .withUser("user1").password("user1Pass").roles("USER") + .withUser("user1").password("{noop}user1Pass").roles("USER") .and() - .withUser("user2").password("user2Pass").roles("USER") + .withUser("user2").password("{noop}user2Pass").roles("USER") .and() - .withUser("admin").password("admin0Pass").roles("ADMIN"); + .withUser("admin").password("{noop}admin0Pass").roles("ADMIN"); // @formatter:on } @@ -33,11 +34,11 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(final HttpSecurity http) throws Exception { // @formatter:off http - .csrf().disable() + .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).and() .authorizeRequests() .antMatchers("/admin/**").hasRole("ADMIN") .antMatchers("/anonymous*").anonymous() - .antMatchers(HttpMethod.GET, "/index*", "/static/**", "/*.js", "/*.json", "/*.ico").permitAll() + .antMatchers(HttpMethod.GET, "/index*", "/static/**", "/*.js", "/*.json", "/*.ico", "/rest").permitAll() .anyRequest().authenticated() .and() .formLogin() diff --git a/spring-security-modules/spring-security-web-react/src/main/resources/logback.xml b/spring-security-modules/spring-security-web-react/src/main/resources/logback.xml index 25f3f36d1a..2cc702de59 100644 --- a/spring-security-modules/spring-security-web-react/src/main/resources/logback.xml +++ b/spring-security-modules/spring-security-web-react/src/main/resources/logback.xml @@ -12,7 +12,7 @@ - + diff --git a/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/homepage.jsp index c9d88cbc9b..d64f80a5cb 100644 --- a/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/homepage.jsp @@ -1,11 +1,30 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - + + +

This is the body of the sample view

+
+

CSRF Testing

+
+ CSRF Token: + + +
+
+
+   + +
+
+
Request Result:

+
+ +

Roles

This text is only visible to a user

@@ -22,5 +41,26 @@ ">Logout + \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/csrf.js b/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/csrf.js new file mode 100644 index 0000000000..657cc31f41 --- /dev/null +++ b/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/csrf.js @@ -0,0 +1,3 @@ +window.getCsrfToken = () => { + return document.cookie.replace(/(?:(?:^|.*;\s*)XSRF-TOKEN\s*\=\s*([^;]*).*$)|^.*$/, '$1'); +} diff --git a/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/index.html b/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/index.html index 0c3f78d7b3..6d4894da42 100644 --- a/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/index.html +++ b/spring-security-modules/spring-security-web-react/src/main/webapp/WEB-INF/view/react/public/index.html @@ -6,6 +6,7 @@ + javax.transaction diff --git a/google-web-toolkit/pom.xml b/google-web-toolkit/pom.xml index 1a49ced021..bcccc136a4 100644 --- a/google-web-toolkit/pom.xml +++ b/google-web-toolkit/pom.xml @@ -44,12 +44,6 @@ gwt-dev provided - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test -
diff --git a/grpc/pom.xml b/grpc/pom.xml index f034b2b517..6f0c3b5c91 100644 --- a/grpc/pom.xml +++ b/grpc/pom.xml @@ -37,12 +37,6 @@ ${io.grpc.version} test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - javax.annotation javax.annotation-api diff --git a/json-2/pom.xml b/json-2/pom.xml index 53d67320ba..b4301c41e5 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -24,12 +24,6 @@ jsoniter ${jsoniter.version} - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core diff --git a/junit5/pom.xml b/junit5/pom.xml index b9804408a2..00b04ea292 100644 --- a/junit5/pom.xml +++ b/junit5/pom.xml @@ -8,8 +8,8 @@ junit5 - parent-modules com.baeldung + parent-modules 1.0.0-SNAPSHOT @@ -18,19 +18,4 @@ 8 - - - org.junit.jupiter - junit-jupiter-api - 5.8.1 - test - - - org.junit.jupiter - junit-jupiter-engine - 5.8.1 - test - - - \ No newline at end of file diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index 3db34709e7..dd48453a8c 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -14,12 +14,6 @@ - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.apache.kafka kafka-streams @@ -92,6 +86,10 @@ commons-codec commons-codec + + junit + junit + @@ -104,6 +102,12 @@ flink-test-utils_2.11 ${flink.version} test + + + junit + junit + + org.slf4j diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml index a9c340b319..954f666785 100644 --- a/libraries-server/pom.xml +++ b/libraries-server/pom.xml @@ -61,12 +61,6 @@ netty-all ${netty.version} - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.apache.tomcat diff --git a/libraries/pom.xml b/libraries/pom.xml index 4ecf82aa87..b2e429ff65 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -146,12 +146,6 @@ jmh-core ${jmh-core.version} - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - info.debatty java-lsh diff --git a/maven-modules/maven-integration-test/pom.xml b/maven-modules/maven-integration-test/pom.xml index 4283baf63b..01be0ad1a4 100644 --- a/maven-modules/maven-integration-test/pom.xml +++ b/maven-modules/maven-integration-test/pom.xml @@ -26,12 +26,6 @@ jersey-hk2 ${jersey.version} - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - diff --git a/maven-modules/maven-properties/pom.xml b/maven-modules/maven-properties/pom.xml index b3169a7fb0..88e13a0fb8 100644 --- a/maven-modules/maven-properties/pom.xml +++ b/maven-modules/maven-properties/pom.xml @@ -14,15 +14,6 @@ ../.. - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - diff --git a/micronaut/pom.xml b/micronaut/pom.xml index f36f565a94..019bd6ab29 100644 --- a/micronaut/pom.xml +++ b/micronaut/pom.xml @@ -64,12 +64,6 @@ ${logback.version} runtime - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - io.projectreactor reactor-core diff --git a/persistence-modules/java-jpa-3/pom.xml b/persistence-modules/java-jpa-3/pom.xml index ad649d58d8..0eb4b8075d 100644 --- a/persistence-modules/java-jpa-3/pom.xml +++ b/persistence-modules/java-jpa-3/pom.xml @@ -68,12 +68,6 @@ ${assertj.version} test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.testcontainers postgresql diff --git a/restx/pom.xml b/restx/pom.xml index ea9f927563..57736f60cd 100644 --- a/restx/pom.xml +++ b/restx/pom.xml @@ -113,12 +113,6 @@ - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test -
diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index 10bc6d3104..8a41da5448 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -80,12 +80,6 @@ arquillian-junit-container test - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - joda-time diff --git a/tensorflow-java/pom.xml b/tensorflow-java/pom.xml index 2ac4d28a37..4dd86d45e3 100644 --- a/tensorflow-java/pom.xml +++ b/tensorflow-java/pom.xml @@ -21,18 +21,6 @@ tensorflow ${tensorflow.version} - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test -
diff --git a/xml/pom.xml b/xml/pom.xml index 6bae312452..f88f0f89b0 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -107,18 +107,6 @@ commons-lang ${commons-lang.version} - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - org.assertj assertj-core From 0f8560ed36c7ff2586c0c580cfeb9311e8d70856 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Fri, 5 Nov 2021 16:04:59 +0530 Subject: [PATCH 118/551] JAVA-1672: removing redundant junit-platform-commons declarations --- algorithms-miscellaneous-5/pom.xml | 5 ----- algorithms-miscellaneous-6/pom.xml | 5 ----- testing-modules/spring-testing/pom.xml | 5 ----- testing-modules/test-containers/pom.xml | 6 ------ 4 files changed, 21 deletions(-) diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 32ecce58a6..c68ac96c38 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -34,11 +34,6 @@ guava ${guava.version} - - org.junit.platform - junit-platform-commons - ${junit-platform.version} - org.assertj assertj-core diff --git a/algorithms-miscellaneous-6/pom.xml b/algorithms-miscellaneous-6/pom.xml index 6d5f211c8a..a9eb75cf1e 100644 --- a/algorithms-miscellaneous-6/pom.xml +++ b/algorithms-miscellaneous-6/pom.xml @@ -19,11 +19,6 @@ guava ${guava.version} - - org.junit.platform - junit-platform-commons - ${junit-platform.version} - org.assertj assertj-core diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index ff5265eab8..08b56c9a1a 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -60,11 +60,6 @@ org.springframework.data spring-data-jpa - - org.junit.platform - junit-platform-commons - ${junit-platform.version} - org.awaitility awaitility diff --git a/testing-modules/test-containers/pom.xml b/testing-modules/test-containers/pom.xml index aa2c85af21..687bc418ad 100644 --- a/testing-modules/test-containers/pom.xml +++ b/testing-modules/test-containers/pom.xml @@ -23,12 +23,6 @@ ${junit-platform.version} test - - org.junit.platform - junit-platform-commons - ${junit-platform.version} - test - org.apache.logging.log4j log4j-core From 073e3c1771b9774e6c6f9de16e761bdb5728c601 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Fri, 5 Nov 2021 16:35:29 +0530 Subject: [PATCH 119/551] JAVA-1672: updating surefire version in main pom --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f2a53f38b7..855cf54f0a 100644 --- a/pom.xml +++ b/pom.xml @@ -1398,8 +1398,7 @@ 1.2.6 - - 2.21.0 + 2.22.2 3.8.1 3.0.0 1.8 From 15cae84104b9f76bbf13be815db4ff3d4e674a43 Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Fri, 5 Nov 2021 13:24:28 +0100 Subject: [PATCH 120/551] BAEL-4546 incorporate thee review comments --- docker/docker-sample-app/pom.xml | 72 ++++++++++++++++---------------- docker/pom.xml | 2 +- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docker/docker-sample-app/pom.xml b/docker/docker-sample-app/pom.xml index 416ec45b10..6841fabcee 100644 --- a/docker/docker-sample-app/pom.xml +++ b/docker/docker-sample-app/pom.xml @@ -1,45 +1,45 @@ - 4.0.0 - - com.baeldung.docker - docker - 0.0.1 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.baeldung.docker + docker + 0.0.1 + - docker-sample-app - docker-sample-app - Demo project for Spring Boot and Docker + docker-sample-app + docker-sample-app + Demo project for Spring Boot and Docker - - 11 - + + 11 + - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + - - org.springframework.boot - spring-boot-starter-test - test - - + + org.springframework.boot + spring-boot-starter-test + test + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/docker/pom.xml b/docker/pom.xml index 0a397dd966..f481f1b8b7 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -25,7 +25,7 @@ docker-internal-dto docker-spring-boot - docker-sample-app + docker-sample-app From 7502addfafac08d5b86ff5117da77699b7ddbd0d Mon Sep 17 00:00:00 2001 From: Swapan Pramanick Date: Fri, 5 Nov 2021 14:40:16 +0100 Subject: [PATCH 121/551] BAEL-4546 incorporate thee review comments --- docker/docker-sample-app/mvnw | 310 ------------------------------ docker/docker-sample-app/mvnw.cmd | 182 ------------------ 2 files changed, 492 deletions(-) delete mode 100755 docker/docker-sample-app/mvnw delete mode 100644 docker/docker-sample-app/mvnw.cmd diff --git a/docker/docker-sample-app/mvnw b/docker/docker-sample-app/mvnw deleted file mode 100755 index a16b5431b4..0000000000 --- a/docker/docker-sample-app/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/docker/docker-sample-app/mvnw.cmd b/docker/docker-sample-app/mvnw.cmd deleted file mode 100644 index c8d43372c9..0000000000 --- a/docker/docker-sample-app/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% From 9d464b4f459987e0dbc548beec1dd8882dba21b6 Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Azam Khan Date: Fri, 5 Nov 2021 18:32:19 +0400 Subject: [PATCH 122/551] Refactoring for better Indentation and Formatting --- .../UnsupportedMediaTypeApplication.java | 6 ++-- .../baeldung/unsupportedmediatype/User.java | 17 +++++------ .../ApplicationUnitTest.java | 28 +++++++++---------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java index ccc136ef86..2bf6bb33cd 100644 --- a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/UnsupportedMediaTypeApplication.java @@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class UnsupportedMediaTypeApplication { - public static void main(String[] args) { - SpringApplication.run(UnsupportedMediaTypeApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(UnsupportedMediaTypeApplication.class, args); + } } diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java index 5f5f2a972c..f9c3d9c191 100644 --- a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java @@ -11,10 +11,9 @@ public class User implements Serializable { private String address; public User(){ - } - public User(Integer id, String name, Integer age, String address){ + public User(Integer id, String name, Integer age, String address) { this.id = id; this.name = name; this.age = age; @@ -55,11 +54,13 @@ public class User implements Serializable { @Override public String toString() { - return "User{" + - "id=" + id + - ", name='" + name + '\'' + - ", age=" + age + - ", address='" + address + '\'' + - '}'; + return "User{" + + "id=" + id + + ", name='" + name + '\'' + + ", age=" + age + + ", address='" + address + '\'' + + '}'; } + + } diff --git a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java index a84388f750..95de780106 100644 --- a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java +++ b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java @@ -21,38 +21,38 @@ public class ApplicationUnitTest { public void JsonTestCase() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/user/") .contentType(MediaType.APPLICATION_JSON_VALUE) - .content("{\n" + - " \"name\": \"Andy\",\n" + - " \"age\": 1,\n" + - " \"address\": \"Hello world\"\n" + - "}")) + .content( "{\n" + + " \"name\": \"Andy\",\n" + + " \"age\": 1,\n" + + " \"address\": \"Hello world\"\n" + + "}")) .andExpect(status().isOk()); } @Test public void JsonFailTestCase() throws Exception {// Because no content-type added mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .content("{\n" + - " \"name\": \"Andy\",\n" + - " \"age\": 1,\n" + - " \"address\": \"Hello world\"\n" + - "}")) + .content( "{\n" + + " \"name\": \"Andy\",\n" + + " \"age\": 1,\n" + + " \"address\": \"Hello world\"\n" + + "}")) .andExpect(status().isUnsupportedMediaType()); } @Test public void XmlTestCase() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .contentType(MediaType.APPLICATION_XML_VALUE) - .content("Andy1
Hello world
")) + .contentType(MediaType.APPLICATION_XML_VALUE) + .content("Andy1
Hello world
")) .andExpect(status().isOk()); } @Test public void StringFailTestCase() throws Exception { // Because content-type is not supported mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .contentType(MediaType.TEXT_PLAIN_VALUE) - .content("Andy1
Hello world
")) + .contentType(MediaType.TEXT_PLAIN_VALUE) + .content("Andy1
Hello world
")) .andExpect(status().isUnsupportedMediaType()); } } From 47ca31189a3adb3b192081d51bb8eae2bbfeb628 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sat, 6 Nov 2021 05:53:22 +0530 Subject: [PATCH 123/551] Review comments updated Review comments updated --- core-java-modules/core-java/pom.xml | 8 +- .../baeldung/util/MySerializationUtils.java | 44 +++++ .../com/baeldung/util/SerializationUtils.java | 47 ------ .../serialization/SerializationUnitTest.java | 154 +++++++++--------- 4 files changed, 125 insertions(+), 128 deletions(-) create mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java delete mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index 00f26b0e0a..42262be29a 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -62,10 +62,10 @@ ${javamoney.moneta.version}
- org.springframework - spring-core - ${spring.core.version} - + org.springframework + spring-core + ${spring.core.version} +
diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java new file mode 100644 index 0000000000..bfaa91313c --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java @@ -0,0 +1,44 @@ +package com.baeldung.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +public class MySerializationUtils { + + public static byte[] serialize(T obj) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(obj); + oos.close(); + return baos.toByteArray(); + } + + public static T deserialize(byte[] b, Class cl) throws IOException, ClassNotFoundException { + ByteArrayInputStream bais = new ByteArrayInputStream(b); + ObjectInputStream ois = new ObjectInputStream(bais); + Object o = ois.readObject(); + return cl.cast(o); + } + + public static boolean isSerializable(Class it) { + boolean serializable = it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); + if (!serializable) { + return serializable; + } + Field[] declaredFields = it.getDeclaredFields(); + for (Field field : declaredFields) { + if (Modifier.isVolatile(field.getModifiers()) || Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) { + continue; + } + Class fieldType = field.getType(); + return isSerializable(fieldType); + } + return serializable; + } +} diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java deleted file mode 100644 index 2a9391965f..0000000000 --- a/core-java-modules/core-java/src/main/java/com/baeldung/util/SerializationUtils.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baeldung.util; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -public class SerializationUtils { - - public static byte[] serialize(T obj) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(obj); - oos.close(); - return baos.toByteArray(); - } - - public static T deserialize(byte[] b, Class cl) - throws IOException, ClassNotFoundException { - ByteArrayInputStream bais = new ByteArrayInputStream(b); - ObjectInputStream ois = new ObjectInputStream(bais); - Object o = ois.readObject(); - return cl.cast(o); - } - - public static boolean isSerializable(Class it) { - boolean serializable = it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it); - if (!serializable) { - return serializable; - } - Field[] declaredFields = it.getDeclaredFields(); - for (Field field : declaredFields) { - if (Modifier.isVolatile(field.getModifiers()) - || Modifier.isTransient(field.getModifiers()) - || Modifier.isStatic(field.getModifiers())) { - continue; - } - Class fieldType = field.getType(); - return isSerializable(fieldType); - } - return serializable; - } -} diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java index e0ee2bb654..bc9cf04b86 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java @@ -1,7 +1,8 @@ package com.baeldung.serialization; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -16,94 +17,93 @@ import org.junit.Test; public class SerializationUnitTest { - @Test(expected = NotSerializableException.class) - public void whenSerializing_ThenThrowsError() throws IOException { - Address address = new Address(); - address.setHouseNumber(10); - FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt"); - try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { - objectOutputStream.writeObject(address); - } - } - - @Test + @Test(expected = NotSerializableException.class) + public void whenSerializing_ThenThrowsError() throws IOException { + Address address = new Address(); + address.setHouseNumber(10); + FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt"); + try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { + objectOutputStream.writeObject(address); + } + } + + @Test public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOException, ClassNotFoundException { Person p = new Person(); p.setAge(20); p.setName("Joe"); FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt"); - try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { - objectOutputStream.writeObject(p); - } + try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { + objectOutputStream.writeObject(p); + } - FileInputStream fileInputStream = new FileInputStream("yofile.txt"); - try ( ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) { - Person p2 = (Person) objectInputStream.readObject(); - assertTrue(p2.getAge() == p.getAge()); - assertTrue(p2.getName().equals(p.getName())); - } - } + FileInputStream fileInputStream = new FileInputStream("yofile.txt"); + try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) { + Person p2 = (Person) objectInputStream.readObject(); + assertEquals(p2.getAge(), p.getAge()); + assertEquals(p2.getName(), p.getName()); + } + } - @Test(expected = ClassCastException.class) - public void whenSerializingUsingApacheCommons_ThenThrowsError() { - Address address = new Address(); - address.setHouseNumber(10); - SerializationUtils.serialize((Serializable) address); - } + @Test(expected = ClassCastException.class) + public void whenSerializingUsingApacheCommons_ThenThrowsError() { + Address address = new Address(); + address.setHouseNumber(10); + SerializationUtils.serialize((Serializable) address); + } - @Test - public void whenSerializingAndDeserializingUsingApacheCommons_ThenObjectIsTheSame() { - Person p = new Person(); - p.setAge(20); - p.setName("Joe"); - byte[] serialize = SerializationUtils.serialize(p); - Person p2 = (Person) SerializationUtils.deserialize(serialize); - assertTrue(p2.getAge() == p.getAge()); - assertTrue(p2.getName().equals(p.getName())); - } + @Test + public void whenSerializingAndDeserializingUsingApacheCommons_ThenObjectIsTheSame() { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + byte[] serialize = SerializationUtils.serialize(p); + Person p2 = (Person) SerializationUtils.deserialize(serialize); + assertEquals(p2.getAge(), p.getAge()); + assertEquals(p2.getName(), p.getName()); + } - @Test(expected = ClassCastException.class) - public void whenSerializingUsingSpringSerializationUtils_ThenThrowsError() { - Address address = new Address(); - address.setHouseNumber(10); - org.springframework.util.SerializationUtils.serialize((Serializable) address); - } + @Test(expected = ClassCastException.class) + public void whenSerializingUsingSpringSerializationUtils_ThenThrowsError() { + Address address = new Address(); + address.setHouseNumber(10); + org.springframework.util.SerializationUtils.serialize((Serializable) address); + } - @Test - public void whenSerializingAndDeserializingUsingSpringSerializationUtils_ThenObjectIsTheSame() { - Person p = new Person(); - p.setAge(20); - p.setName("Joe"); - byte[] serialize = org.springframework.util.SerializationUtils.serialize(p); - Person p2 = (Person) org.springframework.util.SerializationUtils.deserialize(serialize); - assertTrue(p2.getAge() == p.getAge()); - assertTrue(p2.getName().equals(p.getName())); - } + @Test + public void whenSerializingAndDeserializingUsingSpringSerializationUtils_ThenObjectIsTheSame() { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + byte[] serialize = org.springframework.util.SerializationUtils.serialize(p); + Person p2 = (Person) org.springframework.util.SerializationUtils.deserialize(serialize); + assertEquals(p2.getAge(), p.getAge()); + assertEquals(p2.getName(), p.getName()); + } - @Test(expected = ClassCastException.class) - public void whenSerializingUsingCustomSerializationUtils_ThenThrowsError() throws IOException { - Address address = new Address(); - address.setHouseNumber(10); - com.baeldung.util.SerializationUtils.serialize((Serializable) address); - } + @Test(expected = ClassCastException.class) + public void whenSerializingUsingCustomSerializationUtils_ThenThrowsError() throws IOException { + Address address = new Address(); + address.setHouseNumber(10); + com.baeldung.util.MySerializationUtils.serialize((Serializable) address); + } - @Test - public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame() - throws IOException, ClassNotFoundException { - Person p = new Person(); - p.setAge(20); - p.setName("Joe"); - byte[] serialize = com.baeldung.util.SerializationUtils.serialize(p); - Person p2 = com.baeldung.util.SerializationUtils.deserialize(serialize, Person.class); - assertTrue(p2.getAge() == p.getAge()); - assertTrue(p2.getName().equals(p.getName())); - } + @Test + public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame() throws IOException, ClassNotFoundException { + Person p = new Person(); + p.setAge(20); + p.setName("Joe"); + byte[] serialize = com.baeldung.util.MySerializationUtils.serialize(p); + Person p2 = com.baeldung.util.MySerializationUtils.deserialize(serialize, Person.class); + assertEquals(p2.getAge(), p.getAge()); + assertEquals(p2.getName(), p.getName()); + } - @Test - public void whenSerializingUsingCustomSerializationUtils_ThanOk() { - assertFalse(com.baeldung.util.SerializationUtils.isSerializable(Address.class)); - assertTrue(com.baeldung.util.SerializationUtils.isSerializable(Person.class)); - assertTrue(com.baeldung.util.SerializationUtils.isSerializable(Integer.class)); - } + @Test + public void whenSerializingUsingCustomSerializationUtils_ThanOk() { + assertFalse(com.baeldung.util.MySerializationUtils.isSerializable(Address.class)); + assertTrue(com.baeldung.util.MySerializationUtils.isSerializable(Person.class)); + assertTrue(com.baeldung.util.MySerializationUtils.isSerializable(Integer.class)); + } } From 9728ae73773aed0a06583b3a4ec50c1f4e5810fe Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sat, 6 Nov 2021 06:09:48 +0530 Subject: [PATCH 124/551] Updated review comment --- .../serialization/SerializationUnitTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java index bc9cf04b86..a8c4009386 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java @@ -15,6 +15,8 @@ import java.io.Serializable; import org.apache.commons.lang3.SerializationUtils; import org.junit.Test; +import com.baeldung.util.MySerializationUtils; + public class SerializationUnitTest { @Test(expected = NotSerializableException.class) @@ -86,7 +88,7 @@ public class SerializationUnitTest { public void whenSerializingUsingCustomSerializationUtils_ThenThrowsError() throws IOException { Address address = new Address(); address.setHouseNumber(10); - com.baeldung.util.MySerializationUtils.serialize((Serializable) address); + MySerializationUtils.serialize((Serializable) address); } @Test @@ -94,16 +96,16 @@ public class SerializationUnitTest { Person p = new Person(); p.setAge(20); p.setName("Joe"); - byte[] serialize = com.baeldung.util.MySerializationUtils.serialize(p); - Person p2 = com.baeldung.util.MySerializationUtils.deserialize(serialize, Person.class); + byte[] serialize = MySerializationUtils.serialize(p); + Person p2 = MySerializationUtils.deserialize(serialize, Person.class); assertEquals(p2.getAge(), p.getAge()); assertEquals(p2.getName(), p.getName()); } @Test public void whenSerializingUsingCustomSerializationUtils_ThanOk() { - assertFalse(com.baeldung.util.MySerializationUtils.isSerializable(Address.class)); - assertTrue(com.baeldung.util.MySerializationUtils.isSerializable(Person.class)); - assertTrue(com.baeldung.util.MySerializationUtils.isSerializable(Integer.class)); + assertFalse(MySerializationUtils.isSerializable(Address.class)); + assertTrue(MySerializationUtils.isSerializable(Person.class)); + assertTrue(MySerializationUtils.isSerializable(Integer.class)); } } From 91f5674d46c792c42128f1dbb55db6f1815b575d Mon Sep 17 00:00:00 2001 From: Thiago dos Santos Hora Date: Sun, 24 Oct 2021 18:42:53 +0200 Subject: [PATCH 125/551] [BAEL-5197] Add code samples and tests --- core-java-modules/core-java-17/README.md | 1 + core-java-modules/core-java-17/pom.xml | 84 +++++++++++++++++++ .../java/com/baeldung/features/JEP356.java | 20 +++++ .../java/com/baeldung/features/JEP406.java | 28 +++++++ .../java/com/baeldung/features/JEP409.java | 38 +++++++++ .../java/com/baeldung/features/JEP412.java | 56 +++++++++++++ .../java/com/baeldung/features/JEP414.java | 27 ++++++ .../src/main/java/module-info.java | 4 + .../src/main/resources/compile_c.sh | 9 ++ .../src/main/resources/print_name.c | 8 ++ .../com/baeldung/features/JEP356UnitTest.java | 19 +++++ .../com/baeldung/features/JEP406UnitTest.java | 33 ++++++++ .../com/baeldung/features/JEP409UnitTest.java | 39 +++++++++ .../com/baeldung/features/JEP412UnitTest.java | 17 ++++ .../com/baeldung/features/JEP414UnitTest.java | 38 +++++++++ 15 files changed, 421 insertions(+) create mode 100644 core-java-modules/core-java-17/README.md create mode 100644 core-java-modules/core-java-17/pom.xml create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP356.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP406.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP409.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP412.java create mode 100644 core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP414.java create mode 100644 core-java-modules/core-java-17/src/main/java/module-info.java create mode 100755 core-java-modules/core-java-17/src/main/resources/compile_c.sh create mode 100644 core-java-modules/core-java-17/src/main/resources/print_name.c create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP356UnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP406UnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP409UnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP412UnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP414UnitTest.java diff --git a/core-java-modules/core-java-17/README.md b/core-java-modules/core-java-17/README.md new file mode 100644 index 0000000000..37095551a1 --- /dev/null +++ b/core-java-modules/core-java-17/README.md @@ -0,0 +1 @@ +### Relevant articles: diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml new file mode 100644 index 0000000000..e422bd62bb --- /dev/null +++ b/core-java-modules/core-java-17/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + core-java-17 + 0.1.0-SNAPSHOT + core-java-17 + jar + http://maven.apache.org + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.release} + --enable-preview + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + + --enable-preview + --enable-native-access=core.java + 1 + + + + + org.apache.maven.surefire + surefire-api + ${surefire.plugin.version} + + + + + + + + 17 + 17 + 17 + 3.8.1 + 3.0.0-M5 + 3.17.2 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP356.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP356.java new file mode 100644 index 0000000000..0890b025be --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP356.java @@ -0,0 +1,20 @@ +package com.baeldung.features; + +import java.util.random.RandomGeneratorFactory; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class JEP356 { + + public Stream getAllAlgorithms() { + return RandomGeneratorFactory.all().map(RandomGeneratorFactory::name); + } + + public IntStream getPseudoInts(String algorithm, int streamSize) { + // returns an IntStream with size @streamSize of random numbers generated using the @algorithm + // where the lower bound is 0 and the upper is 100 (exclusive) + return RandomGeneratorFactory.of(algorithm) + .create() + .ints(streamSize, 0,100); + } +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP406.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP406.java new file mode 100644 index 0000000000..2bc3a664d1 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP406.java @@ -0,0 +1,28 @@ +package com.baeldung.features; + +import com.baeldung.features.JEP409.Circle; +import com.baeldung.features.JEP409.Shape; +import com.baeldung.features.JEP409.Triangle; + +public class JEP406 { + + static record Human (String name, int age, String profession) {} + + public String checkObject(Object obj) { + return switch (obj) { + case Human h -> "Name: %s, age: %s and profession: %s".formatted(h.name(), h.age(), h.profession()); + case Circle c -> "This is a circle"; + case Shape s -> "It is just a shape"; + case null -> "It is null"; + default -> "It is an object"; + }; + } + + public String checkShape(Shape shape) { + return switch (shape) { + case Triangle t && (t.getNumberOfSides() != 3) -> "This is a weird triangle"; + case Circle c && (c.getNumberOfSides() != 0) -> "This is a weird circle"; + default -> "Just a normal shape"; + }; + } +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP409.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP409.java new file mode 100644 index 0000000000..0fc3d6f467 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP409.java @@ -0,0 +1,38 @@ +package com.baeldung.features; + +public class JEP409 { + + sealed interface Shape permits Rectangle, Circle, Square, Triangle { + int getNumberOfSides(); + } + + static final class Rectangle implements Shape { + @Override + public int getNumberOfSides() { + return 4; + } + } + + static final class Circle implements Shape { + @Override + public int getNumberOfSides() { + return 0; + } + } + + static final class Square implements Shape { + @Override + public int getNumberOfSides() { + return 4; + } + } + + static non-sealed class Triangle implements Shape { + + @Override + public int getNumberOfSides() { + return 3; + } + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP412.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP412.java new file mode 100644 index 0000000000..8c998629c9 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP412.java @@ -0,0 +1,56 @@ +package com.baeldung.features; + +import jdk.incubator.foreign.CLinker; +import jdk.incubator.foreign.FunctionDescriptor; +import jdk.incubator.foreign.MemoryAddress; +import jdk.incubator.foreign.SymbolLookup; + +import java.io.IOException; +import java.lang.invoke.MethodType; + +import static jdk.incubator.foreign.ResourceScope.newImplicitScope; + +public class JEP412 { + + private static final SymbolLookup libLookup; + + static { + var resource = JEP412.class.getResource("/compile_c.sh"); + try { + var process = new ProcessBuilder("sh", resource.getPath()).start(); + while (process.isAlive()) {} + } catch (IOException ex) { + throw new RuntimeException(ex); + } + + var path = JEP412.class.getResource("/print_name.so").getPath(); + System.load(path); + libLookup = SymbolLookup.loaderLookup(); + } + + public String getPrintNameFormat(String name){ + + var printMethod = libLookup.lookup("printName"); + + if (printMethod.isPresent()) { + var methodReference = CLinker.getInstance() + .downcallHandle( + printMethod.get(), + MethodType.methodType(MemoryAddress.class, MemoryAddress.class), + FunctionDescriptor.of(CLinker.C_POINTER, CLinker.C_POINTER) + ); + + try { + var nativeString = CLinker.toCString(name, newImplicitScope()); + var invokeReturn = methodReference.invoke(nativeString.address()); + var memoryAddress = (MemoryAddress) invokeReturn; + return CLinker.toJavaString(memoryAddress); + } catch (Throwable throwable) { + throw new RuntimeException(throwable); + } + } + throw new RuntimeException("printName function not found."); + } +} + + diff --git a/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP414.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP414.java new file mode 100644 index 0000000000..aaccc4a665 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/com/baeldung/features/JEP414.java @@ -0,0 +1,27 @@ +package com.baeldung.features; + +import jdk.incubator.vector.FloatVector; +import jdk.incubator.vector.VectorSpecies; + +public class JEP414 { + + private static final VectorSpecies SPECIES = FloatVector.SPECIES_PREFERRED; + + + public void newVectorComputation(float[] a, float[] b, float[] c) { + for (var i = 0; i < a.length; i += SPECIES.length()) { + var m = SPECIES.indexInRange(i, a.length); + var va = FloatVector.fromArray(SPECIES, a, i, m); + var vb = FloatVector.fromArray(SPECIES, b, i, m); + var vc = va.mul(vb); + vc.intoArray(c, i, m); + } + } + + public void commonVectorComputation(float[] a, float[] b, float[] c) { + for (var i = 0; i < a.length; i ++) { + c[i] = a[i] * b[i]; + } + } + +} diff --git a/core-java-modules/core-java-17/src/main/java/module-info.java b/core-java-modules/core-java-17/src/main/java/module-info.java new file mode 100644 index 0000000000..b1ce62aa68 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module core.java { + requires jdk.incubator.vector; + requires jdk.incubator.foreign; +} \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/main/resources/compile_c.sh b/core-java-modules/core-java-17/src/main/resources/compile_c.sh new file mode 100755 index 0000000000..d2e0629cc5 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/resources/compile_c.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +gcc -c -fPIC $SCRIPTPATH/print_name.c +gcc -shared -rdynamic -o print_name.so print_name.o + +mv print_name.so $SCRIPTPATH/ +mv print_name.o $SCRIPTPATH/ \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/main/resources/print_name.c b/core-java-modules/core-java-17/src/main/resources/print_name.c new file mode 100644 index 0000000000..7bda12e352 --- /dev/null +++ b/core-java-modules/core-java-17/src/main/resources/print_name.c @@ -0,0 +1,8 @@ +#include +#include + +char* printName(char *name) { + char* newString = (char*)malloc((15 + sizeof(name))*sizeof(char)); + sprintf(newString, "Your name is %s", name); + return newString; +} \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP356UnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP356UnitTest.java new file mode 100644 index 0000000000..b4f61a6f24 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP356UnitTest.java @@ -0,0 +1,19 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class JEP356UnitTest { + + @Test + void getPseudoInts_whenUsingAlgorithmXoroshiro128PlusPlus_shouldReturnStreamOfRandomInteger() { + var algorithm = "Xoshiro256PlusPlus"; + var streamSize = 100; + + JEP356 jep356 = new JEP356(); + + jep356.getPseudoInts(algorithm, streamSize) + .forEach(value -> assertThat(value).isLessThanOrEqualTo(99)); + } +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP406UnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP406UnitTest.java new file mode 100644 index 0000000000..87e6f3bec6 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP406UnitTest.java @@ -0,0 +1,33 @@ +package com.baeldung.features; + +import com.baeldung.features.JEP406.Human; +import com.baeldung.features.JEP409.Square; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class JEP406UnitTest { + + @Test + void checkObject_shouldMatchWithHuman() { + var jep406 = new JEP406(); + + var human = new Human("John", 31, "Developer"); + + var checkResult = jep406.checkObject(human); + + assertEquals("Name: John, age: 31 and profession: Developer", checkResult); + } + + @Test + void checkShape_shouldMatchWithShape() { + var jep406 = new JEP406(); + + var square = new Square(); + + var checkResult = jep406.checkShape(square); + + assertEquals("Just a normal shape", checkResult); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP409UnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP409UnitTest.java new file mode 100644 index 0000000000..41380ec2bb --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP409UnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.features; + +import com.baeldung.features.JEP409.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + +class JEP409UnitTest { + + static class WeirdTriangle extends Triangle { + @Override public int getNumberOfSides() { + return 40; + } + } + + @Test + void testSealedClass_shouldInvokeRightClass() { + + Shape shape = spy(new WeirdTriangle()); + + int numberOfSides = getNumberOfSides(shape); + + assertEquals(40, numberOfSides); + verify(shape).getNumberOfSides(); + } + + int getNumberOfSides(Shape shape) { + return switch (shape) { + case WeirdTriangle t -> t.getNumberOfSides(); + case Circle c -> c.getNumberOfSides(); + case Triangle t -> t.getNumberOfSides(); + case Rectangle r -> r.getNumberOfSides(); + case Square s -> s.getNumberOfSides(); + }; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP412UnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP412UnitTest.java new file mode 100644 index 0000000000..66e7d952c7 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP412UnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class JEP412UnitTest { + + @Test + void getPrintNameFormat_whenPassingAName_shouldReceiveItFormatted() { + var jep412 = new JEP412(); + + var formattedName = jep412.getPrintNameFormat("John"); + + assertEquals("Your name is John", formattedName); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP414UnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP414UnitTest.java new file mode 100644 index 0000000000..459344d907 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/features/JEP414UnitTest.java @@ -0,0 +1,38 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import static java.util.stream.Collectors.toList; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class JEP414UnitTest { + + @Test + void vectorComputation_shouldMultiplyVectors() { + var jep414 = new JEP414(); + + float[] a = initArray(100); + float[] b = initArray(100); + float[] c = new float[100]; + float[] d = new float[100]; + + jep414.newVectorComputation(a, b, c); + jep414.commonVectorComputation(a, b, d); + + for (int i = 0; i < a.length; i++) { + assertEquals(c[i], d[i]); + } + } + + private float[] initArray(int size) { + final var jep356 = new JEP356(); + final var values = new float[size]; + final var pseudoInts = jep356.getPseudoInts("Xoshiro256PlusPlus", size).mapToObj(Float::valueOf).collect(toList()); + + for (int i = 0; i < pseudoInts.size(); i++) { + values[i] = pseudoInts.get(i); + } + + return values; + } +} \ No newline at end of file From 683f3199bb8900860d9ac7fa4e919a1328885f45 Mon Sep 17 00:00:00 2001 From: thomasduxbury <68503838+thomasduxbury@users.noreply.github.com> Date: Sat, 6 Nov 2021 23:56:30 +0000 Subject: [PATCH 126/551] BAEL-5179: Introduction to HexFormat in Java 17 (#11387) --- .../ByteHexadecimalConversionUnitTest.java | 23 +++++++++++ ...tiveTypeHexadecimalConversionUnitTest.java | 22 ++++++++++ .../hexformat/StringFormattingUnitTest.java | 15 +++++++ .../UppercaseLowercaseOutputUnitTest.java | 40 +++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/ByteHexadecimalConversionUnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/PrimitiveTypeHexadecimalConversionUnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/StringFormattingUnitTest.java create mode 100644 core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/UppercaseLowercaseOutputUnitTest.java diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/ByteHexadecimalConversionUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/ByteHexadecimalConversionUnitTest.java new file mode 100644 index 0000000000..29b6eb1bee --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/ByteHexadecimalConversionUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.hexformat; + +import java.util.HexFormat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ByteHexadecimalConversionUnitTest { + + private HexFormat hexFormat = HexFormat.of(); + + @Test + void givenInitialisedHexFormat_whenHexStringIsPassed_thenByteArrayRepresentationIsReturned() { + byte[] hexBytes = hexFormat.parseHex("ABCDEF0123456789"); + assertArrayEquals(new byte[] { -85, -51, -17, 1, 35, 69, 103, -119 }, hexBytes); + } + + @Test + void givenInitialisedHexFormat_whenByteArrayIsPassed_thenHexStringRepresentationIsReturned() { + String bytesAsString = hexFormat.formatHex(new byte[] { -85, -51, -17, 1, 35, 69, 103, -119}); + assertEquals("abcdef0123456789", bytesAsString); + } +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/PrimitiveTypeHexadecimalConversionUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/PrimitiveTypeHexadecimalConversionUnitTest.java new file mode 100644 index 0000000000..6f26a8351c --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/PrimitiveTypeHexadecimalConversionUnitTest.java @@ -0,0 +1,22 @@ +package com.baeldung.hexformat; + +import java.util.HexFormat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PrimitiveTypeHexadecimalConversionUnitTest { + + private HexFormat hexFormat = HexFormat.of(); + + @Test + void givenInitialisedHexFormat_whenPrimitiveByteIsPassed_thenHexStringRepresentationIsReturned() { + String fromByte = hexFormat.toHexDigits((byte)64); + assertEquals("40", fromByte); + } + + @Test + void givenInitialisedHexFormat_whenPrimitiveLongIsPassed_thenHexStringRepresentationIsReturned() { + String fromLong = hexFormat.toHexDigits(1234_5678_9012_3456L); + assertEquals("000462d53c8abac0", fromLong); + } +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/StringFormattingUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/StringFormattingUnitTest.java new file mode 100644 index 0000000000..28189d0e8c --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/StringFormattingUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.hexformat; + +import java.util.HexFormat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class StringFormattingUnitTest { + + private HexFormat hexFormat = HexFormat.of().withPrefix("[").withSuffix("]").withDelimiter(", "); + + @Test + public void givenInitialisedHexFormatWithFormattedStringOptions_whenByteArrayIsPassed_thenHexStringRepresentationFormattedCorrectlyIsReturned() { + assertEquals("[48], [0c], [11]", hexFormat.formatHex(new byte[] {72, 12, 17})); + } +} diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/UppercaseLowercaseOutputUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/UppercaseLowercaseOutputUnitTest.java new file mode 100644 index 0000000000..c2a33fb4b5 --- /dev/null +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/hexformat/UppercaseLowercaseOutputUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.hexformat; + +import java.util.HexFormat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class UppercaseLowercaseOutputUnitTest { + + @Test + public void givenInitialisedHexFormat_whenByteArrayIsPassed_thenLowerCaseHexStringRepresentationIsReturned() { + HexFormat hexFormat = HexFormat.of(); + String bytesAsString = hexFormat.formatHex(new byte[] { -85, -51, -17, 1, 35, 69, 103, -119}); + assertTrue(isLowerCase(bytesAsString)); + } + + @Test + public void givenInitialisedHexFormatWithUpperCaseOption_whenByteArrayIsPassed_thenLowerCaseHexStringRepresentationIsReturned() { + HexFormat hexFormat = HexFormat.of().withUpperCase(); + String bytesAsString = hexFormat.formatHex(new byte[] { -85, -51, -17, 1, 35, 69, 103, -119}); + assertTrue(isUpperCase(bytesAsString)); + } + + private boolean isLowerCase(String str) { + char[] charArray = str.toCharArray(); + for (int i=0; i < charArray.length; i++) { + if (Character.isUpperCase(charArray[i])) + return false; + } + return true; + } + + private boolean isUpperCase(String str) { + char[] charArray = str.toCharArray(); + for (int i=0; i < charArray.length; i++) { + if (Character.isLowerCase(charArray[i])) + return false; + } + return true; + } +} From b0176d85cf875611928eb330e2495bb3a4181fd6 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Sun, 7 Nov 2021 19:14:37 +0530 Subject: [PATCH 127/551] JAVA-1672: removing surefire configurations from parents --- guest/junit5-example/pom.xml | 7 ------- parent-boot-2/pom.xml | 6 ------ parent-java/pom.xml | 13 ------------- parent-spring-4/pom.xml | 10 ---------- parent-spring-5/pom.xml | 13 ------------- persistence-modules/pom.xml | 3 --- pom.xml | 5 ----- spring-web-modules/spring-boot-jsp/pom.xml | 1 - testing-modules/pom.xml | 16 ---------------- 9 files changed, 74 deletions(-) diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml index a88f739891..3bfa72f21f 100644 --- a/guest/junit5-example/pom.xml +++ b/guest/junit5-example/pom.xml @@ -42,13 +42,6 @@ maven-surefire-plugin ${maven-surefire-plugin.version} - - - org.junit.platform - junit-platform-surefire-provider - ${junit-platform-surefire-provider.version} - - math diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index 8e8dbba54d..42081fa115 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -58,11 +58,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - @@ -97,7 +92,6 @@ 1.9.1 3.4.0 - 2.22.2 \ No newline at end of file diff --git a/parent-java/pom.xml b/parent-java/pom.xml index ae6eeb40a9..4e5081393c 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -40,23 +40,10 @@
- - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - 31.0.1-jre 2.3.7 2.2 - 2.22.2 \ No newline at end of file diff --git a/parent-spring-4/pom.xml b/parent-spring-4/pom.xml index 630fa0baf3..a36e1060ed 100644 --- a/parent-spring-4/pom.xml +++ b/parent-spring-4/pom.xml @@ -24,15 +24,6 @@
- - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - org.codehaus.cargo @@ -57,7 +48,6 @@ 4.3.27.RELEASE 1.6.1 - 2.22.2 \ No newline at end of file diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index 01e8671099..1263a56e2b 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -23,23 +23,10 @@
- - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - 5.3.9 5.2.3.RELEASE 1.5.10.RELEASE - 2.22.2 \ No newline at end of file diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index c3df8866b1..4d42ff54cd 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -99,9 +99,6 @@ 5.2.17.Final 42.2.20 - - - 2.22.2 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 855cf54f0a..01b55d48f9 100644 --- a/pom.xml +++ b/pom.xml @@ -113,11 +113,6 @@ - - org.junit.platform - junit-platform-surefire-provider - ${junit-platform-surefire-provider.version} - org.junit.jupiter junit-jupiter-engine diff --git a/spring-web-modules/spring-boot-jsp/pom.xml b/spring-web-modules/spring-boot-jsp/pom.xml index 222facd100..b9b4a97e6b 100644 --- a/spring-web-modules/spring-boot-jsp/pom.xml +++ b/spring-web-modules/spring-boot-jsp/pom.xml @@ -92,7 +92,6 @@ 1.2 2.4.4 - 2.22.2 \ No newline at end of file diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index 079c7fa792..28c743b2b3 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -50,20 +50,4 @@ zerocode - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - 2.22.2 - - \ No newline at end of file From c272dba6658c319eb784f08684c145f81db045bb Mon Sep 17 00:00:00 2001 From: Rafael Lopez Date: Sun, 7 Nov 2021 13:04:54 -0500 Subject: [PATCH 128/551] JAVA-2592: Add DROP TABLE IF EXIST clause to avoid SQL exception --- .../spring-boot-persistence/src/test/resources/dsrouting-db.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql b/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql index c9ca52907a..7449b23307 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql +++ b/persistence-modules/spring-boot-persistence/src/test/resources/dsrouting-db.sql @@ -1,3 +1,5 @@ +drop table if exists client; + create table client ( id numeric, name varchar(50), From d8ba53a958a18eaf093e9a25c66e7acbfa057214 Mon Sep 17 00:00:00 2001 From: rvsathe <38076470+rvsathe@users.noreply.github.com> Date: Mon, 8 Nov 2021 02:45:45 +0530 Subject: [PATCH 129/551] changes for BAEL 5164 (#11364) * BAEL 4293 correcting the unit test file ame. * changes for BAEL 5164 * added maven compiler properties for fixing compilation issues. * making BAEL 5164 java 8 compatible. --- .../core-java-collections-maps-4/pom.xml | 79 +++--- .../com/baeldung/nestedhashmaps/Address.java | 32 +++ .../com/baeldung/nestedhashmaps/Employee.java | 43 ++++ .../com/baeldung/nestedhashmaps/MapsUtil.java | 57 ++++ .../NestedHashMapExamplesClass.java | 118 +++++++++ .../NestedHashMapExamplesClassUnitTest.java | 243 ++++++++++++++++++ 6 files changed, 543 insertions(+), 29 deletions(-) create mode 100644 core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Address.java create mode 100644 core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Employee.java create mode 100644 core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/MapsUtil.java create mode 100644 core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClass.java create mode 100644 core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClassUnitTest.java diff --git a/core-java-modules/core-java-collections-maps-4/pom.xml b/core-java-modules/core-java-collections-maps-4/pom.xml index 1835e3ceac..93ec782c94 100644 --- a/core-java-modules/core-java-collections-maps-4/pom.xml +++ b/core-java-modules/core-java-collections-maps-4/pom.xml @@ -1,34 +1,55 @@ - 4.0.0 - core-java-collections-maps-4 - 0.1.0-SNAPSHOT - core-java-collections-maps-4 - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-collections-maps-4 + 0.1.0-SNAPSHOT + core-java-collections-maps-4 + jar - - com.baeldung.core-java-modules - core-java-modules - 0.0.1-SNAPSHOT - ../pom.xml - + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../pom.xml + + + + UTF-8 + 1.8 + 1.8 + - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - - - !performance - - - - - + + + junit + junit + 4.12 + test + + + org.hamcrest + hamcrest-all + 1.3 + test + + - + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + !performance + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Address.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Address.java new file mode 100644 index 0000000000..410758405e --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Address.java @@ -0,0 +1,32 @@ +package com.baeldung.nestedhashmaps; + +public class Address { + + private Integer addressId; + private String addressLocation; + + public Address() { + } + + public Address(Integer addressId, String addressLocation) { + this.addressId = addressId; + this.addressLocation = addressLocation; + } + + public Integer getAddressId() { + return addressId; + } + + public void setAddressId(Integer addressId) { + this.addressId = addressId; + } + + public String getAddressLocation() { + return addressLocation; + } + + public void setAddressLocation(String addressLocation) { + this.addressLocation = addressLocation; + } + +} diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Employee.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Employee.java new file mode 100644 index 0000000000..2ab54ff17c --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/Employee.java @@ -0,0 +1,43 @@ +package com.baeldung.nestedhashmaps; + +public class Employee { + + private Integer employeeId; + private Address address; + private String employeeName; + + public Employee() { + super(); + } + + public Employee(Integer employeeId, Address address, String employeeName) { + this.employeeId = employeeId; + this.address = address; + this.employeeName = employeeName; + } + + public Integer getEmployeeId() { + return employeeId; + } + + public void setEmployeeId(Integer employeeId) { + this.employeeId = employeeId; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + public String getEmployeeName() { + return employeeName; + } + + public void setEmployeeName(String employeeName) { + this.employeeName = employeeName; + } + +} diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/MapsUtil.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/MapsUtil.java new file mode 100644 index 0000000000..53781b0bc1 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/MapsUtil.java @@ -0,0 +1,57 @@ +package com.baeldung.nestedhashmaps; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +public class MapsUtil { + + MapsUtil() { + super(); + } + + public Map buildInnerMap(List batterList) { + Map innerBatterMap = new HashMap(); + + int index = 1; + for (String item : batterList) { + innerBatterMap.put(index, item); + index++; + } + + return innerBatterMap; + } + + public Map> createNestedMapfromStream(List listEmployee) { + Map> employeeAddressMap = listEmployee.stream() + .collect(Collectors.groupingBy(e -> e.getAddress().getAddressId(), + Collectors.toMap(f -> f.getAddress().getAddressLocation(), Employee::getEmployeeName))); + return employeeAddressMap; + } + + public Map> createNestedObjectMap(List listEmployee) { + Map> employeeMap = new HashMap<>(); + + employeeMap = listEmployee.stream().collect(Collectors.groupingBy((Employee emp) -> emp.getEmployeeId(), + Collectors.toMap((Employee emp) -> emp.getAddress().getAddressId(), fEmpObj -> fEmpObj.getAddress()))); + + return employeeMap; + } + + public Map flattenMap(Map source) { + Map converted = new HashMap<>(); + + for (Entry entry : source.entrySet()) { + if (entry.getValue() instanceof Map) { + flattenMap((Map) entry.getValue()) + .forEach((key, value) -> converted.put(entry.getKey() + "." + key, value)); + } else { + converted.put(entry.getKey().toString(), entry.getValue().toString()); + } + } + return converted; + } + +} diff --git a/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClass.java b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClass.java new file mode 100644 index 0000000000..ce63b72527 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/main/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClass.java @@ -0,0 +1,118 @@ +package com.baeldung.nestedhashmaps; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import java.util.List; + +public class NestedHashMapExamplesClass { + public static void main(String[] args) { + + MapsUtil mUtil = new MapsUtil(); + + List batterList = new ArrayList<>(); + Map> outerBakedGoodsMap = new HashMap<>(); + Map> outerBakedGoodsMap2 = new HashMap<>(); + Map> outerBakedGoodsMap3 = new HashMap<>(); + Map> outerBakedGoodsMap4 = new HashMap<>(); + + batterList.add("Mulberry"); + batterList.add("Cranberry"); + batterList.add("Blackberry"); + batterList.add("Mixed fruit"); + batterList.add("Orange"); + + outerBakedGoodsMap.put("Cake", mUtil.buildInnerMap(batterList)); + + batterList.clear(); + batterList.add("Candy"); + batterList.add("Dark Chocolate"); + batterList.add("Chocolate"); + batterList.add("Jam filled"); + batterList.add("Pineapple"); + + outerBakedGoodsMap.put("Donut", mUtil.buildInnerMap(batterList)); + + outerBakedGoodsMap2.put("Eclair", mUtil.buildInnerMap(batterList)); + outerBakedGoodsMap2.put("Donut", mUtil.buildInnerMap(batterList)); + + outerBakedGoodsMap3.put("Cake", mUtil.buildInnerMap(batterList)); + batterList.clear(); + batterList.add("Banana"); + batterList.add("Red Velvet"); + batterList.add("Blackberry"); + batterList.add("Passion fruit"); + batterList.add("Kiwi"); + + outerBakedGoodsMap3.put("Donut", mUtil.buildInnerMap(batterList)); + + outerBakedGoodsMap4.putAll(outerBakedGoodsMap); + + System.out.println(outerBakedGoodsMap.equals(outerBakedGoodsMap2)); + System.out.println(outerBakedGoodsMap.equals(outerBakedGoodsMap3)); + System.out.println(outerBakedGoodsMap.equals(outerBakedGoodsMap4)); + + outerBakedGoodsMap.get("Cake") + .put(6, "Cranberry"); + System.out.println(outerBakedGoodsMap); + + outerBakedGoodsMap.get("Cake") + .remove(5); + System.out.println(outerBakedGoodsMap); + + outerBakedGoodsMap.put("Eclair", new HashMap() { + { + put(1, "Dark Chocolate"); + } + }); + + System.out.println(outerBakedGoodsMap); + outerBakedGoodsMap.remove("Eclair"); + System.out.println(outerBakedGoodsMap); + System.out.println("Baked Goods Map Flattened: " + mUtil.flattenMap(outerBakedGoodsMap)); + + // Employees Map + List listEmployee = new ArrayList(); + + listEmployee.add(new Employee(1, new Address(124, "Timbuktoo"), "Thorin Oakenshield")); + listEmployee.add(new Employee(2, new Address(100, "Misty Lanes"), "Balin")); + listEmployee.add(new Employee(3, new Address(156, "Bramles Lane"), "Bofur")); + listEmployee.add(new Employee(4, new Address(200, "Bag End"), "Bilbo Baggins")); + listEmployee.add(new Employee(5, new Address(23, "Rivendell"), "Elrond")); + + Map> employeeAddressMap = mUtil.createNestedMapfromStream(listEmployee); + + Map> employeeMap = mUtil.createNestedObjectMap(listEmployee); + Map> employeeMap2 = mUtil.createNestedObjectMap(listEmployee); + + listEmployee.clear(); + listEmployee.add(new Employee(1, new Address(500, "Timbuktoo"), "Thorin Oakenshield")); + listEmployee.add(new Employee(2, new Address(600, "Misty Lanes"), "Balin")); + listEmployee.add(new Employee(3, new Address(700, "Bramles Lane"), "Bofur")); + listEmployee.add(new Employee(4, new Address(800, "Bag End"), "Bilbo Baggins")); + listEmployee.add(new Employee(5, new Address(900, "Rivendell"), "Elrond")); + + Map> employeeAddressMap1 = mUtil.createNestedMapfromStream(listEmployee); + + Map> employeeMap1 = mUtil.createNestedObjectMap(listEmployee); + + System.out.println(employeeMap.equals(employeeMap1)); + System.out.println(employeeMap.equals(employeeMap2)); + + for (Map.Entry> outerBakedGoodsMapEntrySet : outerBakedGoodsMap.entrySet()) { + Map valueMap = outerBakedGoodsMapEntrySet.getValue(); + System.out.println(valueMap.entrySet()); + } + + for (Map.Entry> employeeEntrySet : employeeAddressMap.entrySet()) { + Map valueMap = employeeEntrySet.getValue(); + System.out.println(valueMap.entrySet()); + } + + System.out.println("Employee Address Map Flattened: " + mUtil.flattenMap(employeeAddressMap)); + + System.out.println(employeeAddressMap.equals(employeeAddressMap1)); + } + +} diff --git a/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClassUnitTest.java b/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClassUnitTest.java new file mode 100644 index 0000000000..a86e329bea --- /dev/null +++ b/core-java-modules/core-java-collections-maps-4/src/test/java/com/baeldung/nestedhashmaps/NestedHashMapExamplesClassUnitTest.java @@ -0,0 +1,243 @@ +package com.baeldung.nestedhashmaps; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertThat; +import org.hamcrest.collection.IsMapContaining; + +public class NestedHashMapExamplesClassUnitTest { + private MapsUtil mUtil = new MapsUtil(); + private List batterList = new ArrayList<>(); + private List listEmployee = new ArrayList(); + private Map> actualBakedGoodsMap = new HashMap<>(); + private Map> actualEmployeeAddressMap = new HashMap<>(); + private Map> actualEmployeeMap = new HashMap<>(); + + @Test + public void whenCreateNestedHashMap_thenNestedMap() { + assertThat(mUtil.buildInnerMap(batterList), is(notNullValue())); + Assert.assertEquals(actualBakedGoodsMap.keySet().size(), 2); + Assert.assertThat(actualBakedGoodsMap, IsMapContaining.hasValue(equalTo(mUtil.buildInnerMap(batterList)))); + } + + private Map> setup() { + Map> expectedMap = new HashMap<>(); + expectedMap.put(Integer.valueOf(100), new HashMap() { + { + put("Misty Lanes", "Balin"); + } + }); + expectedMap.put(Integer.valueOf(200), new HashMap() { + { + put("Bag End", "Bilbo Baggins"); + } + }); + expectedMap.put(Integer.valueOf(156), new HashMap() { + { + put("Brambles Lane", "Bofur"); + } + }); + expectedMap.put(Integer.valueOf(124), new HashMap() { + { + put("Timbuktoo", "Thorin Oakenshield"); + } + }); + expectedMap.put(Integer.valueOf(23), new HashMap() { + { + put("Rivendell", "Elrond"); + } + }); + + return expectedMap; + } + + @Test + public void whenCreateNestedHashMapwithStreams_thenNestedMap() { + + Map> expectedMap = setup(); + + assertThat(actualEmployeeAddressMap, equalTo(expectedMap)); + } + + @Test + public void whenCompareTwoHashMapswithDifferenctValues_usingEquals_thenFail() { + Map> outerBakedGoodsMap2 = new HashMap<>(); + outerBakedGoodsMap2.put("Eclair", mUtil.buildInnerMap(batterList)); + outerBakedGoodsMap2.put("Donut", mUtil.buildInnerMap(batterList)); + assertNotEquals(outerBakedGoodsMap2, actualBakedGoodsMap); + + Map> outerBakedGoodsMap3 = new HashMap>(); + outerBakedGoodsMap3.put("Cake", mUtil.buildInnerMap(batterList)); + batterList = new ArrayList<>(); + batterList = Arrays.asList("Banana", "Red Velvet", "Blackberry", "Passion fruit", "Kiwi"); + + outerBakedGoodsMap3.put("Donut", mUtil.buildInnerMap(batterList)); + + assertNotEquals(outerBakedGoodsMap2, actualBakedGoodsMap); + + listEmployee.clear(); + listEmployee.add(new Employee(1, new Address(500, "Timbuktoo"), "Thorin Oakenshield")); + listEmployee.add(new Employee(2, new Address(600, "Misty Lanes"), "Balin")); + listEmployee.add(new Employee(3, new Address(700, "Bramles Lane"), "Bofur")); + listEmployee.add(new Employee(4, new Address(800, "Bag End"), "Bilbo Baggins")); + listEmployee.add(new Employee(5, new Address(900, "Rivendell"), "Elrond")); + + Map> employeeAddressMap1 = mUtil.createNestedMapfromStream(listEmployee); + + Map> employeeMap1 = mUtil.createNestedObjectMap(listEmployee); + + assertNotEquals(employeeAddressMap1, actualEmployeeAddressMap); + + assertNotEquals(employeeMap1, actualEmployeeMap); + } + + @Test + public void whencomparingDifferentObjectValuesUsingEquals_thenFail() { + listEmployee.clear(); + listEmployee.add(new Employee(1, new Address(124, "Timbuktoo"), "Thorin Oakenshield")); + listEmployee.add(new Employee(2, new Address(100, "Misty Lanes"), "Balin")); + listEmployee.add(new Employee(3, new Address(156, "Brambles Lane"), "Bofur")); + listEmployee.add(new Employee(4, new Address(200, "Bag End"), "Bilbo Baggins")); + listEmployee.add(new Employee(5, new Address(23, "Rivendell"), "Elrond")); + + Map> employeeMap1 = listEmployee.stream().collect(Collectors.groupingBy( + (Employee emp) -> emp.getEmployeeId(), + Collectors.toMap((Employee emp) -> emp.getAddress().getAddressId(), fEmpObj -> fEmpObj.getAddress()))); + + assertNotSame(employeeMap1, actualEmployeeMap); + assertNotEquals(employeeMap1, actualEmployeeMap); + + Map> expectedMap = setupAddressObjectMap(); + assertNotSame(expectedMap, actualEmployeeMap); + assertNotEquals(expectedMap, actualEmployeeMap); + + } + + @Test + public void whenCompareTwoHashMapsUsingEquals_thenSuccess() { + Map> outerBakedGoodsMap4 = new HashMap<>(); + outerBakedGoodsMap4.putAll(actualBakedGoodsMap); + + assertEquals(actualBakedGoodsMap, outerBakedGoodsMap4); + + Map> employeeMap1 = new HashMap<>(); + employeeMap1.putAll(actualEmployeeMap); + assertEquals(actualEmployeeMap, employeeMap1); + } + + @Test + public void whenAddElementinHashMaps_thenSuccess() { + assertEquals(actualBakedGoodsMap.get("Cake").size(), 5); + actualBakedGoodsMap.get("Cake").put(6, "Cranberry"); + assertEquals(actualBakedGoodsMap.get("Cake").size(), 6); + } + + @Test + public void whenDeleteElementinHashMaps_thenSuccess() { + assertNotEquals(actualBakedGoodsMap.get("Cake").get(5), null); + actualBakedGoodsMap.get("Cake").remove(5); + assertEquals(actualBakedGoodsMap.get("Cake").get(5), null); + + actualBakedGoodsMap.put("Eclair", new HashMap() { + { + put(1, "Dark Chocolate"); + } + }); + + assertNotEquals(actualBakedGoodsMap.get("Eclair").get(1), null); + actualBakedGoodsMap.get("Eclair").remove(1); + assertEquals(actualBakedGoodsMap.get("Eclair").get(1), null); + + actualBakedGoodsMap.put("Eclair", new HashMap() { + { + put(1, "Dark Chocolate"); + } + }); + + assertNotEquals(actualBakedGoodsMap.get("Eclair"), null); + actualBakedGoodsMap.remove("Eclair"); + assertEquals(actualBakedGoodsMap.get("Eclair"), null); + } + + @Test + public void whenFlattenMap_thenRemovesNesting() { + + Map flattenedBakedGoodsMap = mUtil.flattenMap(actualBakedGoodsMap); + assertThat(flattenedBakedGoodsMap, IsMapContaining.hasKey("Donut.2")); + + Map flattenedEmployeeAddressMap = mUtil.flattenMap(actualEmployeeAddressMap); + assertThat(flattenedEmployeeAddressMap, IsMapContaining.hasKey("200.Bag End")); + } + + @Before + public void buildMaps() { + + batterList = Arrays.asList("Mulberry", "Cranberry", "Blackberry", "Mixed fruit", "Orange"); + + actualBakedGoodsMap.put("Cake", mUtil.buildInnerMap(batterList)); + + batterList = new ArrayList<>(); + batterList = Arrays.asList("Candy", "Dark Chocolate", "Chocolate", "Jam filled", "Pineapple"); + + actualBakedGoodsMap.put("Donut", mUtil.buildInnerMap(batterList)); + + listEmployee.add(new Employee(1, new Address(124, "Timbuktoo"), "Thorin Oakenshield")); + listEmployee.add(new Employee(2, new Address(100, "Misty Lanes"), "Balin")); + listEmployee.add(new Employee(3, new Address(156, "Brambles Lane"), "Bofur")); + listEmployee.add(new Employee(4, new Address(200, "Bag End"), "Bilbo Baggins")); + listEmployee.add(new Employee(5, new Address(23, "Rivendell"), "Elrond")); + + actualEmployeeAddressMap = mUtil.createNestedMapfromStream(listEmployee); + + actualEmployeeMap = mUtil.createNestedObjectMap(listEmployee); + + } + + private Map> setupAddressObjectMap() { + + Map> expectedMap = new HashMap<>(); + + expectedMap.put(1, new HashMap() { + { + put(124, new Address(124, "Timbuktoo")); + } + }); + expectedMap.put(2, new HashMap() { + { + put(100, new Address(100, "Misty Lanes")); + } + }); + expectedMap.put(3, new HashMap() { + { + put(156, new Address(156, "Brambles Lane")); + } + }); + expectedMap.put(4, new HashMap() { + { + put(200, new Address(200, "Bag End")); + } + }); + expectedMap.put(5, new HashMap() { + { + put(23, new Address(23, "Rivendell")); + } + }); + return expectedMap; + } + +} From f200ce5b143e605f729941c97cf321c730d09382 Mon Sep 17 00:00:00 2001 From: Teica Date: Sun, 7 Nov 2021 22:19:54 +0100 Subject: [PATCH 130/551] BAEL-5227 check if a first letter of a string is uppercase (#11424) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BAEL-5227 check if the first letter of a string is uppercase * BAEL-5227 renaming the tests * BAEL-5227 renaming the tests * BAEL-5227 renaming the tests Co-authored-by: Matea Pejčinović --- .../StringFirstCharacterUppercase.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java diff --git a/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java b/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java new file mode 100644 index 0000000000..0d9d3b6431 --- /dev/null +++ b/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java @@ -0,0 +1,32 @@ +package com.baeldung.isuppercase; + +import com.google.common.base.Ascii; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class StringFirstCharacterUppercase { + + @Test + public void givenString_whenCheckingWithCharacterIsUpperCase_thenStringCapitalized() { + String example = "Katie"; + Assertions.assertTrue(Character.isUpperCase(example.charAt(0))); + } + + @Test + public void givenString_whenCheckingWithRegex_thenStringCapitalized() { + String example = "Katie"; + String regEx = "[A-Z]\\w*"; + assertThat(example, matchesPattern(regEx)); + } + + @Test + public void givenString_whenCheckingWithGuava_thenStringCapitalized() { + String example = "Katie"; + Assertions.assertTrue(Ascii.isUpperCase(example.charAt(0))); + } +} From 4a3a73111f6b5afa60d04a78b142b770afb31014 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Mon, 8 Nov 2021 13:41:04 +0530 Subject: [PATCH 131/551] JAVA-1672: removing redundant version declarations for surefire plugin --- guest/junit5-example/pom.xml | 2 +- spring-ejb/ejb-beans/pom.xml | 1 - spring-jenkins-pipeline/pom.xml | 1 + spring-security-modules/spring-ldap/pom.xml | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml index 3bfa72f21f..cc52b0e3d7 100644 --- a/guest/junit5-example/pom.xml +++ b/guest/junit5-example/pom.xml @@ -40,8 +40,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} math diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index 8a41da5448..6f20d949b0 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -135,7 +135,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} always diff --git a/spring-jenkins-pipeline/pom.xml b/spring-jenkins-pipeline/pom.xml index 6f00dd5820..4e84bb8c70 100644 --- a/spring-jenkins-pipeline/pom.xml +++ b/spring-jenkins-pipeline/pom.xml @@ -62,6 +62,7 @@ + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-security-modules/spring-ldap/pom.xml b/spring-security-modules/spring-ldap/pom.xml index 44f754673f..086be2df5a 100644 --- a/spring-security-modules/spring-ldap/pom.xml +++ b/spring-security-modules/spring-ldap/pom.xml @@ -106,7 +106,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} integration-test From 1d328e79d353a714cabbc7ea754ac8262c5141b7 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Mon, 8 Nov 2021 13:45:41 +0530 Subject: [PATCH 132/551] JAVA-1672: removing redundant junit dependencies --- core-java-modules/core-java-17/pom.xml | 12 ------------ .../core-java-collections-maps-4/pom.xml | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml index e422bd62bb..b1811ecf7f 100644 --- a/core-java-modules/core-java-17/pom.xml +++ b/core-java-modules/core-java-17/pom.xml @@ -23,18 +23,6 @@ ${assertj.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - diff --git a/core-java-modules/core-java-collections-maps-4/pom.xml b/core-java-modules/core-java-collections-maps-4/pom.xml index 93ec782c94..2109804ff0 100644 --- a/core-java-modules/core-java-collections-maps-4/pom.xml +++ b/core-java-modules/core-java-collections-maps-4/pom.xml @@ -25,13 +25,13 @@ junit junit - 4.12 + ${junit.version} test org.hamcrest hamcrest-all - 1.3 + ${hamcrest-all.version} test
From 82572378b20ab4f3fb09bd13ef15e61562a0968d Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Mon, 8 Nov 2021 09:01:53 +0000 Subject: [PATCH 133/551] [BAEL-5110] Actuator endpoint for startup tracking (#11351) --- .../baeldung/startup/ResourceInitializer.java | 17 +++++++++ .../startup/StartupTrackingApplication.java | 38 +++++++++++++++++++ .../resources/application-startup.properties | 6 +++ 3 files changed, 61 insertions(+) create mode 100644 spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/ResourceInitializer.java create mode 100644 spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/StartupTrackingApplication.java create mode 100644 spring-boot-modules/spring-boot-actuator/src/main/resources/application-startup.properties diff --git a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/ResourceInitializer.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/ResourceInitializer.java new file mode 100644 index 0000000000..e50816821c --- /dev/null +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/ResourceInitializer.java @@ -0,0 +1,17 @@ +package com.baeldung.startup; + +import org.springframework.stereotype.Component; + +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; + +@Component +public class ResourceInitializer { + + ResourceInitializer() throws Exception { + // simulate resource init with random delay of a few seconds + int randomDelay = ThreadLocalRandom.current().nextInt(5, 9); + TimeUnit.SECONDS.sleep(randomDelay); + } + +} diff --git a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/StartupTrackingApplication.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/StartupTrackingApplication.java new file mode 100644 index 0000000000..a3762cb98e --- /dev/null +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/startup/StartupTrackingApplication.java @@ -0,0 +1,38 @@ +package com.baeldung.startup; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; + +import static java.lang.Boolean.FALSE; + +@SpringBootApplication(exclude = { + SecurityAutoConfiguration.class, + ManagementWebSecurityAutoConfiguration.class} +) +public class StartupTrackingApplication { + + public static void main(String[] args) { + // only load properties for this application + System.setProperty("spring.config.location", "classpath:application-startup.properties"); + + SpringApplication app = new SpringApplication(StartupTrackingApplication.class); + BufferingApplicationStartup startup = new BufferingApplicationStartup(2048); + + if (shouldFilterSteps()) { + startup.addFilter(startupStep -> startupStep.getName().matches("spring.beans.instantiate")); + } + + app.setApplicationStartup(startup); + app.run(args); + } + + private static boolean shouldFilterSteps() { + return Boolean.parseBoolean( + System.getProperty("startup.steps.filter", FALSE.toString()) + ); + } + +} diff --git a/spring-boot-modules/spring-boot-actuator/src/main/resources/application-startup.properties b/spring-boot-modules/spring-boot-actuator/src/main/resources/application-startup.properties new file mode 100644 index 0000000000..4cb5f2a94d --- /dev/null +++ b/spring-boot-modules/spring-boot-actuator/src/main/resources/application-startup.properties @@ -0,0 +1,6 @@ +management.endpoints.web.exposure.include=startup + +# JPA is not required for startup actuator endpoint +spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, \ + org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, \ + org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration From 3ab032d0951c0cb11c73a96929ba2a9f23e85195 Mon Sep 17 00:00:00 2001 From: vaibhav007jain <72961247+vaibhav007jain@users.noreply.github.com> Date: Mon, 8 Nov 2021 18:05:17 +0530 Subject: [PATCH 134/551] BAEL-5151 (#11385) * commited initial code for hexagonal architecture * Deleting to check in again * Deleing to check in again * Push first code for Hexagonal Architecture * final code with UT for JSON to Java conversion * removed hexagonal-architecture code from last commit * BEL-5071 updated README * BAEL-5071: Undo README changes and added a nested object in the JSON example. * BAEL-5071: fixed whitespace/indentation in JsonToJavaClassConversion.java * BAEL-5151: Added code for getting the first of a String * BAEL-5151: Renamed Unit Test * BAEL-5151: Moved the files from core-java-string-operations to core-java-string-operations-3 * BAEL-5151: Replaced tabs with white spaces. Co-authored-by: Vaibhav Jain --- .../baeldung/firstword/FirstWordGetter.java | 20 +++++++++++++ .../firstword/FirstWordGetterUnitTest.java | 30 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/firstword/FirstWordGetter.java create mode 100644 core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/firstword/FirstWordGetterUnitTest.java diff --git a/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/firstword/FirstWordGetter.java b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/firstword/FirstWordGetter.java new file mode 100644 index 0000000000..03c134752a --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/main/java/com/baeldung/firstword/FirstWordGetter.java @@ -0,0 +1,20 @@ +package com.baeldung.firstword; + +public class FirstWordGetter { + + public static void main(String[] args) { + String input = "Roberto \"I wish you a bug-free day\""; + System.out.println("Using split: " + getFirstWordUsingSplit(input)); + System.out.println("Using subString: " + getFirstWordUsingSubString(input)); + } + + public static String getFirstWordUsingSubString(String input) { + int index = input.contains(" ") ? input.indexOf(" ") : 0; + return input.substring(0, index); + } + + public static String getFirstWordUsingSplit(String input) { + String[] tokens = input.split(" ", 2); + return tokens[0]; + } +} diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/firstword/FirstWordGetterUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/firstword/FirstWordGetterUnitTest.java new file mode 100644 index 0000000000..bdaa25180e --- /dev/null +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/firstword/FirstWordGetterUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.firstword; + +import static com.baeldung.firstword.FirstWordGetter.getFirstWordUsingSplit; +import static com.baeldung.firstword.FirstWordGetter.getFirstWordUsingSubString; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class FirstWordGetterUnitTest { + + @Test + public void givenString_whenSplit_thenFirstWordIsReturned() { + assertEquals("Roberto", getFirstWordUsingSplit("Roberto \"I wish you a bug-free day\"")); + } + + @Test + public void givenStringWithNoSpace_whenSplit_thenFirstWordIsReturned() { + assertEquals("StringWithNoSpace", getFirstWordUsingSplit("StringWithNoSpace")); + } + + @Test + public void givenString_whenPassedToSubstring_thenFirstWordIsReturned() { + assertEquals("Roberto", getFirstWordUsingSubString("Roberto \"I wish you a bug-free day\"")); + } + + @Test + public void givenStringWithNoSpace_whenPassedToSubstring_thenFirstWordIsReturned() { + assertEquals("", getFirstWordUsingSubString("StringWithNoSpace")); + } +} From 19437f2e13555d701d79d58561590e9815aa59e1 Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Mon, 8 Nov 2021 17:06:17 +0100 Subject: [PATCH 135/551] Spring Webflux and @Cacheable Annotation --- pom.xml | 3 + spring-webflux-caching/pom.xml | 67 +++++++++++++ .../main/java/com/baeldung/caching/Item.java | 50 ++++++++++ .../com/baeldung/caching/ItemRepository.java | 8 ++ .../com/baeldung/caching/ItemService.java | 42 ++++++++ .../SpringWebfluxCachingApplication.java | 16 ++++ .../src/main/resources/application.properties | 2 + .../MonoFluxResultCachingLiveTest.java | 95 +++++++++++++++++++ 8 files changed, 283 insertions(+) create mode 100644 spring-webflux-caching/pom.xml create mode 100644 spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java create mode 100644 spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java create mode 100644 spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java create mode 100644 spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java create mode 100644 spring-webflux-caching/src/main/resources/application.properties create mode 100644 spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java diff --git a/pom.xml b/pom.xml index f2a53f38b7..9a34ed0afe 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,9 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + + spring-webflux-caching + parent-modules pom diff --git a/spring-webflux-caching/pom.xml b/spring-webflux-caching/pom.xml new file mode 100644 index 0000000000..ed9800bce9 --- /dev/null +++ b/spring-webflux-caching/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + com.baeldung.spring + spring-webflux-caching + 1.0.0-SNAPSHOT + spring-webflux-caching + jar + Spring WebFlux Caching Sample + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + + org.springframework.boot + spring-boot-starter-webflux + + + io.reactivex.rxjava2 + rxjava + 2.2.19 + + + io.projectreactor.addons + reactor-extra + 3.4.5 + + + com.github.ben-manes.caffeine + caffeine + 3.0.4 + + + org.springframework.boot + spring-boot-starter-data-mongodb-reactive + + + com.fasterxml.jackson.core + jackson-databind + + + org.springframework.boot + spring-boot-starter-test + test + + + io.projectreactor + reactor-test + test + + + org.testcontainers + mongodb + 1.16.2 + test + + + + \ No newline at end of file diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java b/spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java new file mode 100644 index 0000000000..127975b0e7 --- /dev/null +++ b/spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java @@ -0,0 +1,50 @@ +package com.baeldung.caching; + +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +@Document +public class Item { + + @Id + private String _id; + private String name; + private double price; + + public Item(String name, double price) { + this.name = name; + this.price = price; + } + + public Item() { + } + + public String get_id() { + return _id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + @Override + public String toString() { + return "Item{" + + "id='" + _id + '\'' + + ", name='" + name + '\'' + + ", price=" + price + + '}'; + } +} diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java b/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java new file mode 100644 index 0000000000..a76489623e --- /dev/null +++ b/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.caching; + +import org.springframework.data.mongodb.repository.ReactiveMongoRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ItemRepository extends ReactiveMongoRepository { +} diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java b/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java new file mode 100644 index 0000000000..9dc9ba1642 --- /dev/null +++ b/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java @@ -0,0 +1,42 @@ +package com.baeldung.caching; + +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import reactor.cache.CacheMono; +import reactor.core.publisher.Mono; + +@Service +public class ItemService { + + private final ItemRepository repository; + private final LoadingCache cache; + + public ItemService(ItemRepository repository) { + this.repository = repository; + this.cache = Caffeine.newBuilder() + .build(this::getItem_withAddons); + } + + @Cacheable("items") + public Mono getItem(String id) { + return repository.findById(id); + } + + public Mono save(Item item) { + return repository.save(item); + } + + @Cacheable("items") + public Mono getItem_withCache(String id) { + return repository.findById(id).cache(); + } + + @Cacheable("items") + public Mono getItem_withAddons(String id) { + return CacheMono.lookup(cache.asMap(), id) + .onCacheMissResume(() -> repository.findById(id).cast(Object.class)).cast(Item.class); + } + +} diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java b/spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java new file mode 100644 index 0000000000..7331576bd5 --- /dev/null +++ b/spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java @@ -0,0 +1,16 @@ +package com.baeldung.caching; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +@SpringBootApplication +@EnableMongoRepositories +@EnableCaching +public class SpringWebfluxCachingApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringWebfluxCachingApplication.class, args); + } +} diff --git a/spring-webflux-caching/src/main/resources/application.properties b/spring-webflux-caching/src/main/resources/application.properties new file mode 100644 index 0000000000..23414da2dd --- /dev/null +++ b/spring-webflux-caching/src/main/resources/application.properties @@ -0,0 +1,2 @@ +logging.level.org.springframework.data.mongodb.core.ReactiveMongoTemplate=DEBUG +logging.level.org.springframework.cache=TRACE \ No newline at end of file diff --git a/spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java b/spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java new file mode 100644 index 0000000000..bf96b35dcb --- /dev/null +++ b/spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java @@ -0,0 +1,95 @@ +package com.baeldung.caching; + + +import org.assertj.core.api.Assertions; +import org.junit.ClassRule; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.testcontainers.containers.MongoDBContainer; +import org.testcontainers.utility.DockerImageName; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +public class MonoFluxResultCachingLiveTest { + + + @Autowired + ItemService itemService; + + final static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")); + + @DynamicPropertySource + static void mongoDbProperties(DynamicPropertyRegistry registry) { + mongoDBContainer.start(); + registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl); + } + +@Test +public void givenItem_whenGetItemIsCalled_thenMonoIsCached() { + Mono glass = itemService.save(new Item("glass", 1.00)); + + String id = glass.block().get_id(); + + Mono mono = itemService.getItem(id); + Item item = mono.block(); + + assertThat(item).isNotNull(); + assertThat(item.getName()).isEqualTo("glass"); + assertThat(item.getPrice()).isEqualTo(1.00); + + Mono mono2 = itemService.getItem(id); + Item item2 = mono2.block(); + + assertThat(item2).isNotNull(); + assertThat(item2.getName()).isEqualTo("glass"); + assertThat(item2.getPrice()).isEqualTo(1.00); +} + + @Test + public void givenItem_whenGetItemWithCacheIsCalled_thenMonoResultIsCached() { + Mono glass = itemService.save(new Item("glass", 1.00)); + + String id = glass.block().get_id(); + + Mono mono = itemService.getItem_withCache(id); + Item item = mono.block(); + + assertThat(item).isNotNull(); + assertThat(item.getName()).isEqualTo("glass"); + assertThat(item.getPrice()).isEqualTo(1.00); + + Mono mono2 = itemService.getItem_withCache(id); + Item item2 = mono2.block(); + + assertThat(item2).isNotNull(); + assertThat(item2.getName()).isEqualTo("glass"); + assertThat(item2.getPrice()).isEqualTo(1.00); + } + + @Test + public void givenItem_whenGetItemWithAddonsIsCalled_thenMonoResultIsCached() { + Mono glass = itemService.save(new Item("glass", 1.00)); + + String id = glass.block().get_id(); + + Mono mono = itemService.getItem_withAddons(id); + Item item = mono.block(); + + assertThat(item).isNotNull(); + assertThat(item.getName()).isEqualTo("glass"); + assertThat(item.getPrice()).isEqualTo(1.00); + + Mono mono2 = itemService.getItem_withAddons(id); + Item item2 = mono2.block(); + + assertThat(item2).isNotNull(); + assertThat(item2.getName()).isEqualTo("glass"); + assertThat(item2.getPrice()).isEqualTo(1.00); + } + +} From 20ceab44ebe1f980897bfe94b40239501b257ea3 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Mon, 8 Nov 2021 21:45:18 +0530 Subject: [PATCH 136/551] JAVA-1672: updating surefire version in jhipster --- jhipster/jhipster-uaa/gateway/pom.xml | 1 - jhipster/jhipster-uaa/quotes/pom.xml | 1 - jhipster/jhipster-uaa/uaa/pom.xml | 1 - 3 files changed, 3 deletions(-) diff --git a/jhipster/jhipster-uaa/gateway/pom.xml b/jhipster/jhipster-uaa/gateway/pom.xml index bc3c9bdef2..536b847237 100644 --- a/jhipster/jhipster-uaa/gateway/pom.xml +++ b/jhipster/jhipster-uaa/gateway/pom.xml @@ -1054,7 +1054,6 @@ 2.10 3.0.0-M2 3.1.0 - 2.22.0 3.2.2 0.9.11 1.6 diff --git a/jhipster/jhipster-uaa/quotes/pom.xml b/jhipster/jhipster-uaa/quotes/pom.xml index 7e4252b309..d922be10c2 100644 --- a/jhipster/jhipster-uaa/quotes/pom.xml +++ b/jhipster/jhipster-uaa/quotes/pom.xml @@ -874,7 +874,6 @@ 2.10 3.0.0-M2 3.1.0 - 2.22.0 3.2.2 0.9.11 0.8.2 diff --git a/jhipster/jhipster-uaa/uaa/pom.xml b/jhipster/jhipster-uaa/uaa/pom.xml index ec4dc1b484..a43da9c366 100644 --- a/jhipster/jhipster-uaa/uaa/pom.xml +++ b/jhipster/jhipster-uaa/uaa/pom.xml @@ -875,7 +875,6 @@ 2.10 3.0.0-M2 3.1.0 - 2.22.0 3.2.2 0.9.11 0.8.2 From 4786fb5cf64e1b231e0a008094d46911bbd7387a Mon Sep 17 00:00:00 2001 From: Trying something new <50325284+tancafa@users.noreply.github.com> Date: Tue, 9 Nov 2021 07:04:49 +0530 Subject: [PATCH 137/551] BAEL 4486 (#11353) * BAEL 4486 Adding 2 files for BAEL 4486 * JAVA-4486, unit tests Added Unit Test Corrected the formatting using formatter.xml in eclipse * BAEL - 4486 Renamed CrytoDriverIVTest.java to CryptoDriverIVTest.java added core-security-3 module to pom.xml * Update CryptoDriverIVUnitTest.java Resubmitting CryptoDriverIVUnitTest * BAEL - 4486 Removed Blank lines from CryptoDriver.java --- .../com/baeldung/crypto/CryptoDriver.java | 86 +++++++++++++++++++ .../baeldung/crypto/utils/CryptoUtils.java | 53 ++++++++++++ .../crypto/CryptoDriverIVUnitTest.java | 86 +++++++++++++++++++ core-java-modules/pom.xml | 1 + 4 files changed, 226 insertions(+) create mode 100644 core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/CryptoDriver.java create mode 100644 core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/utils/CryptoUtils.java create mode 100644 core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/CryptoDriverIVUnitTest.java diff --git a/core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/CryptoDriver.java b/core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/CryptoDriver.java new file mode 100644 index 0000000000..552bd5d474 --- /dev/null +++ b/core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/CryptoDriver.java @@ -0,0 +1,86 @@ +package com.baeldung.crypto; + +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.IvParameterSpec; +import java.security.GeneralSecurityException; + +import com.baeldung.crypto.utils.CryptoUtils; + +public class CryptoDriver { + + public byte[] ecbEncrypt(SecretKey key, byte[] data) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(data); + } + + public byte[] ecbDecrypt(SecretKey key, byte[] cipherText) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(cipherText); + } + + public byte[] cbcEncrypt(SecretKey key, IvParameterSpec iv, byte[] data) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + return cipher.doFinal(data); + } + + public byte[] cbcDecrypt(SecretKey key, IvParameterSpec iv, byte[] cipherText) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + return cipher.doFinal(cipherText); + } + + public byte[] cfbEncrypt(SecretKey key, IvParameterSpec iv, byte[] data) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/CFB/NoPadding"); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + return cipher.doFinal(data); + } + + public byte[] cfbDecrypt(SecretKey key, IvParameterSpec iv, byte[] cipherText) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/CFB/NoPadding"); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + return cipher.doFinal(cipherText); + } + + public byte[] ofbEncrypt(SecretKey key, IvParameterSpec iv, byte[] data) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/OFB32/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + return cipher.doFinal(data); + } + + public byte[] ofbDecrypt(SecretKey key, IvParameterSpec iv, byte[] cipherText) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/OFB32/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + return cipher.doFinal(cipherText); + } + + public byte[][] ctrEncrypt(SecretKey key, IvParameterSpec iv, byte[] data) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + return new byte[][] { cipher.getIV(), cipher.doFinal(data) }; + } + + public byte[] ctrDecrypt(SecretKey key, byte[] iv, byte[] cipherText) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); + cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv)); + return cipher.doFinal(cipherText); + } + + public byte[][] gcmEncrypt(SecretKey key, byte[] iv, byte[] data) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); + cipher.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(128, iv)); + byte[] ciphertext = cipher.doFinal(data); + return new byte[][] { iv, ciphertext }; + } + + public byte[] gcmDecrypt(SecretKey key, byte[] iv, byte[] ciphertext) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); + cipher.init(Cipher.DECRYPT_MODE, key, new GCMParameterSpec(128, iv)); + byte[] plaintext = cipher.doFinal(ciphertext); + return plaintext; + } +} diff --git a/core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/utils/CryptoUtils.java b/core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/utils/CryptoUtils.java new file mode 100644 index 0000000000..2d3df231ff --- /dev/null +++ b/core-java-modules/core-java-security-3/src/main/java/com/baeldung/crypto/utils/CryptoUtils.java @@ -0,0 +1,53 @@ +package com.baeldung.crypto.utils; + +import java.security.AlgorithmParameters; +import java.security.GeneralSecurityException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.spec.InvalidParameterSpecException; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; + +public class CryptoUtils { + + public static SecretKey generateKey() throws GeneralSecurityException { + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + keyGenerator.init(256); + return keyGenerator.generateKey(); + } + + public static IvParameterSpec getIV() { + SecureRandom secureRandom = new SecureRandom(); + byte[] iv = new byte[128 / 8]; + byte[] nonce = new byte[96 / 8]; + secureRandom.nextBytes(nonce); + System.arraycopy(nonce, 0, iv, 0, nonce.length); + return new IvParameterSpec(nonce); + } + + public static IvParameterSpec getIVSecureRandom(String algorithm) throws NoSuchAlgorithmException, NoSuchPaddingException { + SecureRandom random = SecureRandom.getInstanceStrong(); + byte[] iv = new byte[Cipher.getInstance(algorithm) + .getBlockSize()]; + random.nextBytes(iv); + return new IvParameterSpec(iv); + } + + public static IvParameterSpec getIVInternal(Cipher cipher) throws InvalidParameterSpecException { + AlgorithmParameters params = cipher.getParameters(); + byte[] iv = params.getParameterSpec(IvParameterSpec.class) + .getIV(); + return new IvParameterSpec(iv); + } + + public static byte[] getRandomIVWithSize(int size) { + byte[] nonce = new byte[size]; + new SecureRandom().nextBytes(nonce); + return nonce; + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/CryptoDriverIVUnitTest.java b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/CryptoDriverIVUnitTest.java new file mode 100644 index 0000000000..f3bed310dd --- /dev/null +++ b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/CryptoDriverIVUnitTest.java @@ -0,0 +1,86 @@ +package com.baeldung.crypto; + +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import java.security.GeneralSecurityException; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import com.baeldung.crypto.utils.CryptoUtils; + +public class CryptoDriverIVUnitTest{ + private CryptoDriver driver = new CryptoDriver(); + private String TEST_DATA = "Encrypt this for testing"; + + @Test + public void givenString_whenAesEcb_thenSuccess() throws GeneralSecurityException { + SecretKey key = CryptoUtils.generateKey(); + byte[] plaintext = TEST_DATA.getBytes(); + + byte[] ciphertext = driver.ecbEncrypt(key, plaintext); + byte[] decryptedtext = driver.ecbDecrypt(key, ciphertext); + + Assertions.assertEquals(new String(decryptedtext), TEST_DATA); + } + + @Test + public void givenString_whenAesCbc_thenSuccess() throws GeneralSecurityException { + SecretKey key = CryptoUtils.generateKey(); + IvParameterSpec iv = CryptoUtils.getIVSecureRandom("AES"); + byte[] plaintext = TEST_DATA.getBytes(); + + byte[] ciphertext = driver.cbcEncrypt(key, iv, plaintext); + byte[] decryptedtext = driver.cbcDecrypt(key, iv, ciphertext); + + Assertions.assertEquals(new String(decryptedtext), TEST_DATA); + } + + @Test + public void givenString_whenAesCfb_thenSuccess() throws GeneralSecurityException { + SecretKey key = CryptoUtils.generateKey(); + IvParameterSpec iv = CryptoUtils.getIVSecureRandom("AES/CFB/NoPadding"); + byte[] plaintext = TEST_DATA.getBytes(); + + byte[] ciphertext = driver.cfbEncrypt(key, iv, plaintext); + byte[] decryptedtext = driver.cfbDecrypt(key, iv, ciphertext); + + Assertions.assertEquals(new String(decryptedtext), TEST_DATA); + } + + @Test + public void givenString_whenAesOfb_thenSuccess() throws GeneralSecurityException { + SecretKey key = CryptoUtils.generateKey(); + IvParameterSpec iv = CryptoUtils.getIVSecureRandom("AES/OFB32/PKCS5Padding"); + byte[] plaintext = TEST_DATA.getBytes(); + + byte[] ciphertext = driver.ofbEncrypt(key, iv, plaintext); + byte[] decryptedtext = driver.ofbDecrypt(key, iv, ciphertext); + + Assertions.assertEquals(new String(decryptedtext), TEST_DATA); + } + + @Test + public void givenString_whenAesCtr_thenSuccess() throws GeneralSecurityException { + SecretKey key = CryptoUtils.generateKey(); + IvParameterSpec iv = CryptoUtils.getIVSecureRandom("AES/CTR/NoPadding"); + byte[] plaintext = TEST_DATA.getBytes(); + + byte[][] ciphertext = driver.ctrEncrypt(key, iv, plaintext); + byte[] decryptedtext = driver.ctrDecrypt(key, ciphertext[0], ciphertext[1]); + + Assertions.assertEquals(new String(decryptedtext), TEST_DATA); + } + + @Test + void givenString_whenAesGcm_thenSuccess() throws GeneralSecurityException { + SecretKey key = CryptoUtils.generateKey(); + byte[] iv = CryptoUtils.getRandomIVWithSize(12); + byte[] plaintext = (TEST_DATA).getBytes(); + + byte[][] ciphertext = driver.gcmEncrypt(key, iv, plaintext); + byte[] decryptedtext = driver.gcmDecrypt(key, ciphertext[0], ciphertext[1]); + + Assertions.assertEquals(new String(decryptedtext), TEST_DATA); + } +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 872161c2bd..c3d17e7637 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -99,6 +99,7 @@ core-java-reflection-2 core-java-security core-java-security-2 + core-java-security-3 core-java-streams core-java-streams-2 core-java-streams-3 From d3033fbcb5d427e4eab3ac074cb1fb9dc3c95a9a Mon Sep 17 00:00:00 2001 From: saikatcse03 <40471715+saikatcse03@users.noreply.github.com> Date: Tue, 9 Nov 2021 07:23:28 +0530 Subject: [PATCH 138/551] Bael 4241 (#11365) * Added all class loaded listing * Added all class loaded listing Signed-off-by: saikatcse03 * Updated class count * Updated class count test and fixed tabs * Removed spaces * Updated version through Properties Co-authored-by: saikat chakraborty --- core-java-modules/core-java-jvm-2/pom.xml | 14 ++++++- .../loadedclasslisting/ListLoadedClass.java | 35 ++++++++++++++++ .../ListLoadedClassUnitTest.java | 41 +++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/ListLoadedClass.java create mode 100644 core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/loadedclasslisting/ListLoadedClassUnitTest.java diff --git a/core-java-modules/core-java-jvm-2/pom.xml b/core-java-modules/core-java-jvm-2/pom.xml index 08c8de75a9..b34aac5a78 100644 --- a/core-java-modules/core-java-jvm-2/pom.xml +++ b/core-java-modules/core-java-jvm-2/pom.xml @@ -26,11 +26,23 @@ jol-core ${jol-core.version} + + org.reflections + reflections + ${reflections.version} + + + com.google.guava + guava + ${guava.version} + 3.6.1 0.10 + 0.10.2 + 31.0.1-jre - \ No newline at end of file + diff --git a/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/ListLoadedClass.java b/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/ListLoadedClass.java new file mode 100644 index 0000000000..b4a290e70d --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/ListLoadedClass.java @@ -0,0 +1,35 @@ +package com.baeldung.loadedclasslisting; + +import java.io.IOException; +import java.util.Set; +import java.util.stream.Collectors; + +import org.reflections.Reflections; +import org.reflections.scanners.SubTypesScanner; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; + +public class ListLoadedClass { + + public ImmutableSet listClassLoaded() throws IOException { + return ClassPath.from(ListLoadedClass.class.getClassLoader()) + .getAllClasses(); + } + + public Set listClassLoaded(String packageName) throws IOException { + return ClassPath.from(ClassLoader.getSystemClassLoader()).getAllClasses().stream() + .filter(clazz -> clazz.getPackageName().equals(packageName)) + .map(ClassInfo::load) + .collect(Collectors.toSet()); + } + + public Set findAllClassesUsingReflectionsLibrary(String packageName) { + Reflections reflections = new Reflections(packageName, new SubTypesScanner(false)); + return reflections.getSubTypesOf(Object.class) + .stream() + .collect(Collectors.toSet()); + } + +} diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/loadedclasslisting/ListLoadedClassUnitTest.java b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/loadedclasslisting/ListLoadedClassUnitTest.java new file mode 100644 index 0000000000..c3e29b27b6 --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/loadedclasslisting/ListLoadedClassUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.loadedclasslisting; + +import java.io.IOException; +import java.util.Set; + +import org.junit.Test; +import org.junit.jupiter.api.Assertions; + +import com.baeldung.loadedclasslisting.ListLoadedClass; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; + +public class ListLoadedClassUnitTest { + + private static final String PACKAGE_NAME = "com.baeldung.loadedclasslisting"; + + @Test + public void when_findAllClassesUsingReflectionsLibrary_thenSuccess() { + ListLoadedClass instance = new ListLoadedClass(); + Set classes = instance.findAllClassesUsingReflectionsLibrary(PACKAGE_NAME); + + Assertions.assertEquals(4, classes.size()); + } + + @Test + public void when_findAllClassesUsingGuavaLibrary_InPackage_thenSuccess() throws IOException { + ListLoadedClass instance = new ListLoadedClass(); + Set classes = instance.listClassLoaded(PACKAGE_NAME); + + Assertions.assertEquals(4, classes.size()); + } + + @Test + public void when_findAllClassesUsingGuavaLibrary_thenSuccess() throws IOException { + ListLoadedClass instance = new ListLoadedClass(); + Set classes = instance.listClassLoaded(); + + Assertions.assertTrue(4 Date: Tue, 9 Nov 2021 09:33:27 +0330 Subject: [PATCH 139/551] bael-4604: add data, key, algorithm, and hash value as local variable in each method --- .../com/baeldung/hmac/HMACUtilUnitTest.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java index 86e81f5895..0d7f97a094 100644 --- a/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java +++ b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/hmac/HMACUtilUnitTest.java @@ -9,20 +9,16 @@ import static org.junit.Assert.assertEquals; public class HMACUtilUnitTest { - private static String hmacSHA256Value = "5b50d80c7dc7ae8bb1b1433cc0b99ecd2ac8397a555c6f75cb8a619ae35a0c35"; - private static String hmacMD5Value = "621dc816b3bf670212e0c261dc9bcdb6"; - private static String hmacSHA512Value = "b313a21908df55c9e322e3c65a4b0b7561ab1594ca806b3affbc0d769a1290c1922aa6622587bea3c0c4d871470a6d06f54dbd20dbda84250e2741eb01f08e33"; - - //given - String hmacSHA256Algorithm = "HmacSHA256"; - String hmacSHA512Algorithm = "HmacSHA512"; - String hmacMD5Algorithm = "HmacMD5"; - String data = "baeldung"; - String key = "123456"; - @Test public void givenDataAndKeyAndAlgorithm_whenHmacWithJava_thenSuccess() throws NoSuchAlgorithmException, InvalidKeyException { + + //given + String hmacSHA256Value = "5b50d80c7dc7ae8bb1b1433cc0b99ecd2ac8397a555c6f75cb8a619ae35a0c35"; + String hmacSHA256Algorithm = "HmacSHA256"; + String data = "baeldung"; + String key = "123456"; + //when String result = HMACUtil.hmacWithJava(hmacSHA256Algorithm, data, key); @@ -32,6 +28,13 @@ public class HMACUtilUnitTest { @Test public void givenDataAndKeyAndAlgorithm_whenHmacWithApacheCommons_thenSuccess() { + + //given + String hmacMD5Value = "621dc816b3bf670212e0c261dc9bcdb6"; + String hmacMD5Algorithm = "HmacMD5"; + String data = "baeldung"; + String key = "123456"; + //when String result = HMACUtil.hmacWithApacheCommons(hmacMD5Algorithm, data, key); @@ -41,6 +44,14 @@ public class HMACUtilUnitTest { @Test public void givenDataAndKeyAndAlgorithm_whenHmacWithBouncyCastle_thenSuccess() { + + //given + String hmacSHA512Value = "b313a21908df55c9e322e3c65a4b0b7561ab1594ca806b3affbc0d769a1" + + "290c1922aa6622587bea3c0c4d871470a6d06f54dbd20dbda84250e2741eb01f08e33"; + String hmacSHA512Algorithm = "HmacSHA512"; + String data = "baeldung"; + String key = "123456"; + //when String result = HMACUtil.hmacWithBouncyCastle(hmacSHA512Algorithm, data, key); From 54352329d30680ae0304662de9e7b445a7185b07 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Tue, 9 Nov 2021 13:07:43 +0530 Subject: [PATCH 140/551] JAVA-5967 : Update Introduction to Spring Data Solr --- persistence-modules/spring-data-solr/pom.xml | 2 +- .../baeldung/spring/data/solr/config/SolrConfig.java | 4 ++-- .../data/solr/repository/ProductRepository.java | 3 +++ .../data/solr/repo/ProductRepositoryLiveTest.java | 12 ++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/persistence-modules/spring-data-solr/pom.xml b/persistence-modules/spring-data-solr/pom.xml index d7523e6de2..c68c405137 100644 --- a/persistence-modules/spring-data-solr/pom.xml +++ b/persistence-modules/spring-data-solr/pom.xml @@ -45,7 +45,7 @@ - 2.0.5.RELEASE + 4.3.14 \ No newline at end of file diff --git a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java index 1fe1e5468b..54a9816114 100644 --- a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java +++ b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java @@ -9,13 +9,13 @@ import org.springframework.data.solr.core.SolrTemplate; import org.springframework.data.solr.repository.config.EnableSolrRepositories; @Configuration -@EnableSolrRepositories(basePackages = "com.baeldung.spring.data.solr.repository", namedQueriesLocation = "classpath:solr-named-queries.properties", multicoreSupport = true) +@EnableSolrRepositories(basePackages = "com.baeldung.spring.data.solr.repository", namedQueriesLocation = "classpath:solr-named-queries.properties") @ComponentScan public class SolrConfig { @Bean public SolrClient solrClient() { - return new HttpSolrClient("http://localhost:8983/solr"); + return new HttpSolrClient.Builder("http://localhost:8983/solr").build(); } @Bean diff --git a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java index 5649cd7888..677073a58b 100644 --- a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java +++ b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java @@ -1,6 +1,7 @@ package com.baeldung.spring.data.solr.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,6 +12,8 @@ import com.baeldung.spring.data.solr.model.Product; public interface ProductRepository extends SolrCrudRepository { + public Optional findById(String id); + public List findByName(String name); @Query("id:*?0* OR name:*?0*") diff --git a/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java b/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java index f86adcdc8a..2208ffadc0 100644 --- a/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java +++ b/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.data.solr.repo; + package com.baeldung.spring.data.solr.repo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -36,7 +36,7 @@ public class ProductRepositoryLiveTest { product.setId("P000089998"); product.setName("Desk"); productRepository.save(product); - final Product retrievedProduct = productRepository.findOne(product.getId()); + final Product retrievedProduct = productRepository.findById(product.getId()).get(); assertEquals(product.getId(), retrievedProduct.getId()); } @@ -51,7 +51,7 @@ public class ProductRepositoryLiveTest { product.setName("Shirt"); productRepository.save(product); - final Product retrievedProduct = productRepository.findOne(product.getId()); + final Product retrievedProduct = productRepository.findById(product.getId()).get(); assertEquals(product.getName(), retrievedProduct.getName()); } @@ -64,7 +64,7 @@ public class ProductRepositoryLiveTest { productRepository.delete(product); - Product retrievedProduct = productRepository.findOne(product.getId()); + Product retrievedProduct = productRepository.findById(product.getId()).get(); assertNull(retrievedProduct); } @@ -97,7 +97,7 @@ public class ProductRepositoryLiveTest { wirelessCharger.setName("Phone Charging Cable"); productRepository.save(wirelessCharger); - Page result = productRepository.findByCustomQuery("Phone", new PageRequest(0, 10)); + Page result = productRepository.findByCustomQuery("Phone", PageRequest.of(0, 10)); assertEquals(3, result.getNumberOfElements()); } @@ -118,7 +118,7 @@ public class ProductRepositoryLiveTest { wirelessCharger.setName("Phone Charging Cable"); productRepository.save(wirelessCharger); - Page result = productRepository.findByNamedQuery("one", new PageRequest(0, 10)); + Page result = productRepository.findByNamedQuery("one", PageRequest.of(0, 10)); assertEquals(3, result.getNumberOfElements()); } From b984a4b61812e126208f2ef7666b4ca83a19e8e6 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 9 Nov 2021 16:27:03 +0530 Subject: [PATCH 141/551] JAVA-8204: Fix formatting of POMs --- akka-http/pom.xml | 2 +- aws-lambda/lambda/pom.xml | 3 +- core-java-modules/core-java-10/pom.xml | 1 - core-java-modules/core-java-11-2/pom.xml | 1 - core-java-modules/core-java-11/pom.xml | 1 - core-java-modules/core-java-12/pom.xml | 1 - core-java-modules/core-java-13/pom.xml | 1 - core-java-modules/core-java-14/pom.xml | 1 - core-java-modules/core-java-16/pom.xml | 66 ++--- core-java-modules/core-java-17/pom.xml | 64 ++-- .../core-java-annotations/pom.xml | 6 +- .../pom.xml | 3 - .../core-java-collections-maps-4/pom.xml | 6 +- .../core-java-collections-set/pom.xml | 1 - .../core-java-date-operations-1/pom.xml | 1 - .../core-java-datetime-string/pom.xml | 1 - .../core-java-io-conversions-2/pom.xml | 1 - core-java-modules/core-java-io/pom.xml | 1 - core-java-modules/core-java-jvm/pom.xml | 1 - core-java-modules/core-java-os/pom.xml | 180 ++++++------ .../core-java-security-3/pom.xml | 1 - .../core-java-string-algorithms-3/pom.xml | 4 +- .../core-java-string-operations-3/pom.xml | 2 +- core-java-modules/core-java-sun/pom.xml | 1 - .../core-java-time-measurements/pom.xml | 1 - drools/pom.xml | 1 - feign/pom.xml | 1 - flyway-cdi-extension/pom.xml | 1 - guava-modules/guava-18/pom.xml | 1 - guava-modules/guava-19/pom.xml | 1 - guava-modules/guava-21/pom.xml | 1 - guava-modules/guava-collections-list/pom.xml | 1 - guava-modules/guava-collections-map/pom.xml | 1 - guava-modules/guava-collections-set/pom.xml | 1 - guava-modules/guava-collections/pom.xml | 1 - guava-modules/guava-core/pom.xml | 1 - guava-modules/guava-io/pom.xml | 1 - guava-modules/guava-utilities/pom.xml | 1 - libraries-2/pom.xml | 3 +- libraries-6/pom.xml | 2 +- logging-modules/flogger/pom.xml | 1 - logging-modules/log4j/pom.xml | 1 - logging-modules/log4j2/pom.xml | 1 - logging-modules/logback/pom.xml | 1 - logging-modules/pom.xml | 1 - maven-archetype/pom.xml | 1 - maven-modules/maven-generate-war/pom.xml | 126 ++++---- .../aggregator/module1/pom.xml | 2 +- .../aggregator/module2/module3/pom.xml | 2 +- .../aggregator/module2/pom.xml | 2 +- .../aggregator/pom.xml | 2 +- maven-modules/maven-printing-plugins/pom.xml | 6 +- maven-modules/maven-surefire-plugin/pom.xml | 2 +- maven-modules/pom.xml | 2 +- patterns/clean-architecture/pom.xml | 1 - persistence-modules/apache-derby/pom.xml | 13 +- persistence-modules/deltaspike/pom.xml | 4 +- .../spring-data-cassandra-2/pom.xml | 135 ++++----- .../spring-data-cassandra/pom.xml | 3 +- quarkus-vs-springboot/pom.xml | 16 +- quarkus-vs-springboot/quarkus-project/pom.xml | 277 +++++++++--------- quarkus-vs-springboot/spring-project/pom.xml | 33 ++- quarkus/pom.xml | 4 +- rule-engines/evrete/pom.xml | 9 +- spring-boot-modules/spring-boot-admin/pom.xml | 1 - .../spring-boot-admin-client/pom.xml | 1 - .../spring-boot-admin-server/pom.xml | 1 - .../spring-boot-angular/pom.xml | 1 - .../spring-boot-annotations/pom.xml | 1 - .../spring-boot-artifacts-2/pom.xml | 1 - .../spring-boot-artifacts/pom.xml | 1 - .../spring-boot-autoconfiguration/pom.xml | 1 - .../spring-boot-basic-customization-2/pom.xml | 1 - .../spring-boot-basic-customization/pom.xml | 1 - .../spring-boot-bootstrap/pom.xml | 1 - spring-boot-modules/spring-boot-ci-cd/pom.xml | 1 - .../spring-boot-client/pom.xml | 1 - .../spring-boot-config-jpa-error/pom.xml | 1 - spring-boot-modules/spring-boot-crud/pom.xml | 1 - .../spring-boot-ctx-fluent/pom.xml | 1 - .../greeter-spring-boot-sample-app/pom.xml | 1 - .../spring-boot-custom-starter/pom.xml | 1 - .../spring-boot-data-2/pom.xml | 1 - spring-boot-modules/spring-boot-data/pom.xml | 1 - .../spring-boot-deployment/pom.xml | 1 - spring-boot-modules/spring-boot-di/pom.xml | 1 - .../disabling-console-jul/pom.xml | 1 - .../disabling-console-log4j2/pom.xml | 1 - .../disabling-console-logback/pom.xml | 1 - .../spring-boot-disable-logging/pom.xml | 1 - .../spring-boot-environment/pom.xml | 1 - .../spring-boot-exceptions/pom.xml | 1 - .../spring-boot-flowable/pom.xml | 1 - .../spring-boot-jasypt/pom.xml | 1 - .../spring-boot-libraries/pom.xml | 1 - .../spring-boot-logging-log4j2/pom.xml | 4 +- spring-boot-modules/spring-boot-mvc-2/pom.xml | 1 - spring-boot-modules/spring-boot-mvc-3/pom.xml | 3 +- .../spring-boot-mvc-jersey/pom.xml | 1 - spring-boot-modules/spring-boot-mvc/pom.xml | 1 - .../spring-boot-nashorn/pom.xml | 1 - .../spring-boot-parent/pom.xml | 1 - .../spring-boot-with-custom-parent/pom.xml | 1 - .../spring-boot-with-starter-parent/pom.xml | 1 - .../spring-boot-performance/pom.xml | 1 - .../spring-boot-properties-2/pom.xml | 1 - .../spring-boot-properties-3/pom.xml | 1 - .../spring-boot-properties/pom.xml | 3 +- .../spring-boot-runtime-2/pom.xml | 3 +- .../spring-boot-runtime/pom.xml | 3 +- .../spring-boot-security/pom.xml | 3 +- .../spring-boot-springdoc/pom.xml | 3 +- .../spring-boot-swagger-jwt/pom.xml | 1 - .../spring-boot-swagger/pom.xml | 1 - .../spring-boot-testing/pom.xml | 3 +- spring-boot-modules/spring-boot-vue/pom.xml | 3 +- spring-boot-modules/spring-boot/pom.xml | 1 - spring-cloud-data-flow/pom.xml | 1 - spring-cloud/spring-cloud-aws/pom.xml | 4 +- .../order-service/order-client/pom.xml | 2 +- .../spring-cloud-connectors-heroku/pom.xml | 6 +- spring-cloud/spring-cloud-dapr/pom.xml | 2 +- .../docker-product-server/pom.xml | 2 +- spring-cloud/spring-cloud-docker/pom.xml | 2 +- .../rest-consumer/pom.xml | 1 - .../kubernetes-guide/client-service/pom.xml | 2 +- .../liveness-example/pom.xml | 2 +- .../twitterhdfs/pom.xml | 4 +- spring-ejb/pom.xml | 5 +- spring-quartz/pom.xml | 2 +- .../spring-5-security-oauth/pom.xml | 3 +- .../spring-security-web-boot-3/pom.xml | 4 +- .../spring-security-web-thymeleaf/pom.xml | 1 - testing-modules/assertion-libraries/pom.xml | 6 +- testing-modules/selenium-junit-testng/pom.xml | 4 +- 135 files changed, 533 insertions(+), 606 deletions(-) diff --git a/akka-http/pom.xml b/akka-http/pom.xml index 4b73fbc960..a64d7a80f6 100644 --- a/akka-http/pom.xml +++ b/akka-http/pom.xml @@ -41,4 +41,4 @@ 2.5.11 - + \ No newline at end of file diff --git a/aws-lambda/lambda/pom.xml b/aws-lambda/lambda/pom.xml index dea951d1b3..b2e5cc3b2d 100644 --- a/aws-lambda/lambda/pom.xml +++ b/aws-lambda/lambda/pom.xml @@ -63,7 +63,8 @@ json-simple ${json-simple.version} - + junit junit diff --git a/core-java-modules/core-java-10/pom.xml b/core-java-modules/core-java-10/pom.xml index b293110546..c3406751dc 100644 --- a/core-java-modules/core-java-10/pom.xml +++ b/core-java-modules/core-java-10/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 68e8b66d67..4c16ec7032 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../.. diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index def7ab43f7..d3ffb0a8f0 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -13,7 +13,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../.. diff --git a/core-java-modules/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml index 931fce820b..26b7d0c14d 100644 --- a/core-java-modules/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -13,7 +13,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../../ diff --git a/core-java-modules/core-java-13/pom.xml b/core-java-modules/core-java-13/pom.xml index 6369976580..d28618a21a 100644 --- a/core-java-modules/core-java-13/pom.xml +++ b/core-java-modules/core-java-13/pom.xml @@ -14,7 +14,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../../ diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index a03332d8bc..4b0d030a34 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -12,7 +12,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../../ diff --git a/core-java-modules/core-java-16/pom.xml b/core-java-modules/core-java-16/pom.xml index 5d10325f03..d003ca9ae7 100644 --- a/core-java-modules/core-java-16/pom.xml +++ b/core-java-modules/core-java-16/pom.xml @@ -28,18 +28,18 @@ commons-lang3 3.12.0 - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + @@ -50,37 +50,37 @@ ${maven-compiler-plugin.version} ${maven.compiler.release} - --enable-preview + --enable-preview ${maven.compiler.source.version} ${maven.compiler.target.version} - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.plugin.version} - - --enable-preview - 1 - - - - org.apache.maven.surefire - surefire-api - ${surefire.plugin.version} - - - + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + --enable-preview + 1 + + + + org.apache.maven.surefire + surefire-api + ${surefire.plugin.version} + + + 16 16 - 16 - 3.8.1 - 3.0.0-M5 - 3.17.2 + 16 + 3.8.1 + 3.0.0-M5 + 3.17.2 \ No newline at end of file diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml index f9a7ec326b..7024705cc2 100644 --- a/core-java-modules/core-java-17/pom.xml +++ b/core-java-modules/core-java-17/pom.xml @@ -23,18 +23,18 @@ ${assertj.version} test - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + @@ -50,32 +50,32 @@ ${maven.compiler.target.version} - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.plugin.version} - - --enable-preview - 1 - - - - org.apache.maven.surefire - surefire-api - ${surefire.plugin.version} - - - + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + --enable-preview + 1 + + + + org.apache.maven.surefire + surefire-api + ${surefire.plugin.version} + + + 17 17 - 17 - 3.8.1 - 3.0.0-M5 - 3.17.2 + 17 + 3.8.1 + 3.0.0-M5 + 3.17.2 \ No newline at end of file diff --git a/core-java-modules/core-java-annotations/pom.xml b/core-java-modules/core-java-annotations/pom.xml index a87baa6204..19d02aa2ac 100644 --- a/core-java-modules/core-java-annotations/pom.xml +++ b/core-java-modules/core-java-annotations/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 core-java-annotations 0.1.0-SNAPSHOT @@ -37,4 +37,4 @@
- + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml index 065f1930e2..d122e3330c 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/pom.xml +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -19,20 +19,17 @@ commons-lang3 ${commons-lang3.version} - org.assertj assertj-core ${assertj-core.version} test - org.openjdk.jmh jmh-core ${jmh.version} - org.openjdk.jmh jmh-generator-annprocess diff --git a/core-java-modules/core-java-collections-maps-4/pom.xml b/core-java-modules/core-java-collections-maps-4/pom.xml index 1835e3ceac..bfb91515fa 100644 --- a/core-java-modules/core-java-collections-maps-4/pom.xml +++ b/core-java-modules/core-java-collections-maps-4/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 core-java-collections-maps-4 0.1.0-SNAPSHOT @@ -31,4 +31,4 @@
- + \ No newline at end of file diff --git a/core-java-modules/core-java-collections-set/pom.xml b/core-java-modules/core-java-collections-set/pom.xml index b8940f4a68..359c0fc86f 100644 --- a/core-java-modules/core-java-collections-set/pom.xml +++ b/core-java-modules/core-java-collections-set/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-date-operations-1/pom.xml b/core-java-modules/core-java-date-operations-1/pom.xml index 7b7c68d1b6..854d6ed916 100644 --- a/core-java-modules/core-java-date-operations-1/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-datetime-string/pom.xml b/core-java-modules/core-java-datetime-string/pom.xml index f50eb2ae5e..8bc7b60126 100644 --- a/core-java-modules/core-java-datetime-string/pom.xml +++ b/core-java-modules/core-java-datetime-string/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-io-conversions-2/pom.xml b/core-java-modules/core-java-io-conversions-2/pom.xml index dcb9d494dc..24708ad967 100644 --- a/core-java-modules/core-java-io-conversions-2/pom.xml +++ b/core-java-modules/core-java-io-conversions-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-io/pom.xml b/core-java-modules/core-java-io/pom.xml index 0cf6d6767e..a036818226 100644 --- a/core-java-modules/core-java-io/pom.xml +++ b/core-java-modules/core-java-io/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml index afbe0b0ee3..77d0aaf54b 100644 --- a/core-java-modules/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index b279e3d6cb..b163052ea2 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -1,99 +1,99 @@ - 4.0.0 - core-java-os - 0.1.0-SNAPSHOT - core-java-os - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-os + 0.1.0-SNAPSHOT + core-java-os + jar - - com.baeldung.core-java-modules - core-java-modules - 0.0.1-SNAPSHOT - ../ - + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + - - - org.junit.jupiter - junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter-engine ${junit-jupiter.version} - test - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - commons-io - commons-io - ${commons-io.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - log4j - log4j - ${log4j.version} - - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.unix4j - unix4j-command - ${unix4j.version} - - - com.googlecode.grep4j - grep4j - ${grep4j.version} - - + test + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + log4j + log4j + ${log4j.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.unix4j + unix4j-command + ${unix4j.version} + + + com.googlecode.grep4j + grep4j + ${grep4j.version} + + - - core-java-os - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - + + core-java-os + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + - - - 4.1 - 4.01 - - 3.6.1 - 1.8.9 - 1.9 - 1.9 - 25.1-jre - 0.4 - 1.8.7 - + + + 4.1 + 4.01 + + 3.6.1 + 1.8.9 + 1.9 + 1.9 + 25.1-jre + 0.4 + 1.8.7 + \ No newline at end of file diff --git a/core-java-modules/core-java-security-3/pom.xml b/core-java-modules/core-java-security-3/pom.xml index 69d0ffb917..a0e73a1e29 100644 --- a/core-java-modules/core-java-security-3/pom.xml +++ b/core-java-modules/core-java-security-3/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 6376bfa677..67a6443bc6 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -4,8 +4,8 @@ 4.0.0 core-java-string-algorithms-3 0.1.0-SNAPSHOT - jar core-java-string-algorithms-3 + jar com.baeldung.core-java-modules @@ -66,4 +66,4 @@ 1.7 - + \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-3/pom.xml b/core-java-modules/core-java-string-operations-3/pom.xml index 20e9bcb39a..2567f776b1 100644 --- a/core-java-modules/core-java-string-operations-3/pom.xml +++ b/core-java-modules/core-java-string-operations-3/pom.xml @@ -92,4 +92,4 @@ 3.1.0 - + \ No newline at end of file diff --git a/core-java-modules/core-java-sun/pom.xml b/core-java-modules/core-java-sun/pom.xml index 347020a736..4c26b59168 100644 --- a/core-java-modules/core-java-sun/pom.xml +++ b/core-java-modules/core-java-sun/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index 663cf6708b..69de5c04fa 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -13,7 +13,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/drools/pom.xml b/drools/pom.xml index cc96d9d032..daaf1fa8a7 100644 --- a/drools/pom.xml +++ b/drools/pom.xml @@ -19,7 +19,6 @@ httpcore ${http-component-version} - org.kie kie-ci diff --git a/feign/pom.xml b/feign/pom.xml index 56059d2a77..cf28890868 100644 --- a/feign/pom.xml +++ b/feign/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. diff --git a/flyway-cdi-extension/pom.xml b/flyway-cdi-extension/pom.xml index dbd21374e2..3d52ff0e36 100644 --- a/flyway-cdi-extension/pom.xml +++ b/flyway-cdi-extension/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. diff --git a/guava-modules/guava-18/pom.xml b/guava-modules/guava-18/pom.xml index ed295db2f4..8f5108bff1 100644 --- a/guava-modules/guava-18/pom.xml +++ b/guava-modules/guava-18/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-19/pom.xml b/guava-modules/guava-19/pom.xml index 3c29a2a59c..ba85fe0ae8 100644 --- a/guava-modules/guava-19/pom.xml +++ b/guava-modules/guava-19/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-21/pom.xml b/guava-modules/guava-21/pom.xml index 8b7c3cdcfd..9e791bfe23 100644 --- a/guava-modules/guava-21/pom.xml +++ b/guava-modules/guava-21/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections-list/pom.xml b/guava-modules/guava-collections-list/pom.xml index e57198ec40..b90f70764f 100644 --- a/guava-modules/guava-collections-list/pom.xml +++ b/guava-modules/guava-collections-list/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections-map/pom.xml b/guava-modules/guava-collections-map/pom.xml index 7f3e470fc3..e34d1a33a6 100644 --- a/guava-modules/guava-collections-map/pom.xml +++ b/guava-modules/guava-collections-map/pom.xml @@ -12,7 +12,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections-set/pom.xml b/guava-modules/guava-collections-set/pom.xml index 09e3f42e83..1953ade44f 100644 --- a/guava-modules/guava-collections-set/pom.xml +++ b/guava-modules/guava-collections-set/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections/pom.xml b/guava-modules/guava-collections/pom.xml index 6dc7510a1e..be75f93d29 100644 --- a/guava-modules/guava-collections/pom.xml +++ b/guava-modules/guava-collections/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-core/pom.xml b/guava-modules/guava-core/pom.xml index a15dfb5178..2540ac97a7 100644 --- a/guava-modules/guava-core/pom.xml +++ b/guava-modules/guava-core/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-io/pom.xml b/guava-modules/guava-io/pom.xml index 11a5d4ada6..de1ab926dc 100644 --- a/guava-modules/guava-io/pom.xml +++ b/guava-modules/guava-io/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-utilities/pom.xml b/guava-modules/guava-utilities/pom.xml index 6049a62e85..deac03b406 100644 --- a/guava-modules/guava-utilities/pom.xml +++ b/guava-modules/guava-utilities/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 700a0a02d4..0988ed454e 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -54,7 +54,8 @@ jbpm-test ${jbpm.version} - + junit junit diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index cecc9ca476..cf2c2c551d 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -157,4 +157,4 @@ 2.4.4 - + \ No newline at end of file diff --git a/logging-modules/flogger/pom.xml b/logging-modules/flogger/pom.xml index b96025f277..c814d31767 100644 --- a/logging-modules/flogger/pom.xml +++ b/logging-modules/flogger/pom.xml @@ -9,7 +9,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/log4j/pom.xml b/logging-modules/log4j/pom.xml index 864e2253b5..d3c7f8287e 100644 --- a/logging-modules/log4j/pom.xml +++ b/logging-modules/log4j/pom.xml @@ -11,7 +11,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/log4j2/pom.xml b/logging-modules/log4j2/pom.xml index aaf60a4216..0b6fa9b902 100644 --- a/logging-modules/log4j2/pom.xml +++ b/logging-modules/log4j2/pom.xml @@ -10,7 +10,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml index 512dc9e5a3..48bb37b881 100644 --- a/logging-modules/logback/pom.xml +++ b/logging-modules/logback/pom.xml @@ -11,7 +11,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/pom.xml b/logging-modules/pom.xml index 7e358ae490..c7a770891d 100644 --- a/logging-modules/pom.xml +++ b/logging-modules/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/maven-archetype/pom.xml b/maven-archetype/pom.xml index 2eab8ac614..04247f622c 100644 --- a/maven-archetype/pom.xml +++ b/maven-archetype/pom.xml @@ -18,7 +18,6 @@ ${archetype-packaging.version} -
diff --git a/maven-modules/maven-generate-war/pom.xml b/maven-modules/maven-generate-war/pom.xml index e5b42f5090..56256f58ea 100644 --- a/maven-modules/maven-generate-war/pom.xml +++ b/maven-modules/maven-generate-war/pom.xml @@ -1,62 +1,68 @@ - -4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.5.4 - - - -com.baeldung -maven-generate-war -0.0.1-SNAPSHOT -war -maven-generate-war -Spring boot project to demonstrate war file generation - - 11 - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - org.springframework.boot - spring-boot-starter-test - test - - - - maven-generate-war - - - maven-war-plugin - 3.3.1 - - - - additional_resources - - - - - true - - - - - - - + + 4.0.0 + com.baeldung + maven-generate-war + 0.0.1-SNAPSHOT + war + maven-generate-war + Spring boot project to demonstrate war file generation + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + maven-generate-war + + + maven-war-plugin + 3.3.1 + + + + additional_resources + + + + + true + + + + + + + + + 11 + + + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml index e1f411db2f..67e60fb386 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml @@ -13,4 +13,4 @@ - + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml index d983f35e3e..f4e3e81e7d 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml @@ -15,4 +15,4 @@ ../../pom.xml - + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml index 48c1ebab9d..9b36ef37fb 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml @@ -18,4 +18,4 @@ module3 - + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml index 8f6e3453a5..dde2c46370 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml @@ -19,4 +19,4 @@ module2 - + \ No newline at end of file diff --git a/maven-modules/maven-printing-plugins/pom.xml b/maven-modules/maven-printing-plugins/pom.xml index 07ddd8d1e8..aacc829b93 100644 --- a/maven-modules/maven-printing-plugins/pom.xml +++ b/maven-modules/maven-printing-plugins/pom.xml @@ -76,8 +76,10 @@ log.info('Test message: {}', 'Hello, World!') - log.info('Embed a line break {}', System.lineSeparator()) - log.info('ArtifactId is: ${project.artifactId}') + log.info('Embed a + line break {}', System.lineSeparator()) + log.info('ArtifactId is: + ${project.artifactId}') log.warn('Message only in debug mode') diff --git a/maven-modules/maven-surefire-plugin/pom.xml b/maven-modules/maven-surefire-plugin/pom.xml index 98decc69e1..840ffab077 100644 --- a/maven-modules/maven-surefire-plugin/pom.xml +++ b/maven-modules/maven-surefire-plugin/pom.xml @@ -14,4 +14,4 @@ 0.0.1-SNAPSHOT - + \ No newline at end of file diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index 0aadb873e5..12fd44e739 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -37,7 +37,7 @@ plugin-management maven-surefire-plugin maven-parent-pom-resolution - maven-dependency + maven-dependency diff --git a/patterns/clean-architecture/pom.xml b/patterns/clean-architecture/pom.xml index c36f9b83af..71f50907fd 100644 --- a/patterns/clean-architecture/pom.xml +++ b/patterns/clean-architecture/pom.xml @@ -71,7 +71,6 @@ - org.springframework.boot spring-boot-maven-plugin diff --git a/persistence-modules/apache-derby/pom.xml b/persistence-modules/apache-derby/pom.xml index 7728bd4d8f..f7f5ca7503 100644 --- a/persistence-modules/apache-derby/pom.xml +++ b/persistence-modules/apache-derby/pom.xml @@ -1,15 +1,15 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + apache-derby + persistence-modules com.baeldung 1.0.0-SNAPSHOT - 4.0.0 - - apache-derby @@ -18,15 +18,12 @@ derby 10.13.1.1 - org.apache.derby derbyclient 10.13.1.1 - - \ No newline at end of file diff --git a/persistence-modules/deltaspike/pom.xml b/persistence-modules/deltaspike/pom.xml index 5003ef9daf..f151255948 100644 --- a/persistence-modules/deltaspike/pom.xml +++ b/persistence-modules/deltaspike/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/persistence-modules/spring-data-cassandra-2/pom.xml b/persistence-modules/spring-data-cassandra-2/pom.xml index 0e09448d0f..8202471d19 100644 --- a/persistence-modules/spring-data-cassandra-2/pom.xml +++ b/persistence-modules/spring-data-cassandra-2/pom.xml @@ -1,72 +1,73 @@ - - 4.0.0 - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + + 4.0.0 + org.baeldung + spring-cassandra + 0.0.1-SNAPSHOT + spring-cassandra + Demo project for Spring Data Cassandra - org.baeldung - spring-cassandra - 0.0.1-SNAPSHOT - spring-cassandra - Demo project for Spring Data Cassandra + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + - - - org.springframework.boot - spring-boot-starter-data-cassandra - - - org.springframework.data - spring-data-cassandra - ${org.springframework.data.version} - - - uk.org.webcompere - system-stubs-core - ${system.stubs.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - org.testcontainers - testcontainers - ${testcontainers.version} - test - - - org.testcontainers - cassandra - ${testcontainers.version} - test - - - org.testcontainers - junit-jupiter - ${testcontainers.version} - test - - - uk.org.webcompere - system-stubs-jupiter - ${system.stubs.version} - test - - + + + org.springframework.boot + spring-boot-starter-data-cassandra + + + org.springframework.data + spring-data-cassandra + ${org.springframework.data.version} + + + uk.org.webcompere + system-stubs-core + ${system.stubs.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + org.testcontainers + testcontainers + ${testcontainers.version} + test + + + org.testcontainers + cassandra + ${testcontainers.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + test + + + uk.org.webcompere + system-stubs-jupiter + ${system.stubs.version} + test + + - - 11 - 3.1.11 - 1.15.3 - 1.1.0 - 5.6.2 - + + 11 + 3.1.11 + 1.15.3 + 1.1.0 + 5.6.2 + - + \ No newline at end of file diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index 8092c05a40..925031b141 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -49,7 +49,8 @@ ${cassandra-unit-shaded.version} test - + junit junit diff --git a/quarkus-vs-springboot/pom.xml b/quarkus-vs-springboot/pom.xml index cf1cbb5d85..1726d076da 100644 --- a/quarkus-vs-springboot/pom.xml +++ b/quarkus-vs-springboot/pom.xml @@ -1,19 +1,19 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + quarkus-vs-springboot + 1.0-SNAPSHOT + quarkus-vs-springboot + pom + parent-modules com.baeldung 1.0.0-SNAPSHOT - 1.0-SNAPSHOT - quarkus-vs-springboot - quarkus-vs-springboot - pom - 4.0.0 - quarkus-project spring-project diff --git a/quarkus-vs-springboot/quarkus-project/pom.xml b/quarkus-vs-springboot/quarkus-project/pom.xml index 58d547f3b0..eeeb9d3256 100644 --- a/quarkus-vs-springboot/quarkus-project/pom.xml +++ b/quarkus-vs-springboot/quarkus-project/pom.xml @@ -1,143 +1,150 @@ - - 4.0.0 - - com.baeldung - quarkus-vs-springboot - 1.0-SNAPSHOT - - quarkus-project - 0.1-SNAPSHOT - - 3.8.1 - true - 11 - 11 - UTF-8 - UTF-8 - quarkus-bom - io.quarkus.platform - 2.2.2.Final - 3.0.0-M4 - - + 4.0.0 + quarkus-project + 0.1-SNAPSHOT + + + com.baeldung + quarkus-vs-springboot + 1.0-SNAPSHOT + + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + - - ${quarkus.platform.group-id} - ${quarkus.platform.artifact-id} - ${quarkus.platform.version} - pom - import - + + io.quarkus + quarkus-hibernate-reactive-panache + + + io.quarkus + quarkus-resteasy-reactive + + + io.quarkus + quarkus-resteasy-reactive-jackson + + + io.quarkus + quarkus-reactive-pg-client + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-container-image-docker + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + - - - - io.quarkus - quarkus-hibernate-reactive-panache - - - io.quarkus - quarkus-resteasy-reactive - - - io.quarkus - quarkus-resteasy-reactive-jackson - - - io.quarkus - quarkus-reactive-pg-client - - - io.quarkus - quarkus-arc - - - io.quarkus - quarkus-container-image-docker - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - - - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - - - - maven-compiler-plugin - ${compiler-plugin.version} - - ${maven.compiler.parameters} - - - - maven-surefire-plugin - ${surefire-plugin.version} - - false - - org.jboss.logmanager.LogManager - - - - - - - - native - - - native - - - + + - - maven-failsafe-plugin - ${surefire-plugin.version} - - - - integration-test - verify - + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + ${compiler-plugin.version} - - ${project.build.directory}/${project.build.finalName}-runner - org.jboss.logmanager.LogManager - + ${maven.compiler.parameters} - - - + + + maven-surefire-plugin + ${surefire-plugin.version} + + false + + org.jboss.logmanager.LogManager + + + - - - -H:+AllowVMInspection - native - - - - + + + + native + + + native + + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + + + + + + + + + -H:+AllowVMInspection + native + + + + + + 3.8.1 + true + 11 + 11 + UTF-8 + UTF-8 + quarkus-bom + io.quarkus.platform + 2.2.2.Final + 3.0.0-M4 + + + \ No newline at end of file diff --git a/quarkus-vs-springboot/spring-project/pom.xml b/quarkus-vs-springboot/spring-project/pom.xml index be5cc57765..128966c07e 100644 --- a/quarkus-vs-springboot/spring-project/pom.xml +++ b/quarkus-vs-springboot/spring-project/pom.xml @@ -1,25 +1,18 @@ - - - org.springframework.boot - spring-boot-starter-parent - 2.5.4 - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-project com.baeldung 0.1-SNAPSHOT - - 11 - - 0.10.3 - + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + @@ -161,11 +154,19 @@ org.apache.maven.plugins maven-surefire-plugin - -DspringAot=true -agentlib:native-image-agent=access-filter-file=src/test/resources/access-filter.json,config-merge-dir=target/classes/META-INF/native-image + -DspringAot=true + -agentlib:native-image-agent=access-filter-file=src/test/resources/access-filter.json,config-merge-dir=target/classes/META-INF/native-image + + + 11 + + 0.10.3 + + \ No newline at end of file diff --git a/quarkus/pom.xml b/quarkus/pom.xml index d826729ad7..22f5e0e991 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -16,8 +16,8 @@ - + junit junit diff --git a/rule-engines/evrete/pom.xml b/rule-engines/evrete/pom.xml index 819a912c43..cfcadcb2ea 100644 --- a/rule-engines/evrete/pom.xml +++ b/rule-engines/evrete/pom.xml @@ -8,10 +8,6 @@ 1.0 evrete - - 2.1.04 - - com.baeldung rule-engines @@ -32,4 +28,9 @@ ${evrete.version} + + + 2.1.04 + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-admin/pom.xml b/spring-boot-modules/spring-boot-admin/pom.xml index b995b6f02e..509abfa013 100644 --- a/spring-boot-modules/spring-boot-admin/pom.xml +++ b/spring-boot-modules/spring-boot-admin/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml index eca92ff3a5..72f828b259 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml index a1daa3fa19..0ccd43e0b9 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml index 89a8814d2f..d713510cff 100644 --- a/spring-boot-modules/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-annotations/pom.xml b/spring-boot-modules/spring-boot-annotations/pom.xml index 22572e7492..618ae6024b 100644 --- a/spring-boot-modules/spring-boot-annotations/pom.xml +++ b/spring-boot-modules/spring-boot-annotations/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-artifacts-2/pom.xml b/spring-boot-modules/spring-boot-artifacts-2/pom.xml index 8cf78b79e0..3b9390e973 100644 --- a/spring-boot-modules/spring-boot-artifacts-2/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml index 7ed91a6626..5b4f5a1dd1 100644 --- a/spring-boot-modules/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index bf8bcc5a87..b5e85bad59 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-basic-customization-2/pom.xml b/spring-boot-modules/spring-boot-basic-customization-2/pom.xml index 6f3cb48b81..7a086331ab 100644 --- a/spring-boot-modules/spring-boot-basic-customization-2/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-basic-customization/pom.xml b/spring-boot-modules/spring-boot-basic-customization/pom.xml index 5ab747cff1..2782c3320e 100644 --- a/spring-boot-modules/spring-boot-basic-customization/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-bootstrap/pom.xml b/spring-boot-modules/spring-boot-bootstrap/pom.xml index f94ee9ca31..caa3f6c7fc 100644 --- a/spring-boot-modules/spring-boot-bootstrap/pom.xml +++ b/spring-boot-modules/spring-boot-bootstrap/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-ci-cd/pom.xml b/spring-boot-modules/spring-boot-ci-cd/pom.xml index fb1810c62e..68a9f21d20 100644 --- a/spring-boot-modules/spring-boot-ci-cd/pom.xml +++ b/spring-boot-modules/spring-boot-ci-cd/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-client/pom.xml b/spring-boot-modules/spring-boot-client/pom.xml index 7f54d0e541..8ae2cbee79 100644 --- a/spring-boot-modules/spring-boot-client/pom.xml +++ b/spring-boot-modules/spring-boot-client/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml index b5207f8997..6291589e7a 100644 --- a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml +++ b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml index 79eccf2fba..0a8e57be17 100644 --- a/spring-boot-modules/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -10,7 +10,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml index 8a7aca076e..deefefc87c 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml +++ b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml index 815c3e8366..c4759af373 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-custom-starter 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-custom-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/pom.xml index 27e3a03153..aee98b125e 100644 --- a/spring-boot-modules/spring-boot-custom-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-data-2/pom.xml b/spring-boot-modules/spring-boot-data-2/pom.xml index b7006782c8..a3c2430497 100644 --- a/spring-boot-modules/spring-boot-data-2/pom.xml +++ b/spring-boot-modules/spring-boot-data-2/pom.xml @@ -9,7 +9,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml index 447b730c02..c57dad49f4 100644 --- a/spring-boot-modules/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml index 7c78d20afc..c4d9fa7059 100644 --- a/spring-boot-modules/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-di/pom.xml b/spring-boot-modules/spring-boot-di/pom.xml index 0e9fb49a95..af0dd7e4de 100644 --- a/spring-boot-modules/spring-boot-di/pom.xml +++ b/spring-boot-modules/spring-boot-di/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml b/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml index deee4e435f..ace21410ea 100644 --- a/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-disable-logging 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml b/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml index 0524f9d401..b71e1066e7 100644 --- a/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-disable-logging 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml b/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml index 0990209ff9..37fad3ec53 100644 --- a/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml @@ -10,7 +10,6 @@ com.baeldung.spring-boot-modules spring-boot-disable-logging 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/pom.xml b/spring-boot-modules/spring-boot-disable-logging/pom.xml index 65de521c63..31b02009b6 100644 --- a/spring-boot-modules/spring-boot-disable-logging/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index d4b260ee3d..504a0e2539 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-exceptions/pom.xml b/spring-boot-modules/spring-boot-exceptions/pom.xml index cec1bab4ff..b1240957f6 100644 --- a/spring-boot-modules/spring-boot-exceptions/pom.xml +++ b/spring-boot-modules/spring-boot-exceptions/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-flowable/pom.xml b/spring-boot-modules/spring-boot-flowable/pom.xml index 320a684880..9d8daa022d 100644 --- a/spring-boot-modules/spring-boot-flowable/pom.xml +++ b/spring-boot-modules/spring-boot-flowable/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index 0a37c545ac..8595b9c639 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index ad00629e14..eee469ea46 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml index dafbddb93f..8cf052deb3 100644 --- a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/spring-boot-modules/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml index d347b36b3b..f303171df8 100644 --- a/spring-boot-modules/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index a46837e315..dee217862d 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-mvc-3 - jar spring-boot-mvc-3 + jar Module For Spring Boot MVC Web com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-mvc-jersey/pom.xml b/spring-boot-modules/spring-boot-mvc-jersey/pom.xml index b6e2c62663..34b459d1dc 100644 --- a/spring-boot-modules/spring-boot-mvc-jersey/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-jersey/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-mvc/pom.xml b/spring-boot-modules/spring-boot-mvc/pom.xml index 3e835691aa..6d3f722146 100644 --- a/spring-boot-modules/spring-boot-mvc/pom.xml +++ b/spring-boot-modules/spring-boot-mvc/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-nashorn/pom.xml b/spring-boot-modules/spring-boot-nashorn/pom.xml index 89b0b984bc..0ae108ffd0 100644 --- a/spring-boot-modules/spring-boot-nashorn/pom.xml +++ b/spring-boot-modules/spring-boot-nashorn/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-parent/pom.xml b/spring-boot-modules/spring-boot-parent/pom.xml index 28a940bcd0..d9c23b66ac 100644 --- a/spring-boot-modules/spring-boot-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml index a61a5fd057..18fa4c53d9 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-parent 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml index 2568714278..e65f590c9b 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-parent 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-performance/pom.xml b/spring-boot-modules/spring-boot-performance/pom.xml index f1f9b52dc4..38f5758c1f 100644 --- a/spring-boot-modules/spring-boot-performance/pom.xml +++ b/spring-boot-modules/spring-boot-performance/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-properties-2/pom.xml b/spring-boot-modules/spring-boot-properties-2/pom.xml index 62f23da450..d5aaab54d3 100644 --- a/spring-boot-modules/spring-boot-properties-2/pom.xml +++ b/spring-boot-modules/spring-boot-properties-2/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-properties-3/pom.xml b/spring-boot-modules/spring-boot-properties-3/pom.xml index b5e6ef8701..d72c410d9b 100644 --- a/spring-boot-modules/spring-boot-properties-3/pom.xml +++ b/spring-boot-modules/spring-boot-properties-3/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 0ef44e0546..8cbaccdac5 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -4,16 +4,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-properties - jar 0.0.1-SNAPSHOT spring-boot-properties + jar Spring Boot Properties Module com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-runtime-2/pom.xml b/spring-boot-modules/spring-boot-runtime-2/pom.xml index c177529a41..e6483e9ec0 100644 --- a/spring-boot-modules/spring-boot-runtime-2/pom.xml +++ b/spring-boot-modules/spring-boot-runtime-2/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-runtime-2 - jar spring-boot-runtime-2 + jar Demo project for Spring Boot com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index 92b1458cf6..d42ae303a7 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-runtime - jar spring-boot-runtime + jar Demo project for Spring Boot Runtime com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-security/pom.xml b/spring-boot-modules/spring-boot-security/pom.xml index 11e5a38eeb..41dbcff38d 100644 --- a/spring-boot-modules/spring-boot-security/pom.xml +++ b/spring-boot-modules/spring-boot-security/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-security - jar spring-boot-security + jar Spring Boot Security Auto-Configuration com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index 892fbfe4ca..10bd9a7534 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -5,15 +5,14 @@ 4.0.0 spring-boot-springdoc 0.0.1-SNAPSHOT - jar spring-boot-springdoc + jar Project for Springdoc integration com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-swagger-jwt/pom.xml b/spring-boot-modules/spring-boot-swagger-jwt/pom.xml index c296b06388..e0d96627cd 100644 --- a/spring-boot-modules/spring-boot-swagger-jwt/pom.xml +++ b/spring-boot-modules/spring-boot-swagger-jwt/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml index a9d8a943e4..87ee5f04cb 100644 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index f70e77b31a..2f33c44d60 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-testing - war spring-boot-testing + war This is simple boot application for demonstrating testing features. com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-vue/pom.xml b/spring-boot-modules/spring-boot-vue/pom.xml index 3d3d51797c..c552a9583f 100644 --- a/spring-boot-modules/spring-boot-vue/pom.xml +++ b/spring-boot-modules/spring-boot-vue/pom.xml @@ -5,15 +5,14 @@ 4.0.0 spring-boot-vue 0.0.1-SNAPSHOT - jar spring-boot-vue + jar Demo project for Spring Boot Vue project com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index 8df16a1f9c..58c4e39043 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-cloud-data-flow/pom.xml b/spring-cloud-data-flow/pom.xml index f81daeeabc..49a5accb90 100644 --- a/spring-cloud-data-flow/pom.xml +++ b/spring-cloud-data-flow/pom.xml @@ -7,7 +7,6 @@ 0.0.1-SNAPSHOT spring-cloud-data-flow pom - com.baeldung parent-boot-2 diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml index c9cd56bea6..c313e2026a 100644 --- a/spring-cloud/spring-cloud-aws/pom.xml +++ b/spring-cloud/spring-cloud-aws/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml b/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml index dc6e196325..5326e181e0 100644 --- a/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml @@ -16,4 +16,4 @@ 1.0.0-SNAPSHOT - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-connectors-heroku/pom.xml b/spring-cloud/spring-cloud-connectors-heroku/pom.xml index 967b1b3caf..b13c512cc0 100644 --- a/spring-cloud/spring-cloud-connectors-heroku/pom.xml +++ b/spring-cloud/spring-cloud-connectors-heroku/pom.xml @@ -28,7 +28,7 @@ - + org.springframework.boot spring-boot-starter-cloud-connectors ${spring-boot-starter-cloud-connectors.version} @@ -57,9 +57,9 @@ - 2.2.6.RELEASE + 2.2.6.RELEASE Hoxton.SR4 42.2.10 - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-dapr/pom.xml b/spring-cloud/spring-cloud-dapr/pom.xml index c2e9edaedc..436666b08e 100644 --- a/spring-cloud/spring-cloud-dapr/pom.xml +++ b/spring-cloud/spring-cloud-dapr/pom.xml @@ -17,4 +17,4 @@ greeting - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml b/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml index be65a6d7d3..cfea512399 100644 --- a/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml +++ b/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 docker-product-server - docker-product-server 1.0.0 + docker-product-server com.baeldung.spring.cloud diff --git a/spring-cloud/spring-cloud-docker/pom.xml b/spring-cloud/spring-cloud-docker/pom.xml index 3e407df6a1..f0f6b84fb0 100644 --- a/spring-cloud/spring-cloud-docker/pom.xml +++ b/spring-cloud/spring-cloud-docker/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-cloud-docker - spring-cloud-docker 1.0.0-SNAPSHOT + spring-cloud-docker pom diff --git a/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml b/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml index 73a0859785..741457529c 100644 --- a/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml +++ b/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring.cloud spring-cloud-hystrix 1.0.0-SNAPSHOT - ../ diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml index e916f2bc3e..cedd46dfef 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 client-service - client-service 1.0-SNAPSHOT + client-service com.baeldung.spring.cloud diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml index 725aa9cd3d..928f401405 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 liveness-example - liveness-example 1.0-SNAPSHOT + liveness-example com.baeldung.spring.cloud diff --git a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml index ba6cee1fce..1c8fa4e694 100644 --- a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml +++ b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/spring-ejb/pom.xml b/spring-ejb/pom.xml index 0b52fa52b1..003b428ff9 100755 --- a/spring-ejb/pom.xml +++ b/spring-ejb/pom.xml @@ -14,7 +14,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../ @@ -26,8 +25,8 @@ - + junit junit diff --git a/spring-quartz/pom.xml b/spring-quartz/pom.xml index 19ea302a1d..53b6962a60 100644 --- a/spring-quartz/pom.xml +++ b/spring-quartz/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-quartz - spring-quartz 0.0.1-SNAPSHOT + spring-quartz jar Demo project for Scheduling in Spring with Quartz diff --git a/spring-security-modules/spring-5-security-oauth/pom.xml b/spring-security-modules/spring-5-security-oauth/pom.xml index 194ace35b0..aa4958ae47 100644 --- a/spring-security-modules/spring-5-security-oauth/pom.xml +++ b/spring-security-modules/spring-5-security-oauth/pom.xml @@ -68,7 +68,8 @@ - + 2.5.2 com.baeldung.oauth2.SpringOAuthApplication diff --git a/spring-security-modules/spring-security-web-boot-3/pom.xml b/spring-security-modules/spring-security-web-boot-3/pom.xml index 9d09d60611..b26ca094be 100644 --- a/spring-security-modules/spring-security-web-boot-3/pom.xml +++ b/spring-security-modules/spring-security-web-boot-3/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-security-web-boot-3 0.0.1-SNAPSHOT diff --git a/spring-security-modules/spring-security-web-thymeleaf/pom.xml b/spring-security-modules/spring-security-web-thymeleaf/pom.xml index 8e6e0856af..3a240f4129 100644 --- a/spring-security-modules/spring-security-web-thymeleaf/pom.xml +++ b/spring-security-modules/spring-security-web-thymeleaf/pom.xml @@ -29,7 +29,6 @@ org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-starter-test diff --git a/testing-modules/assertion-libraries/pom.xml b/testing-modules/assertion-libraries/pom.xml index 14e0379a3c..57d38746ab 100644 --- a/testing-modules/assertion-libraries/pom.xml +++ b/testing-modules/assertion-libraries/pom.xml @@ -19,7 +19,8 @@ truth ${truth.version} - + junit junit @@ -54,7 +55,8 @@ ${jgotesting.version} test - + junit junit diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index 9f132c7562..ee4dcf8335 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 selenium-junit-testng 0.0.1-SNAPSHOT From 478829067e3cf0e43de0ec204c99161d0bfb99ff Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 9 Nov 2021 16:38:07 +0530 Subject: [PATCH 142/551] fix build --- maven-modules/maven-printing-plugins/pom.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/maven-modules/maven-printing-plugins/pom.xml b/maven-modules/maven-printing-plugins/pom.xml index aacc829b93..07ddd8d1e8 100644 --- a/maven-modules/maven-printing-plugins/pom.xml +++ b/maven-modules/maven-printing-plugins/pom.xml @@ -76,10 +76,8 @@ log.info('Test message: {}', 'Hello, World!') - log.info('Embed a - line break {}', System.lineSeparator()) - log.info('ArtifactId is: - ${project.artifactId}') + log.info('Embed a line break {}', System.lineSeparator()) + log.info('ArtifactId is: ${project.artifactId}') log.warn('Message only in debug mode') From afe1cfae090bffd2d7da6ec37c0ea31155b1c0a9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 9 Nov 2021 12:36:38 +0100 Subject: [PATCH 143/551] JAVA-8202: Move spring-boot-react to the heavy profile --- pom.xml | 4 ++++ spring-boot-modules/pom.xml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2a53f38b7..1b712786d8 100644 --- a/pom.xml +++ b/pom.xml @@ -764,6 +764,8 @@ libraries-5 libraries-6 + spring-boot-modules/spring-boot-react + vaadin vavr vavr-2 @@ -1217,6 +1219,8 @@ libraries-5 libraries-6 + spring-boot-modules/spring-boot-react + vaadin vavr vavr-2 diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 0e4c2fe60b..9e0c49a12d 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -72,7 +72,6 @@ spring-boot-vue spring-boot-actuator spring-boot-data-2 - spring-boot-react spring-boot-validation From 33890e34b0a29518e8f8a7b02b3325bff4052d4e Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Tue, 9 Nov 2021 22:12:33 +0530 Subject: [PATCH 144/551] JAVA-1673: removing junit and surefire configs from maven-modules --- .../maven-copy-files/copy-rename-maven-plugin/pom.xml | 2 +- maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml | 2 +- .../maven-copy-files/maven-resources-plugin/pom.xml | 2 +- maven-modules/maven-copy-files/pom.xml | 2 +- maven-modules/maven-integration-test/pom.xml | 7 +++---- maven-modules/maven-multi-source/pom.xml | 3 +-- maven-modules/maven-plugins/pom.xml | 5 ++--- maven-modules/pom.xml | 4 ---- 8 files changed, 10 insertions(+), 17 deletions(-) diff --git a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml index 6feb8284e6..06a44ed4fb 100644 --- a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml +++ b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml index 5168e0e965..b005f4b125 100644 --- a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml @@ -57,7 +57,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml index 6829898b45..a49095f528 100644 --- a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-copy-files/pom.xml b/maven-modules/maven-copy-files/pom.xml index 94bf952361..57d0ddf647 100644 --- a/maven-modules/maven-copy-files/pom.xml +++ b/maven-modules/maven-copy-files/pom.xml @@ -51,7 +51,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-integration-test/pom.xml b/maven-modules/maven-integration-test/pom.xml index 01be0ad1a4..56c243e3c5 100644 --- a/maven-modules/maven-integration-test/pom.xml +++ b/maven-modules/maven-integration-test/pom.xml @@ -86,8 +86,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} DataTest.java @@ -171,8 +171,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} DataTest.java @@ -217,8 +217,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} integration-test @@ -269,7 +269,6 @@ 3.0.2 3.8.0 - 2.22.0 2.22.0 1.1 3.0.0 diff --git a/maven-modules/maven-multi-source/pom.xml b/maven-modules/maven-multi-source/pom.xml index 65e00419af..d9863b31a9 100644 --- a/maven-modules/maven-multi-source/pom.xml +++ b/maven-modules/maven-multi-source/pom.xml @@ -54,8 +54,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} integration-test @@ -81,7 +81,6 @@ 3.0.2 3.8.0 - 2.22.0 2.22.0 1.1 3.0.0 diff --git a/maven-modules/maven-plugins/pom.xml b/maven-modules/maven-plugins/pom.xml index 29b3b550ea..4aa295c8a8 100644 --- a/maven-modules/maven-plugins/pom.xml +++ b/maven-modules/maven-plugins/pom.xml @@ -84,8 +84,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} DataTest.java @@ -105,8 +105,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} integration-test @@ -132,7 +132,6 @@ 3.0.2 3.8.0 - 2.22.0 2.22.0 1.1 3.0.0 diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index 0aadb873e5..3bd2c8b9ec 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -57,8 +57,4 @@ - - 5.8.1 - - \ No newline at end of file From 2acb6ff29132bbf62c650cd9c33d2b3219f201b9 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Wed, 10 Nov 2021 09:36:41 +0530 Subject: [PATCH 145/551] JAVA-1673: updating surefire plugin in xml module --- xml/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xml/pom.xml b/xml/pom.xml index f88f0f89b0..d8aa77583b 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -178,8 +178,8 @@ ${maven-compiler-plugin.version} + org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} @@ -242,7 +242,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} CustomerTest.java From 7af6badf6302fa8b94d3d10eb1c1c63a9a607cc9 Mon Sep 17 00:00:00 2001 From: mbarriola <85458535+mbarriola@users.noreply.github.com> Date: Wed, 10 Nov 2021 03:27:28 -0500 Subject: [PATCH 146/551] Baeldung/java 5187 (#11431) * Commit source code to branch * BAEL-5065 improvement of groupBy with complex key * Client and Server SSLSocket implementation to support https client authentication. --- .../SSLScocketClient.java | 41 +++++++++++++++++ .../SSLSocketEchoServer.java | 46 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLScocketClient.java create mode 100644 core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLSocketEchoServer.java diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLScocketClient.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLScocketClient.java new file mode 100644 index 0000000000..286ecfc9df --- /dev/null +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLScocketClient.java @@ -0,0 +1,41 @@ +package com.baeldung.httpsclientauthentication; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; + +public class SSLScocketClient { + + static void startClient(String host, int port) throws IOException { + + SocketFactory factory = SSLSocketFactory.getDefault(); + + try (SSLSocket socket = (SSLSocket) factory.createSocket(host, port)) { + socket.setEnabledCipherSuites(new String[] { "TLS_AES_128_GCM_SHA256" }); + socket.setEnabledProtocols(new String[] { "TLSv1.3" }); + InputStream is = new BufferedInputStream(socket.getInputStream()); + String message = "Hello World Message"; + System.out.println("sending message: " + message); + OutputStream os = new BufferedOutputStream(socket.getOutputStream()); + os.write(message.getBytes()); + os.flush(); + byte[] data = new byte[2048]; + int len = is.read(data); + if (len <= 0) { + throw new IOException("no data received"); + } + System.out.printf("client received %d bytes: %s%n", len, new String(data, 0, len)); + } + } + + public static void main(String[] args) throws IOException { + + startClient("localhost", 8443); + } +} diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLSocketEchoServer.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLSocketEchoServer.java new file mode 100644 index 0000000000..66efa18fe9 --- /dev/null +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/httpsclientauthentication/SSLSocketEchoServer.java @@ -0,0 +1,46 @@ +package com.baeldung.httpsclientauthentication; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; + +import javax.net.ServerSocketFactory; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; + +public class SSLSocketEchoServer { + + static void startServer(int port) throws IOException { + + ServerSocketFactory factory = SSLServerSocketFactory.getDefault(); + + try (SSLServerSocket listener = (SSLServerSocket) factory.createServerSocket(port)) { + listener.setNeedClientAuth(true); + listener.setEnabledCipherSuites(new String[] { "TLS_AES_128_GCM_SHA256" }); + listener.setEnabledProtocols(new String[] { "TLSv1.3" }); + System.out.println("listening for messages..."); + try (Socket socket = listener.accept()) { + InputStream is = new BufferedInputStream(socket.getInputStream()); + OutputStream os = new BufferedOutputStream(socket.getOutputStream()); + byte[] data = new byte[2048]; + int len = is.read(data); + if (len <= 0) { + throw new IOException("no data received"); + } + String message = new String(data, 0, len); + System.out.printf("server received %d bytes: %s%n", len, message); + String response = message + " processed by server"; + os.write(response.getBytes(), 0, response.getBytes().length); + os.flush(); + } + System.out.println("message processed, exiting"); + } + } + + public static void main(String[] args) throws IOException { + startServer(8443); + } +} \ No newline at end of file From 151753d3ac2b2d4be8aa07cc95a33b8a1420eabf Mon Sep 17 00:00:00 2001 From: Trixi Turny Date: Mon, 8 Nov 2021 17:52:38 +0000 Subject: [PATCH 147/551] BAEL-5209 add to modules sdk9 and above --- pom.xml | 2 ++ testing-modules/pom.xml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2a53f38b7..3b396bd2c5 100644 --- a/pom.xml +++ b/pom.xml @@ -1310,6 +1310,7 @@ persistence-modules/sirix quarkus-vs-springboot spring-boot-modules/spring-boot-cassandre + testing-modules/testing-assertions @@ -1362,6 +1363,7 @@ persistence-modules/sirix quarkus-vs-springboot spring-boot-modules/spring-boot-cassandre + testing-modules/testing-assertions diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index 079c7fa792..1e4ff246f9 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -42,7 +42,6 @@ spring-testing-2 spring-testing test-containers - testing-assertions testing-libraries-2 testing-libraries testng From 5e3132d2029e0166ace9b1e4f380b5cac03b706d Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:13:39 +0800 Subject: [PATCH 148/551] Update README.md --- core-java-modules/core-java-lang-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-4/README.md b/core-java-modules/core-java-lang-4/README.md index 4546a00fe6..e2a74b36af 100644 --- a/core-java-modules/core-java-lang-4/README.md +++ b/core-java-modules/core-java-lang-4/README.md @@ -9,3 +9,4 @@ This module contains articles about core features in the Java language - [Referencing a Method in Javadoc Comments](https://www.baeldung.com/java-method-in-javadoc) - [Tiered Compilation in JVM](https://www.baeldung.com/jvm-tiered-compilation) - [Fixing the “Declared package does not match the expected package” Error](https://www.baeldung.com/java-declared-expected-package-error) +- [Chaining Constructors in Java](https://www.baeldung.com/java-chain-constructors) From ec95bf31fac08e519c48e5ee452fa3fa9e442fac Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:17:13 +0800 Subject: [PATCH 149/551] Update README.md --- docker/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/README.md b/docker/README.md index 8aca8e4293..0de3694215 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,3 +5,4 @@ - [Running Spring Boot with PostgreSQL in Docker Compose](https://www.baeldung.com/spring-boot-postgresql-docker) - [How To Configure Java Heap Size Inside a Docker Container](https://www.baeldung.com/ops/docker-jvm-heap-size) - [Dockerfile Strategies for Git](https://www.baeldung.com/ops/dockerfile-git-strategies) +- [How to Get Docker-Compose to Always Use the Latest Image](https://www.baeldung.com/ops/docker-compose-latest-image) From c542d486ca600c7923f1b6ad886cdcaa72485175 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:20:50 +0800 Subject: [PATCH 150/551] Update README.md --- core-java-modules/core-java-17/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-17/README.md b/core-java-modules/core-java-17/README.md index 074c5e4f86..88cd1c3648 100644 --- a/core-java-modules/core-java-17/README.md +++ b/core-java-modules/core-java-17/README.md @@ -1,3 +1,4 @@ ### Relevant articles: - [Pattern Matching for Switch](https://www.baeldung.com/java-switch-pattern-matching) +- [Introduction to HexFormat in Java 17](https://www.baeldung.com/java-hexformat) From 5c97f5c421dfef1633ac5fafdefbbf2b5878795e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:22:38 +0800 Subject: [PATCH 151/551] Update README.md --- core-java-modules/core-java-17/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-17/README.md b/core-java-modules/core-java-17/README.md index 88cd1c3648..688ef2845d 100644 --- a/core-java-modules/core-java-17/README.md +++ b/core-java-modules/core-java-17/README.md @@ -2,3 +2,4 @@ - [Pattern Matching for Switch](https://www.baeldung.com/java-switch-pattern-matching) - [Introduction to HexFormat in Java 17](https://www.baeldung.com/java-hexformat) +- [New Features in Java 17](https://www.baeldung.com/java-17-new-features) From e0c1239984b6009f67f3cffc18b1c4cbeeed7cd1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:26:58 +0800 Subject: [PATCH 152/551] Update README.md --- core-java-modules/core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java/README.md b/core-java-modules/core-java/README.md index f1cf2d8c09..3285a7e663 100644 --- a/core-java-modules/core-java/README.md +++ b/core-java-modules/core-java/README.md @@ -13,3 +13,4 @@ - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) - [Deserialization Vulnerabilities in Java](https://www.baeldung.com/java-deserialization-vulnerabilities) - [Generating Alphanumeric UUID String in Java](https://www.baeldung.com/java-generate-alphanumeric-uuid) +- [Serialization Validation in Java](https://www.baeldung.com/java-validate-serializable) From 87dfb9e1102b68ac95b5354ab96a97292dfc2c3e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:31:26 +0800 Subject: [PATCH 153/551] Update README.md --- spring-boot-modules/spring-boot-actuator/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-actuator/README.md b/spring-boot-modules/spring-boot-actuator/README.md index 9e2f30786f..59f7e929da 100644 --- a/spring-boot-modules/spring-boot-actuator/README.md +++ b/spring-boot-modules/spring-boot-actuator/README.md @@ -11,3 +11,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Custom Information in Spring Boot Info Endpoint](https://www.baeldung.com/spring-boot-info-actuator-custom) - [Health Indicators in Spring Boot](https://www.baeldung.com/spring-boot-health-indicators) - [How to Enable All Endpoints in Spring Boot Actuator](https://www.baeldung.com/spring-boot-actuator-enable-endpoints) +- [Spring Boot Startup Actuator Endpoint](https://www.baeldung.com/spring-boot-actuator-startup) From a5d943a6d159c89f4b70a1ca81e60ff4cbcf8394 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:33:10 +0800 Subject: [PATCH 154/551] Update README.md --- core-java-modules/core-java-string-operations-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-3/README.md b/core-java-modules/core-java-string-operations-3/README.md index dc42862e5d..b22cf56e3a 100644 --- a/core-java-modules/core-java-string-operations-3/README.md +++ b/core-java-modules/core-java-string-operations-3/README.md @@ -9,3 +9,4 @@ - [Remove Accents and Diacritics From a String in Java](https://www.baeldung.com/java-remove-accents-from-text) - [Remove Beginning and Ending Double Quotes from a String](https://www.baeldung.com/java-remove-start-end-double-quote) - [Splitting a Java String by Multiple Delimiters](https://www.baeldung.com/java-string-split-multiple-delimiters) +- [Split a String Only on the First Occurrence of Delimiter](https://www.baeldung.com/java-split-string-first-delimiter) From eae84c2db78c99b814d98c2685fe19fede16633c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:34:43 +0800 Subject: [PATCH 155/551] Update README.md --- core-java-modules/core-java-security-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-security-3/README.md b/core-java-modules/core-java-security-3/README.md index a37719964b..10e9773f9b 100644 --- a/core-java-modules/core-java-security-3/README.md +++ b/core-java-modules/core-java-security-3/README.md @@ -6,4 +6,5 @@ This module contains articles about core Java Security - [Secret Key and String Conversion in Java](https://www.baeldung.com/java-secret-key-to-string) - [Enabling Unlimited Strength Cryptography in Java](https://www.baeldung.com/jce-enable-unlimited-strength) +- [Initialization Vector for Encryption](https://www.baeldung.com/java-encryption-iv) - More articles: [[<-- prev]](/core-java-modules/core-java-security-2) From f1ec3e0f3fe3224576dc892aae70334e627b4524 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:36:32 +0800 Subject: [PATCH 156/551] Update README.md --- core-java-modules/core-java-jvm-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-jvm-2/README.md b/core-java-modules/core-java-jvm-2/README.md index ccca3a11ac..94ebe262c8 100644 --- a/core-java-modules/core-java-jvm-2/README.md +++ b/core-java-modules/core-java-jvm-2/README.md @@ -12,4 +12,5 @@ This module contains articles about working with the Java Virtual Machine (JVM). - [Memory Address of Objects in Java](https://www.baeldung.com/java-object-memory-address) - [List All Classes Loaded in a Specific Class Loader](https://www.baeldung.com/java-list-classes-class-loader) - [An Introduction to the Constant Pool in the JVM](https://www.baeldung.com/jvm-constant-pool) +- [List All the Classes Loaded in the JVM](https://www.baeldung.com/jvm-list-all-classes-loaded) - More articles: [[<-- prev]](/core-java-modules/core-java-jvm) From e32cba0373bc53191b4cc2e3e8cede5fc42bb8f9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:41:57 +0800 Subject: [PATCH 157/551] Update README.md --- core-java-modules/core-java-collections-maps-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-collections-maps-4/README.md b/core-java-modules/core-java-collections-maps-4/README.md index 54ab60da7d..cb25aa5a8a 100644 --- a/core-java-modules/core-java-collections-maps-4/README.md +++ b/core-java-modules/core-java-collections-maps-4/README.md @@ -4,3 +4,4 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: - [Using a Custom Class as a Key in a Java HashMap](https://www.baeldung.com/java-custom-class-map-key) +- [Nested HashMaps Examples in Java](https://www.baeldung.com/java-nested-hashmaps) From 7cbe98f895b70c1a0672b3e99e2201035d957dff Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:43:19 +0800 Subject: [PATCH 158/551] Update README.md --- core-java-modules/core-java-string-algorithms-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-algorithms-2/README.md b/core-java-modules/core-java-string-algorithms-2/README.md index dbfbb3ef3c..aa71e5f59e 100644 --- a/core-java-modules/core-java-string-algorithms-2/README.md +++ b/core-java-modules/core-java-string-algorithms-2/README.md @@ -13,4 +13,5 @@ This module contains articles about string-related algorithms. - [Remove Leading and Trailing Characters from a String](https://www.baeldung.com/java-remove-trailing-characters) - [Counting Words in a String with Java](https://www.baeldung.com/java-word-counting) - [Finding the Difference Between Two Strings in Java](https://www.baeldung.com/java-difference-between-two-strings) +- [Check if the First Letter of a String is Uppercase](https://www.baeldung.com/java-check-first-letter-uppercase) - More articles: [[<-- prev]](../core-java-string-algorithms) From f89d4d5b33a621cbdc706b0de5199533f2ead048 Mon Sep 17 00:00:00 2001 From: freelansam <79205526+freelansam@users.noreply.github.com> Date: Thu, 11 Nov 2021 11:39:01 +0530 Subject: [PATCH 159/551] correction to core-java-os --- core-java-modules/core-java-os/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 8265e47192..c0eac46db8 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ @@ -90,4 +89,4 @@ 1.8.7 - \ No newline at end of file + From c7978bf0e5505732c7425559518ad9b7fb923c70 Mon Sep 17 00:00:00 2001 From: Max Zhilin Date: Thu, 11 Nov 2021 09:35:20 +0300 Subject: [PATCH 160/551] Update README.md Link to next page --- core-java-modules/core-java-io-3/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-io-3/README.md b/core-java-modules/core-java-io-3/README.md index d0ac5387a8..312797cb94 100644 --- a/core-java-modules/core-java-io-3/README.md +++ b/core-java-modules/core-java-io-3/README.md @@ -14,4 +14,4 @@ This module contains articles about core Java input and output (IO) - [Find the Last Modified File in a Directory with Java](https://www.baeldung.com/java-last-modified-file) - [Get a Filename Without the Extension in Java](https://www.baeldung.com/java-filename-without-extension) - [Writing byte[] to a File in Java](https://www.baeldung.com/java-write-byte-array-file) -- [[<-- Prev]](/core-java-modules/core-java-io-2) +- [[<-- Prev]](/core-java-modules/core-java-io-2)[[More -->]](/core-java-modules/core-java-io-4) From 4dc1a31a5b406ad62cb97ff1aa2c3b1d4d0b534d Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Thu, 11 Nov 2021 15:47:37 +0100 Subject: [PATCH 161/551] Spring Webflux and @Cacheable Annotation - moved to different module --- pom.xml | 3 - spring-5-webflux/pom.xml | 20 ++++++ .../com/baeldung/spring}/caching/Item.java | 2 +- .../spring}/caching/ItemRepository.java | 2 +- .../baeldung/spring}/caching/ItemService.java | 2 +- .../SpringWebfluxCachingApplication.java | 2 +- .../resources/application-cache.properties | 0 .../MonoFluxResultCachingLiveTest.java | 6 +- spring-webflux-caching/pom.xml | 67 ------------------- 9 files changed, 27 insertions(+), 77 deletions(-) rename {spring-webflux-caching/src/main/java/com/baeldung => spring-5-webflux/src/main/java/com/baeldung/spring}/caching/Item.java (96%) rename {spring-webflux-caching/src/main/java/com/baeldung => spring-5-webflux/src/main/java/com/baeldung/spring}/caching/ItemRepository.java (85%) rename {spring-webflux-caching/src/main/java/com/baeldung => spring-5-webflux/src/main/java/com/baeldung/spring}/caching/ItemService.java (96%) rename {spring-webflux-caching/src/main/java/com/baeldung => spring-5-webflux/src/main/java/com/baeldung/spring}/caching/SpringWebfluxCachingApplication.java (93%) rename spring-webflux-caching/src/main/resources/application.properties => spring-5-webflux/src/main/resources/application-cache.properties (100%) rename {spring-webflux-caching/src/test/java/com/baeldung => spring-5-webflux/src/test/java/com/baeldung/spring}/caching/MonoFluxResultCachingLiveTest.java (96%) delete mode 100644 spring-webflux-caching/pom.xml diff --git a/pom.xml b/pom.xml index 9a34ed0afe..f2a53f38b7 100644 --- a/pom.xml +++ b/pom.xml @@ -7,9 +7,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - - spring-webflux-caching - parent-modules pom diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index 69de83c227..cd3564d404 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -66,11 +66,31 @@ + + io.projectreactor.addons + reactor-extra + 3.4.5 + + + com.github.ben-manes.caffeine + caffeine + 3.0.4 + + + org.springframework.boot + spring-boot-starter-data-mongodb-reactive + io.projectreactor reactor-test test + + org.testcontainers + mongodb + 1.16.2 + test + com.squareup.okhttp3 mockwebserver diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java similarity index 96% rename from spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java rename to spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java index 127975b0e7..7b79ff7503 100644 --- a/spring-webflux-caching/src/main/java/com/baeldung/caching/Item.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java @@ -1,4 +1,4 @@ -package com.baeldung.caching; +package com.baeldung.spring.caching; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java similarity index 85% rename from spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java rename to spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java index a76489623e..27c97de36a 100644 --- a/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemRepository.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.caching; +package com.baeldung.spring.caching; import org.springframework.data.mongodb.repository.ReactiveMongoRepository; import org.springframework.stereotype.Repository; diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java similarity index 96% rename from spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java rename to spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java index 9dc9ba1642..b24b54521e 100644 --- a/spring-webflux-caching/src/main/java/com/baeldung/caching/ItemService.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java @@ -1,4 +1,4 @@ -package com.baeldung.caching; +package com.baeldung.spring.caching; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; diff --git a/spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java similarity index 93% rename from spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java rename to spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java index 7331576bd5..5266e33775 100644 --- a/spring-webflux-caching/src/main/java/com/baeldung/caching/SpringWebfluxCachingApplication.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.caching; +package com.baeldung.spring.caching; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-webflux-caching/src/main/resources/application.properties b/spring-5-webflux/src/main/resources/application-cache.properties similarity index 100% rename from spring-webflux-caching/src/main/resources/application.properties rename to spring-5-webflux/src/main/resources/application-cache.properties diff --git a/spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java b/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java similarity index 96% rename from spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java rename to spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java index bf96b35dcb..322b3c5aa5 100644 --- a/spring-webflux-caching/src/test/java/com/baeldung/caching/MonoFluxResultCachingLiveTest.java +++ b/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java @@ -1,11 +1,10 @@ -package com.baeldung.caching; +package com.baeldung.spring.caching; -import org.assertj.core.api.Assertions; -import org.junit.ClassRule; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; import org.testcontainers.containers.MongoDBContainer; @@ -15,6 +14,7 @@ import reactor.core.publisher.Mono; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest +@ActiveProfiles("cache") public class MonoFluxResultCachingLiveTest { diff --git a/spring-webflux-caching/pom.xml b/spring-webflux-caching/pom.xml deleted file mode 100644 index ed9800bce9..0000000000 --- a/spring-webflux-caching/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - com.baeldung.spring - spring-webflux-caching - 1.0.0-SNAPSHOT - spring-webflux-caching - jar - Spring WebFlux Caching Sample - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - - org.springframework.boot - spring-boot-starter-webflux - - - io.reactivex.rxjava2 - rxjava - 2.2.19 - - - io.projectreactor.addons - reactor-extra - 3.4.5 - - - com.github.ben-manes.caffeine - caffeine - 3.0.4 - - - org.springframework.boot - spring-boot-starter-data-mongodb-reactive - - - com.fasterxml.jackson.core - jackson-databind - - - org.springframework.boot - spring-boot-starter-test - test - - - io.projectreactor - reactor-test - test - - - org.testcontainers - mongodb - 1.16.2 - test - - - - \ No newline at end of file From 7f97bc1b983d3c0f6e6c029336519c81d16f547f Mon Sep 17 00:00:00 2001 From: ioanadinuit <83220826+ioanadinuit@users.noreply.github.com> Date: Thu, 11 Nov 2021 20:22:13 +0200 Subject: [PATCH 162/551] BAEL-5080 (#11436) * BAEL-5080 Custom validation with Swagger Codegen Add tutorial code * BAEL-5080 Custom validation with Swagger Codegen Formatting * BAEL-5080 Custom validation with Swagger Codegen Swagger doc update * remove Licence file --- .../README.md | 1 + .../pom.xml | 103 ++++++++++++ .../openapi/petstore/PetstoreApplication.java | 13 ++ .../petstore/controller/PetController.java | 17 ++ .../controller/PetControllerAdvice.java | 20 +++ .../petstore/validation/Camelcase.java | 22 +++ .../validation/CamelcaseValidator.java | 35 ++++ .../src/main/resources/application.properties | 1 + .../resources/openapi/templates/api.mustache | 150 ++++++++++++++++++ .../templates/beanValidationCore.mustache | 26 +++ .../openapi/templates/cookieParams.mustache | 1 + .../resources/openapi/templates/enum.mustache | 31 ++++ .../openapi/templates/model.mustache | 42 +++++ .../openapi/templates/modelEnum.mustache | 68 ++++++++ .../src/main/resources/petstore.yml | 65 ++++++++ 15 files changed, 595 insertions(+) create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache create mode 100644 spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md b/spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md new file mode 100644 index 0000000000..83eec25c03 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md @@ -0,0 +1 @@ +# This is a sample on how we can merge the OpenApi code generation with the a custom annotation using ConstraintValidator diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml b/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml new file mode 100644 index 0000000000..53e5006bf4 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + + com.example + petstore + 0.0.1-SNAPSHOT + petstore + Demo project for Swagger Custom Validations Codegen + + 11 + 3.0.0 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.hibernate + hibernate-validator + 6.0.10.Final + + + javax.validation + validation-api + 2.0.1.Final + + + org.openapitools + openapi-generator + 3.3.4 + + + io.springfox + springfox-oas + ${springfox-version} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0.pr3 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.openapitools + openapi-generator-maven-plugin + 5.1.0 + + + + generate + + + + ${project.basedir}/src/main/resources/petstore.yml + + spring + com.baeldung.openapi.api + com.baeldung.openapi.model + + ApiUtil.java + + + false + java8-localdatetime + + + src/main/resources/openapi/templates + + + + + + + + + + diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java new file mode 100644 index 0000000000..5a6372ba22 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.openapi.petstore; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PetstoreApplication { + + public static void main(String[] args) { + SpringApplication.run(PetstoreApplication.class, args); + } + +} diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java new file mode 100644 index 0000000000..081d0cb6f9 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java @@ -0,0 +1,17 @@ +package com.baeldung.openapi.petstore.controller; + +import com.baeldung.openapi.api.PetsApi; +import com.baeldung.openapi.model.Pet; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import java.util.Arrays; +import java.util.List; + +@Controller +public class PetController implements PetsApi { + + public ResponseEntity> findPetsByName(String name) { + return ResponseEntity.ok(Arrays.asList(new Pet().id(1L).name(name))); + } +} diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java new file mode 100644 index 0000000000..cf243dbb46 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java @@ -0,0 +1,20 @@ +package com.baeldung.openapi.petstore.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +import javax.validation.ConstraintViolationException; + +@ControllerAdvice +public class PetControllerAdvice { + + @ResponseBody + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(ConstraintViolationException.class) + public void handleConstraintViolationException() { + + } +} diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java new file mode 100644 index 0000000000..b0b0b739e2 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java @@ -0,0 +1,22 @@ +package com.baeldung.openapi.petstore.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.*; + +@Documented +@Constraint(validatedBy = {CamelcaseValidator.class}) +@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Camelcase { + + String message() default "Name should be uppercase."; + + boolean required() default true; + + Class[] groups() default {}; + + Class[] payload() default {}; + + String[] values() default {}; +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java new file mode 100644 index 0000000000..2b08e3dd2a --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java @@ -0,0 +1,35 @@ +package com.baeldung.openapi.petstore.validation; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.util.Objects; + +public class CamelcaseValidator implements ConstraintValidator { + + private Camelcase uppercaseAnnotation; + + public void initialize(Camelcase constraintAnnotation) { + this.uppercaseAnnotation = constraintAnnotation; + } + + @Override + public boolean isValid(String nameField, ConstraintValidatorContext context) { + String correctName = buildCorrectName(nameField); + if (uppercaseAnnotation.required() + && (Objects.isNull(nameField) || nameField.isBlank() + || !correctName.equals(nameField))) { + context = context + .buildConstraintViolationWithTemplate(this.uppercaseAnnotation.message()) + .addConstraintViolation(); + context.disableDefaultConstraintViolation(); + return false; + } + return true; + } + + private String buildCorrectName(String nameField) { + String upCase = String.valueOf(nameField.charAt(0)).toUpperCase(); + String lowCase = nameField.substring(1).toLowerCase(); + return upCase.concat(lowCase); + } +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties new file mode 100644 index 0000000000..d5e4d42eb8 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties @@ -0,0 +1 @@ +openapi.petStore.base-path=/ diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache new file mode 100644 index 0000000000..a7a35d43b5 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache @@ -0,0 +1,150 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://com.baeldung.openapi-generator.tech) ({{{generatorVersion}}}). + * https://com.baeldung.openapi-generator.tech + * Do not edit the class manually. + */ +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +import io.swagger.annotations.*; +import com.baeldung.openapi.petstore.validation.Camelcase; +{{#jdk8-no-delegate}} +{{#virtualService}} +import io.virtualan.annotation.ApiVirtual; +import io.virtualan.annotation.VirtualService; +{{/virtualService}} +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +{{/jdk8-no-delegate}} +import org.springframework.http.ResponseEntity; +{{#useBeanValidation}} +import org.springframework.validation.annotation.Validated; +{{/useBeanValidation}} +{{#vendorExtensions.x-spring-paginated}} +import org.springframework.data.domain.Pageable; +{{/vendorExtensions.x-spring-paginated}} +import org.springframework.web.bind.annotation.*; +{{#jdk8-no-delegate}} + {{^reactive}} +import org.springframework.web.context.request.NativeWebRequest; + {{/reactive}} +{{/jdk8-no-delegate}} +import org.springframework.web.multipart.MultipartFile; +{{#reactive}} +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; +{{/reactive}} +import springfox.documentation.annotations.ApiIgnore; + +{{#useBeanValidation}} +import javax.validation.Valid; +import javax.validation.constraints.*; +{{/useBeanValidation}} +import java.util.List; +import java.util.Map; +{{#jdk8-no-delegate}} +import java.util.Optional; +{{/jdk8-no-delegate}} +{{^jdk8-no-delegate}} + {{#useOptional}} +import java.util.Optional; + {{/useOptional}} +{{/jdk8-no-delegate}} +{{#async}} +import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; +{{/async}} +{{>generatedAnnotation}} +{{#useBeanValidation}} +@Validated +{{/useBeanValidation}} +@Api(value = "{{{baseName}}}", tags = "All") +{{#operations}} +{{#virtualService}} +@VirtualService +{{/virtualService}} +public interface {{classname}} { +{{#jdk8-default-interface}} + {{^isDelegate}} + {{^reactive}} + + default Optional getRequest() { + return Optional.empty(); + } + {{/reactive}} + {{/isDelegate}} + {{#isDelegate}} + + default {{classname}}Delegate getDelegate() { + return new {{classname}}Delegate() {}; + } + {{/isDelegate}} +{{/jdk8-default-interface}} +{{#operation}} + + /** + * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}} + {{#notes}} + * {{.}} + {{/notes}} + * + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + {{/allParams}} + * @return {{#responses}}{{message}} (status code {{code}}){{^-last}} + * or {{/-last}}{{/responses}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#virtualService}} + @ApiVirtual + {{/virtualService}} + @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { + {{#authMethods}}{{#isOAuth}}@Authorization(value = "{{name}}", scopes = { + {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}}, + {{/-last}}{{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}} + {{^isOAuth}}@Authorization(value = "{{name}}"){{^-last}},{{/-last}} + {{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) + @ApiResponses(value = { {{#responses}} + @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}} }) + {{#implicitHeaders}} + @ApiImplicitParams({ + {{#headerParams}} + {{>implicitHeader}} + {{/headerParams}} + }) + {{/implicitHeaders}} + @RequestMapping( + method = RequestMethod.{{httpMethod}}, + value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}}, + produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}}, + consumes = "{{{vendorExtensions.x-contentType}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, + produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}}, + consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}} + ) + {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},{{/-last}}{{#-last}}{{#reactive}}, {{/reactive}}{{/-last}}{{/allParams}}{{#reactive}}@ApiIgnore final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { + {{#delegate-method}} + return {{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); + } + + // Override this method + {{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}@ApiIgnore final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { + {{/delegate-method}} + {{^isDelegate}} + {{>methodBody}} + {{/isDelegate}} + {{#isDelegate}} + return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); + {{/isDelegate}} + }{{/jdk8-default-interface}} + +{{/operation}} +} +{{/operations}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache new file mode 100644 index 0000000000..e3c19c6474 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache @@ -0,0 +1,26 @@ +{{{ vendorExtensions.x-constraints }}} +{{#errorMessage}}@Mandatory(errorMessage="{{{pattern}}}") {{/errorMessage}} +{{#pattern}}@Pattern(regexp="{{{pattern}}}") {{/pattern}}{{! +minLength && maxLength set +}}{{#minLength}}{{#maxLength}}@Size(min={{minLength}},max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! +minLength set, maxLength not +}}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{! +minLength not set, maxLength set +}}{{^minLength}}{{#maxLength}}@Size(max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! +@Size: minItems && maxItems set +}}{{#minItems}}{{#maxItems}}@Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! +@Size: minItems set, maxItems not +}}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{! +@Size: minItems not set && maxItems set +}}{{^minItems}}{{#maxItems}}@Size(max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! +@Email: useBeanValidation set && isEmail && java8 set +}}{{#useBeanValidation}}{{#isEmail}}{{#java8}}@javax.validation.constraints.Email{{/java8}}{{/isEmail}}{{/useBeanValidation}}{{! +@Email: performBeanValidation set && isEmail && not java8 set +}}{{#performBeanValidation}}{{#isEmail}}{{^java8}}@org.hibernate.validator.constraints.Email{{/java8}}{{/isEmail}}{{/performBeanValidation}}{{! +check for integer or long / all others=decimal type with @Decimal* +isInteger set +}}{{#isInteger}}{{#minimum}}@Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}) {{/maximum}}{{/isInteger}}{{! +isLong set +}}{{#isLong}}{{#minimum}}@Min({{minimum}}L){{/minimum}}{{#maximum}} @Max({{maximum}}L) {{/maximum}}{{/isLong}}{{! +Not Integer, not Long => we have a decimal value! +}}{{^isInteger}}{{^isLong}}{{#minimum}}@DecimalMin({{#exclusiveMinimum}}value={{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}},inclusive=false{{/exclusiveMinimum}}){{/minimum}}{{#maximum}} @DecimalMax({{#exclusiveMaximum}}value={{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}},inclusive=false{{/exclusiveMaximum}}) {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache new file mode 100644 index 0000000000..e21bd9ff4b --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache @@ -0,0 +1 @@ +{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) @CookieValue("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isCookieParam}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache new file mode 100644 index 0000000000..3cdae7f3cc --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache @@ -0,0 +1,31 @@ +class {{classname}} { + /// The underlying value of this enum member. + {{dataType}} value; + + {{classname}}._internal(this.value); + {{ vendorExtensions.x-enum-varnames }} + {{ vendorExtensions.x-enum-descriptions }} + {{#allowableValues}} + {{#enumVars}} + {{#description}} + /// {{description}} + {{/description}} + static {{classname}} {{name}} = {{classname}}._internal({{{value}}}); + {{/enumVars}} + {{/allowableValues}} + + {{classname}}.fromJson(dynamic data) { + switch (data) { + {{#allowableValues}} + {{#enumVars}} + case {{{value}}}: value = data; break; + {{/enumVars}} + {{/allowableValues}} + default: throw('Unknown enum value to decode: $data'); + } + } + + static dynamic encode({{classname}} data) { + return data.value; + } +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache new file mode 100644 index 0000000000..d9329b40d3 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache @@ -0,0 +1,42 @@ +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +import com.fasterxml.jackson.databind.annotation.*; +import com.fasterxml.jackson.annotation.*; +import com.baeldung.openapi.petstore.validation.Camelcase; +{{^supportJava6}} +import java.util.Objects; +import java.util.Arrays; +{{/supportJava6}} +{{#supportJava6}} +import org.apache.commons.lang3.ObjectUtils; +{{/supportJava6}} +{{#imports}} +import {{import}}; +{{/imports}} +{{#serializableModel}} +import java.io.Serializable; +{{/serializableModel}} +{{#jackson}} +{{#withXml}} +import com.fasterxml.jackson.dataformat.xml.annotation.*; +{{/withXml}} +{{/jackson}} +{{#withXml}} +import javax.xml.bind.annotation.*; +{{/withXml}} +{{#parcelableModel}} +import android.os.Parcelable; +import android.os.Parcel; +{{/parcelableModel}} +{{#useBeanValidation}} +import javax.validation.constraints.*; +import javax.validation.Valid; +{{/useBeanValidation}} + +{{#models}} +{{#model}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>pojo}}{{/isEnum}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache new file mode 100644 index 0000000000..29f27bd851 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache @@ -0,0 +1,68 @@ +{{#jackson}} +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +{{/jackson}} +{{#gson}} +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +{{/gson}} + +/** + * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} + */ +{{#gson}} +@JsonAdapter({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class) +{{/gson}} +public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { + {{#allowableValues}}{{#enumVars}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + + private {{{dataType}}} value; + + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { + this.value = value; + } + +{{#jackson}} + @JsonValue +{{/jackson}} + public {{{dataType}}} getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +{{#jackson}} + @JsonCreator +{{/jackson}} + public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue{{#jackson}}({{{dataType}}} value){{/jackson}}{{^jackson}}(String text){{/jackson}} { + for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if ({{#jackson}}b.value.equals(value){{/jackson}}{{^jackson}}String.valueOf(b.value).equals(text){{/jackson}}) { + return b; + } + } + throw new UlpValidationException(UlpBundleKey.{{vendorExtensions.x-enum-invalidtag}}); + } +{{#gson}} + + public static class Adapter extends TypeAdapter<{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> { + @Override + public void write(final JsonWriter jsonWriter, final {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException { + {{#isNumber}}BigDecimal value = new BigDecimal(jsonReader.nextDouble()){{/isNumber}}{{^isNumber}}{{#isInteger}}Integer value {{/isInteger}}{{^isInteger}}String value {{/isInteger}}= jsonReader.{{#isInteger}}nextInt(){{/isInteger}}{{^isInteger}}nextString(){{/isInteger}}{{/isNumber}}; + return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#jackson}}value{{/jackson}}{{^jackson}}String.valueOf(value){{/jackson}}); + } + } +{{/gson}} +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml new file mode 100644 index 0000000000..c9884c01e8 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml @@ -0,0 +1,65 @@ +openapi: 3.0.1 +info: + version: "1.0" + title: PetStore +paths: + /pets: + post: + tags: + - pet + summary: Add a new pet to the store + description: Add a new pet to the store + operationId: addPet + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + responses: + '201': + description: default response, returning the new pet id + content: + application/json: + schema: + type: integer + '400': + description: Invalid input + get: + tags: + - pet + summary: Finds Pets by name + description: 'Find pets by name' + operationId: findPetsByName + parameters: + - name: name + in: query + schema: + type: string + description: Tags to filter by + x-constraints: "@Camelcase(required = true)" + responses: + '200': + description: default response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid name value +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + x-constraints: "@Camelcase(required = true)" \ No newline at end of file From ddf531faa7b99d06eae049fd6058fe72e32d4aaa Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Thu, 11 Nov 2021 23:19:32 +0100 Subject: [PATCH 163/551] BAEL-5194 rm html tags (#11404) --- xml/pom.xml | 19 ++++++ .../delhtmltags/RemoveHtmlTagsLiveTest.java | 61 +++++++++++++++++++ .../xmlhtml/delhtmltags/example1.html | 15 +++++ .../xmlhtml/delhtmltags/example2.html | 22 +++++++ 4 files changed, 117 insertions(+) create mode 100644 xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java create mode 100644 xml/src/test/resources/xmlhtml/delhtmltags/example1.html create mode 100644 xml/src/test/resources/xmlhtml/delhtmltags/example2.html diff --git a/xml/pom.xml b/xml/pom.xml index d8aa77583b..d05f2401e3 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -14,6 +14,22 @@ + + org.jsoup + jsoup + ${jsoup.version} + + + net.sourceforge.htmlcleaner + htmlcleaner + ${htmlcleaner.version} + + + net.htmlparser.jericho + jericho-html + ${jericho.version} + + org.dom4j @@ -361,6 +377,9 @@ 1.3.1 3.8.0 + 1.14.3 + 2.25 + 3.4 \ No newline at end of file diff --git a/xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java b/xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java new file mode 100644 index 0000000000..b05123cbdc --- /dev/null +++ b/xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java @@ -0,0 +1,61 @@ +package com.baeldung.xmlhtml.delhtmltags; + +import net.htmlparser.jericho.Renderer; +import net.htmlparser.jericho.Segment; +import net.htmlparser.jericho.Source; +import org.htmlcleaner.CleanerProperties; +import org.htmlcleaner.HtmlCleaner; +import org.jsoup.Jsoup; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; + +class RemoveHtmlTagsLiveTest { + + @Test + void givenHtml1_whenRemoveTagsByRegex_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example1.html").toURI())))); + String result = html.replaceAll("<[^>]*>", "") + .replaceAll("(?m)^\\s*$", ""); // remove empty and blank lines + System.out.println(result); + } + + @Test + void givenHtml2_whenRemoveTagsByRegex_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + String result = html.replaceAll("<[^>]*>", ""); + System.out.println(result); + } + + @Test + void givenHtml2_whenRemoveTagsByJsoup_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + System.out.println(Jsoup.parse(html).text()); + } + + @Test + void givenHtml2_whenRemoveTagsByHtmlCleaner_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + CleanerProperties props = new CleanerProperties(); + props.setPruneTags("script"); + String result = new HtmlCleaner(props).clean(html).getText().toString(); + System.out.println(result); + } + + @Test + void givenHtml2_whenRemoveTagsByJericho_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + Source htmlSource = new Source(html); + Segment segment = new Segment(htmlSource, 0, htmlSource.length()); + Renderer htmlRender = new Renderer(segment).setIncludeHyperlinkURLs(true); + System.out.println(htmlRender); + } +} diff --git a/xml/src/test/resources/xmlhtml/delhtmltags/example1.html b/xml/src/test/resources/xmlhtml/delhtmltags/example1.html new file mode 100644 index 0000000000..43f3a22ef4 --- /dev/null +++ b/xml/src/test/resources/xmlhtml/delhtmltags/example1.html @@ -0,0 +1,15 @@ + + + + This is the page title + + +

+ If the application X doesn't start, the possible causes could be:
+ 1. Maven is not installed.
+ 2. Not enough disk space.
+ 3. Not enough memory. +

+ + \ No newline at end of file diff --git a/xml/src/test/resources/xmlhtml/delhtmltags/example2.html b/xml/src/test/resources/xmlhtml/delhtmltags/example2.html new file mode 100644 index 0000000000..532eadc101 --- /dev/null +++ b/xml/src/test/resources/xmlhtml/delhtmltags/example2.html @@ -0,0 +1,22 @@ + + + + This is the page title + + + +

+ If the application X doesn't start, the possible causes could be:
+ 1. + Maven + is not installed.
+ 2. Not enough (<1G) disk space.
+ 3. Not enough (<64MB) memory.
+

+ + \ No newline at end of file From f741713458df29630a75ac9ed079321ff02dcd5c Mon Sep 17 00:00:00 2001 From: janmadle <85927377+janmadle@users.noreply.github.com> Date: Fri, 12 Nov 2021 09:16:13 +0100 Subject: [PATCH 164/551] fixed missing parameter Fixed not working example - Added missing zipParameters to .addFile() function --- .../src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java index d0947afa2e..7639a2e9df 100644 --- a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java @@ -21,7 +21,7 @@ public class ZipSingleFile { if (!fileToAdd.exists()) { fileToAdd.createNewFile(); } - zipFile.addFile(fileToAdd); + zipFile.addFile(fileToAdd, zipParameters); zipFile.close(); } } From 6f5a8b267474d7dc9d922f79e2c95a6cc22bf24e Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 12 Nov 2021 20:20:11 +0530 Subject: [PATCH 165/551] JAVA-8395: Delete module simplehexagonalexample --- patterns/simplehexagonalexample/pom.xml | 32 ----- .../simplehexagonalex/DailyQuoteMain.java | 32 ----- .../controller/QuoteCliController.java | 24 ---- .../controller/QuoteRestController.java | 24 ---- .../domain/QuoteOfTheDay.java | 56 --------- .../repository/QuoteOfTheDayFromProvider.java | 8 -- .../domain/service/QuoteAggregator.java | 22 ---- .../domain/service/QuoteService.java | 8 -- .../primary/quoteadapter/ProviderQuote.java | 109 ------------------ .../quoteadapter/ProviderQuoteAdapter.java | 54 --------- .../quoteadapter/ProviderQuoteEnvelope.java | 68 ----------- .../mock/quoteadapter/MockQuoteAdapter.java | 20 ---- .../src/main/resources/application.properties | 1 - .../MockAccessProviderUnitTest.java | 22 ---- .../PrimaryAccessProviderIntegrationTest.java | 28 ----- .../QuoteRequestIntegrationTest.java | 36 ------ .../src/test/resources/application.properties | 1 - 17 files changed, 545 deletions(-) delete mode 100644 patterns/simplehexagonalexample/pom.xml delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java delete mode 100644 patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java delete mode 100644 patterns/simplehexagonalexample/src/main/resources/application.properties delete mode 100644 patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java delete mode 100644 patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java delete mode 100644 patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java delete mode 100644 patterns/simplehexagonalexample/src/test/resources/application.properties diff --git a/patterns/simplehexagonalexample/pom.xml b/patterns/simplehexagonalexample/pom.xml deleted file mode 100644 index 31e829b7dc..0000000000 --- a/patterns/simplehexagonalexample/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - 4.0.0 - 1.0.0-SNAPSHOT - simple-hexagonal-example - simple-hexagonal-example - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - \ No newline at end of file diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java deleted file mode 100644 index de8b2f4793..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.simplehexagonalex; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import com.baeldung.simplehexagonalex.controller.QuoteCliController; -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; - -@SpringBootApplication -public class DailyQuoteMain implements CommandLineRunner { - - private static final Logger LOG = LoggerFactory.getLogger(DailyQuoteMain.class); - @Autowired - private QuoteCliController quoteCliController; - - public static void main(final String[] args) { - - SpringApplication.run(DailyQuoteMain.class, args); - } - - @Override - public void run(String... args) throws Exception { - - QuoteOfTheDay quoteOfTheDay = quoteCliController.getQuote("cliController"); - - LOG.info(quoteOfTheDay.toString()); - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java deleted file mode 100644 index 9ecb2bf822..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.simplehexagonalex.controller; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.service.QuoteService; - -@Component -public class QuoteCliController { - - private static final Logger LOG = LoggerFactory.getLogger(QuoteCliController.class); - - @Autowired - private QuoteService quoteService; - - public QuoteOfTheDay getQuote(String userId) { - - LOG.info("Getting quote"); - return quoteService.getQuote(userId); - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java deleted file mode 100644 index 061cff8cec..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.simplehexagonalex.controller; - -import org.springframework.beans.factory.annotation.Autowired; -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.RestController; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.service.QuoteService; - -@RestController -@RequestMapping("/quote") -public class QuoteRestController { - - @Autowired - private QuoteService quoteService; - - @GetMapping(path = "/{userId}") - public QuoteOfTheDay getEmployee(@PathVariable("userId") String userId) { - return quoteService.getQuote(userId); - } - -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java deleted file mode 100644 index c74c224c70..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.simplehexagonalex.domain; - -import java.util.Objects; - -public class QuoteOfTheDay { - - private String userName; - private String quote; - private String provider; - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getQuote() { - return quote; - } - - public void setQuote(String quote) { - this.quote = quote; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - @Override - public int hashCode() { - return Objects.hash(provider, quote, userName); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - QuoteOfTheDay other = (QuoteOfTheDay) obj; - return Objects.equals(provider, other.provider) && Objects.equals(quote, other.quote) && Objects.equals(userName, other.userName); - } - - @Override - public String toString() { - return "QuoteOfTheDay [userName=" + userName + ", quote=" + quote + ", provider=" + provider + "]"; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java deleted file mode 100644 index 7e70cebd12..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.simplehexagonalex.domain.repository; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; - -public interface QuoteOfTheDayFromProvider { - - QuoteOfTheDay getQuote(); -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java deleted file mode 100644 index 16f7015ace..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.simplehexagonalex.domain.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; - -@Service -public class QuoteAggregator implements QuoteService { - - @Autowired - private QuoteOfTheDayFromProvider quoteOfTheDayFromProvider; - - @Override - public QuoteOfTheDay getQuote(String userName) { - - QuoteOfTheDay quoteOfTheDay = quoteOfTheDayFromProvider.getQuote(); - quoteOfTheDay.setUserName(userName); - return quoteOfTheDay; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java deleted file mode 100644 index 300387a41d..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.simplehexagonalex.domain.service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; - -public interface QuoteService { - - QuoteOfTheDay getQuote(String userName); -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java deleted file mode 100644 index 0cbbc60726..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primary.quoteadapter; - -import java.util.List; -import java.util.Objects; - -public class ProviderQuote { - - private String quote; - private String length; - private String author; - private List tags; - private String category; - private String language; - private String date; - private String permalink; - private String id; - private String background; - private String title; - - public ProviderQuote() { - - } - - public ProviderQuote(String quote, String length, String author, List tags, String category, String language, String date, String permalink, String id, String background, String title) { - super(); - this.quote = quote; - this.length = length; - this.author = author; - this.tags = tags; - this.category = category; - this.language = language; - this.date = date; - this.permalink = permalink; - this.id = id; - this.background = background; - this.title = title; - } - - public String getQuote() { - return quote; - } - - public String getLength() { - return length; - } - - public String getAuthor() { - return author; - } - - public List getTags() { - return tags; - } - - public String getCategory() { - return category; - } - - public String getLanguage() { - return language; - } - - public String getDate() { - return date; - } - - public String getPermalink() { - return permalink; - } - - public String getId() { - return id; - } - - public String getBackground() { - return background; - } - - public String getTitle() { - return title; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ProviderQuote other = (ProviderQuote) obj; - return Objects.equals(id, other.id); - } - - @Override - public String toString() { - return "TheysaysoQuote [quote=" + quote + ", length=" + length + ", " + "author=" + author + ", tags=" + tags + ", category=" + category + ", language=" + language + ", date=" + date + ", permalink=" + permalink + ", id=" + id + ", background=" - + background + ", title=" + title + "]"; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java deleted file mode 100644 index ded08f7b18..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primary.quoteadapter; - -import java.net.URI; - -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Primary; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service("providerQuoteAdapter") -@Primary -public class ProviderQuoteAdapter implements QuoteOfTheDayFromProvider { - - @Autowired - private Environment env; - - @Override - public QuoteOfTheDay getQuote() { - - QuoteOfTheDay quoteOfTheDay = new QuoteOfTheDay(); - ProviderQuoteEnvelope providerQuote; - try { - providerQuote = getProviderQuote(); - quoteOfTheDay.setQuote(providerQuote.getContents() - .getQuotes() - .get(0) - .getQuote()); - quoteOfTheDay.setProvider(providerQuote.getCopyright() - .getUrl()); - } catch (Exception e) { - quoteOfTheDay.setQuote("Unable to get the quote"); - quoteOfTheDay.setProvider("none"); - } - return quoteOfTheDay; - } - - private ProviderQuoteEnvelope getProviderQuote() throws Exception { - - HttpGet request = new HttpGet(URI.create(env.getProperty("theysayso.quote.provider.url"))); - CloseableHttpClient client = HttpClients.createDefault(); - CloseableHttpResponse response = client.execute(request); - ProviderQuoteEnvelope providersQuote = new ObjectMapper().readValue(response.getEntity() - .getContent(), ProviderQuoteEnvelope.class); - return providersQuote; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java deleted file mode 100644 index 611549f23d..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primary.quoteadapter; - -import java.util.List; - -public class ProviderQuoteEnvelope { - - private Success success; - private Contents contents; - private String baseurl; - private Copyright copyright; - - public ProviderQuoteEnvelope() { - - } - - public ProviderQuoteEnvelope(Success success, Contents contents, String baseurl, Copyright copyright) { - super(); - this.success = success; - this.contents = contents; - this.baseurl = baseurl; - this.copyright = copyright; - } - - public Success getSuccess() { - return success; - } - - public Contents getContents() { - return contents; - } - - public String getBaseurl() { - return baseurl; - } - - public Copyright getCopyright() { - return copyright; - } - - public class Contents { - private List quotes; - - public List getQuotes() { - return quotes; - } - } - - public class Copyright { - private int year; - private String url; - - public int getYear() { - return year; - } - - public String getUrl() { - return url; - } - } - - public class Success { - private int total; - - public int getTotal() { - return total; - } - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java deleted file mode 100644 index 54c28fc94e..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.simplehexagonalex.reposity.mock.quoteadapter; - -import org.springframework.stereotype.Service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; - -@Service -public class MockQuoteAdapter implements QuoteOfTheDayFromProvider { - - @Override - public QuoteOfTheDay getQuote() { - - QuoteOfTheDay quoteOfTheDay = new QuoteOfTheDay(); - quoteOfTheDay.setQuote("Mock quote of the day"); - quoteOfTheDay.setProvider("Mock Provider"); - - return quoteOfTheDay; - } -} diff --git a/patterns/simplehexagonalexample/src/main/resources/application.properties b/patterns/simplehexagonalexample/src/main/resources/application.properties deleted file mode 100644 index dd9413bfd5..0000000000 --- a/patterns/simplehexagonalexample/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -theysayso.quote.provider.url=https://quotes.rest/qod?language=en \ No newline at end of file diff --git a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java deleted file mode 100644 index 602f7ea5d4..0000000000 --- a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.junit.jupiter.api.Test; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.reposity.mock.quoteadapter.MockQuoteAdapter; - -public class MockAccessProviderUnitTest { - - @Test - public void givenProvider_whenConnect_thenResponse() throws Exception { - - MockQuoteAdapter provider = new MockQuoteAdapter(); - QuoteOfTheDay quote = provider.getQuote(); - assertNotNull(quote); - assertEquals("Mock quote of the day", quote.getQuote()); - assertEquals("Mock Provider", quote.getProvider()); - } -} diff --git a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java deleted file mode 100644 index 47e1dde136..0000000000 --- a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.test.context.SpringBootTest; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; - -@SpringBootTest -public class PrimaryAccessProviderIntegrationTest { - - @Autowired - @Qualifier("providerQuoteAdapter") - QuoteOfTheDayFromProvider provider; - - @Test - public void whenQuoteProvider_thenResponse() throws Exception { - - QuoteOfTheDay quote = provider.getQuote(); - assertNotNull(quote); - assertThat(quote.getProvider()).contains("theysaidso"); - } -} diff --git a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java deleted file mode 100644 index 552b5d51c2..0000000000 --- a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -@SpringBootTest -@AutoConfigureMockMvc -public class QuoteRequestIntegrationTest { - - @Autowired - private MockMvc mockMvc; - - @Test - public void whenRestQuoteRequest_thenResponse() throws Exception { - - MvcResult result = this.mockMvc.perform(get("/quote/tester")) - .andDo(print()) - .andExpect(status().isOk()) - .andReturn(); - - String content = result.getResponse() - .getContentAsString(); - - assertThat(content).contains("tester"); - assertThat(content).contains("theysaidso"); - } -} \ No newline at end of file diff --git a/patterns/simplehexagonalexample/src/test/resources/application.properties b/patterns/simplehexagonalexample/src/test/resources/application.properties deleted file mode 100644 index dd9413bfd5..0000000000 --- a/patterns/simplehexagonalexample/src/test/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -theysayso.quote.provider.url=https://quotes.rest/qod?language=en \ No newline at end of file From 2db042443d79d13c8858445d6ed6bc4605f53c10 Mon Sep 17 00:00:00 2001 From: nishitgoyal17 Date: Sat, 13 Nov 2021 22:07:03 +0530 Subject: [PATCH 166/551] BAEL-4243:Once per request filter (#11239) * executing junit via command line * incorporating review comments * incorporating review comments * OncePerReqFilter * Delete FirstUnitTest.java * Delete SecondUnitTest.java * Delete pom.xml * Reverting * Update pom.xml * OncePerReqFilter * Update MyFilter.java * OncePerReqFilter * OncePerReqFilter * Update pom.xml * Update pom.xml * Update pom.xml * fixing extra changes * OncePerReqFilter * Reverting * Update MyOncePerRequestFilter.java * Update HelloController.java * fromatting changes * fromatting changes * formatting * Apply suggestions from code review Co-authored-by: KevinGilmore * OncePerRequest changes * OncePerRequest changes * OncePerRequest changes * OncePerRequest changes * OncePerRequest changes Co-authored-by: KevinGilmore --- .../AuthenticationFilter.java | 34 ++++++++++++++++ .../onceperrequestfilter/HelloController.java | 40 +++++++++++++++++++ .../MyOncePerRequestFilter.java | 29 ++++++++++++++ .../OncePerRequestFilterApp.java | 12 ++++++ 4 files changed, 115 insertions(+) create mode 100644 spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java create mode 100644 spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java create mode 100644 spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java create mode 100644 spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java new file mode 100644 index 0000000000..7ddcde7dc8 --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java @@ -0,0 +1,34 @@ +package com.baeldung.onceperrequestfilter; + +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class AuthenticationFilter extends OncePerRequestFilter { + + @Override + protected void doFilterInternal( + HttpServletRequest request, + HttpServletResponse response, + FilterChain filterChain) throws + ServletException, IOException { + String usrName = request.getHeader("userName"); + logger.info("Successfully authenticated user " + + usrName); + filterChain.doFilter(request, response); + } + @Override + protected boolean shouldNotFilterAsyncDispatch() { + return false; + } + @Override + protected boolean shouldNotFilterErrorDispatch() { + return false; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java new file mode 100644 index 0000000000..0a354c91ac --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java @@ -0,0 +1,40 @@ +package com.baeldung.onceperrequestfilter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.context.request.async.DeferredResult; + +import javax.servlet.http.HttpServletResponse; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@Controller +public class HelloController implements AutoCloseable { + + private final ExecutorService executorService = Executors.newCachedThreadPool(); + + private Logger logger = LoggerFactory.getLogger(HelloController.class); + + @GetMapping(path = "/greeting") + public DeferredResult hello(HttpServletResponse response) throws Exception { + DeferredResult deferredResult = new DeferredResult<>(); + executorService.submit(() -> perform(deferredResult)); + return deferredResult; + } + + private void perform(DeferredResult dr) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + dr.setResult("OK"); + } + + @Override + public void close() throws Exception { + executorService.shutdownNow(); + } +} diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java new file mode 100644 index 0000000000..3fd304f86b --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java @@ -0,0 +1,29 @@ +package com.baeldung.onceperrequestfilter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class MyOncePerRequestFilter extends OncePerRequestFilter { + private Logger logger = LoggerFactory.getLogger(MyOncePerRequestFilter.class); + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { + logger.info("Inside Once Per Request Filter originated by request {}", request.getRequestURI()); + filterChain.doFilter(request, response); + } + + @Override + protected boolean shouldNotFilterAsyncDispatch() { + return true; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java new file mode 100644 index 0000000000..ed7be518a3 --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java @@ -0,0 +1,12 @@ +package com.baeldung.onceperrequestfilter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication(scanBasePackages = "com.baeldung.onceperrequestfilter") +public class OncePerRequestFilterApp { + public static void main(String[] args) { + SpringApplication.run(OncePerRequestFilterApp.class, args); + } +} \ No newline at end of file From 37eb10c68dba7654994da7f08df46bcd2324e38d Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 13 Nov 2021 21:22:34 +0100 Subject: [PATCH 167/551] JAVA-8279 Split or move core java module --- .../core-java-serialization/README.md | 9 + .../core-java-serialization/pom.xml | 194 ++++++++++++++++++ .../deserialization/AppleProduct.java | 0 .../deserialization/DefaultSerial.java | 0 .../DeserializationUtility.java | 0 .../deserialization/SerializationUtility.java | 0 .../baeldung/externalizable/Community.java | 0 .../com/baeldung/externalizable/Country.java | 0 .../com/baeldung/externalizable/Region.java | 0 .../com/baeldung/serialization/Address.java | 0 .../com/baeldung/serialization/Employee.java | 0 .../com/baeldung/serialization/Person.java | 0 .../baeldung/util/MySerializationUtils.java | 0 .../src/main/resources/log4j.properties | 6 + .../src/main/resources/log4j2.xml | 13 ++ .../resources/log4jstructuraldp.properties | 9 + .../src/main/resources/logback.xml | 19 ++ .../DeserializationUnitTest.java | 5 +- .../serialization/PersonUnitTest.java | 0 .../serialization/SerializationUnitTest.java | 0 .../src/test/resources/log4j.properties | 6 + .../src/test/resources/log4j2.xml | 13 ++ .../resources/log4jstructuraldp.properties | 9 + .../src/test/resources/logback.xml | 19 ++ core-java-modules/core-java-uuid/README.md | 5 + core-java-modules/core-java-uuid/pom.xml | 156 ++++++++++++++ .../java/com/baeldung/uuid/UUIDGenerator.java | 0 .../src/main/resources/log4j.properties | 6 + .../src/main/resources/log4j2.xml | 13 ++ .../resources/log4jstructuraldp.properties | 9 + .../src/main/resources/logback.xml | 19 ++ .../baeldung/uuid/UUIDGeneratorUnitTest.java | 0 .../src/test/resources/log4j.properties | 6 + .../src/test/resources/log4j2.xml | 13 ++ .../resources/log4jstructuraldp.properties | 9 + .../src/test/resources/logback.xml | 19 ++ core-java-modules/core-java/README.md | 7 - .../ExternalizableUnitTest.java | 71 ------- core-java-modules/pom.xml | 2 + pom.xml | 3 + 40 files changed, 560 insertions(+), 80 deletions(-) create mode 100644 core-java-modules/core-java-serialization/README.md create mode 100644 core-java-modules/core-java-serialization/pom.xml rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/deserialization/AppleProduct.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/deserialization/DefaultSerial.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/deserialization/DeserializationUtility.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/deserialization/SerializationUtility.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/externalizable/Community.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/externalizable/Country.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/externalizable/Region.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/serialization/Address.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/serialization/Employee.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/serialization/Person.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/main/java/com/baeldung/util/MySerializationUtils.java (100%) create mode 100644 core-java-modules/core-java-serialization/src/main/resources/log4j.properties create mode 100644 core-java-modules/core-java-serialization/src/main/resources/log4j2.xml create mode 100644 core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties create mode 100644 core-java-modules/core-java-serialization/src/main/resources/logback.xml rename core-java-modules/{core-java => core-java-serialization}/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java (92%) rename core-java-modules/{core-java => core-java-serialization}/src/test/java/com/baeldung/serialization/PersonUnitTest.java (100%) rename core-java-modules/{core-java => core-java-serialization}/src/test/java/com/baeldung/serialization/SerializationUnitTest.java (100%) create mode 100644 core-java-modules/core-java-serialization/src/test/resources/log4j.properties create mode 100644 core-java-modules/core-java-serialization/src/test/resources/log4j2.xml create mode 100644 core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties create mode 100644 core-java-modules/core-java-serialization/src/test/resources/logback.xml create mode 100644 core-java-modules/core-java-uuid/README.md create mode 100644 core-java-modules/core-java-uuid/pom.xml rename core-java-modules/{core-java => core-java-uuid}/src/main/java/com/baeldung/uuid/UUIDGenerator.java (100%) create mode 100644 core-java-modules/core-java-uuid/src/main/resources/log4j.properties create mode 100644 core-java-modules/core-java-uuid/src/main/resources/log4j2.xml create mode 100644 core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties create mode 100644 core-java-modules/core-java-uuid/src/main/resources/logback.xml rename core-java-modules/{core-java => core-java-uuid}/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java (100%) create mode 100644 core-java-modules/core-java-uuid/src/test/resources/log4j.properties create mode 100644 core-java-modules/core-java-uuid/src/test/resources/log4j2.xml create mode 100644 core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties create mode 100644 core-java-modules/core-java-uuid/src/test/resources/logback.xml delete mode 100644 core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java diff --git a/core-java-modules/core-java-serialization/README.md b/core-java-modules/core-java-serialization/README.md new file mode 100644 index 0000000000..fc6cfcf134 --- /dev/null +++ b/core-java-modules/core-java-serialization/README.md @@ -0,0 +1,9 @@ +## Core Java Serialization + +### Relevant Articles: + +- [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) +- [Introduction to Java Serialization](http://www.baeldung.com/java-serialization) +- [Deserialization Vulnerabilities in Java](https://www.baeldung.com/java-deserialization-vulnerabilities) +- [Serialization Validation in Java](https://www.baeldung.com/java-validate-serializable) +- [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) diff --git a/core-java-modules/core-java-serialization/pom.xml b/core-java-modules/core-java-serialization/pom.xml new file mode 100644 index 0000000000..74a78e8b48 --- /dev/null +++ b/core-java-modules/core-java-serialization/pom.xml @@ -0,0 +1,194 @@ + + + 4.0.0 + core-java-serialization + 0.1.0-SNAPSHOT + core-java-serialization + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + org.unix4j + unix4j-command + ${unix4j.version} + + + com.googlecode.grep4j + grep4j + ${grep4j.version} + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + log4j + log4j + ${log4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + org.springframework + spring-core + ${spring.core.version} + + + org.springframework + spring-core + 4.3.20.RELEASE + test + + + + + core-java + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + ${project.build.directory}/libs + + + + + + org.codehaus.mojo + exec-maven-plugin + + java + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + -Xmx300m + -XX:+UseParallelGC + -classpath + + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + ${source.version} + ${target.version} + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*ManualTest.java + + + **/*IntegrationTest.java + **/*IntTest.java + + + + + + + json + + + + + org.codehaus.mojo + exec-maven-plugin + + + run-benchmarks + + none + + exec + + + test + java + + -classpath + + org.openjdk.jmh.Main + .* + + + + + + + + + + + + + 0.4 + 1.8.7 + + 3.10.0 + + 1.1 + 3.0.0-M1 + 1.8 + 1.8 + 4.3.20.RELEASE + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/AppleProduct.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/AppleProduct.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DefaultSerial.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DefaultSerial.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DefaultSerial.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DefaultSerial.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DeserializationUtility.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/DeserializationUtility.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/SerializationUtility.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/deserialization/SerializationUtility.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Community.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Community.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Community.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Community.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Country.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Country.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Country.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Country.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Region.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Region.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Region.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/externalizable/Region.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Address.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Address.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/serialization/Address.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Address.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Employee.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Employee.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/serialization/Employee.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Employee.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Person.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Person.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/serialization/Person.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/serialization/Person.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java b/core-java-modules/core-java-serialization/src/main/java/com/baeldung/util/MySerializationUtils.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/util/MySerializationUtils.java rename to core-java-modules/core-java-serialization/src/main/java/com/baeldung/util/MySerializationUtils.java diff --git a/core-java-modules/core-java-serialization/src/main/resources/log4j.properties b/core-java-modules/core-java-serialization/src/main/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/main/resources/log4j2.xml b/core-java-modules/core-java-serialization/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/main/resources/logback.xml b/core-java-modules/core-java-serialization/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-serialization/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java similarity index 92% rename from core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java rename to core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java index d7c1ee17d4..cc45cbc8e0 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java +++ b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.InvalidClassException; +import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -24,7 +25,7 @@ public class DeserializationUnitTest { @Test public void testDeserializeObj_compatible() throws IOException, ClassNotFoundException { - assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); + Assert.assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); AppleProduct macBook = new AppleProduct(); macBook.headphonePort = "headphonePort2020"; @@ -60,7 +61,7 @@ public class DeserializationUnitTest { @Test(expected = InvalidClassException.class) public void testDeserializeObj_incompatible() throws ClassNotFoundException, IOException { - assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); + Assert.assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); // attempts to deserialize the "AppleProduct" object DeserializationUtility.deSerializeObjectFromString(serializedObj); } diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/PersonUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java rename to core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/PersonUnitTest.java diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/SerializationUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/serialization/SerializationUnitTest.java rename to core-java-modules/core-java-serialization/src/test/java/com/baeldung/serialization/SerializationUnitTest.java diff --git a/core-java-modules/core-java-serialization/src/test/resources/log4j.properties b/core-java-modules/core-java-serialization/src/test/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/test/resources/log4j2.xml b/core-java-modules/core-java-serialization/src/test/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties b/core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/src/test/resources/logback.xml b/core-java-modules/core-java-serialization/src/test/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/README.md b/core-java-modules/core-java-uuid/README.md new file mode 100644 index 0000000000..836552d798 --- /dev/null +++ b/core-java-modules/core-java-uuid/README.md @@ -0,0 +1,5 @@ +## Core Java UUID + +### Relevant Articles: +- [Generating Alphanumeric UUID String in Java](https://www.baeldung.com/java-generate-alphanumeric-uuid) +- [Guide to UUID in Java](http://www.baeldung.com/java-uuid) diff --git a/core-java-modules/core-java-uuid/pom.xml b/core-java-modules/core-java-uuid/pom.xml new file mode 100644 index 0000000000..fba36ada8e --- /dev/null +++ b/core-java-modules/core-java-uuid/pom.xml @@ -0,0 +1,156 @@ + + + 4.0.0 + core-java-uuid + 0.1.0-SNAPSHOT + core-java-uuid + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + + log4j + log4j + ${log4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + core-java-uuid + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + ${project.build.directory}/libs + + + + + + org.codehaus.mojo + exec-maven-plugin + + java + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + -Xmx300m + -XX:+UseParallelGC + -classpath + + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + ${source.version} + ${target.version} + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*ManualTest.java + + + **/*IntegrationTest.java + **/*IntTest.java + + + + + + + json + + + + + org.codehaus.mojo + exec-maven-plugin + + + run-benchmarks + + none + + exec + + + test + java + + -classpath + + org.openjdk.jmh.Main + .* + + + + + + + + + + + + 3.10.0 + 3.0.0-M1 + 1.8 + 1.8 + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java b/core-java-modules/core-java-uuid/src/main/java/com/baeldung/uuid/UUIDGenerator.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java rename to core-java-modules/core-java-uuid/src/main/java/com/baeldung/uuid/UUIDGenerator.java diff --git a/core-java-modules/core-java-uuid/src/main/resources/log4j.properties b/core-java-modules/core-java-uuid/src/main/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/main/resources/log4j2.xml b/core-java-modules/core-java-uuid/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/main/resources/logback.xml b/core-java-modules/core-java-uuid/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-uuid/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java rename to core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDGeneratorUnitTest.java diff --git a/core-java-modules/core-java-uuid/src/test/resources/log4j.properties b/core-java-modules/core-java-uuid/src/test/resources/log4j.properties new file mode 100644 index 0000000000..621cf01735 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=DEBUG, A1 + +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/test/resources/log4j2.xml b/core-java-modules/core-java-uuid/src/test/resources/log4j2.xml new file mode 100644 index 0000000000..a824bef9b0 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties b/core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties new file mode 100644 index 0000000000..5bc2bfe4b9 --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/log4jstructuraldp.properties @@ -0,0 +1,9 @@ + +# Root logger +log4j.rootLogger=INFO, file, stdout + +# Write to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java-uuid/src/test/resources/logback.xml b/core-java-modules/core-java-uuid/src/test/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-modules/core-java-uuid/src/test/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java/README.md b/core-java-modules/core-java/README.md index 3285a7e663..a75805e0c2 100644 --- a/core-java-modules/core-java/README.md +++ b/core-java-modules/core-java/README.md @@ -3,14 +3,7 @@ ### Relevant Articles: - [Getting Started with Java Properties](http://www.baeldung.com/java-properties) - [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency) -- [Introduction to Java Serialization](http://www.baeldung.com/java-serialization) -- [Guide to UUID in Java](http://www.baeldung.com/java-uuid) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) - [Introduction to Javadoc](http://www.baeldung.com/javadoc) -- [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) -- [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) - [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) -- [Deserialization Vulnerabilities in Java](https://www.baeldung.com/java-deserialization-vulnerabilities) -- [Generating Alphanumeric UUID String in Java](https://www.baeldung.com/java-generate-alphanumeric-uuid) -- [Serialization Validation in Java](https://www.baeldung.com/java-validate-serializable) diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java deleted file mode 100644 index 651364fb13..0000000000 --- a/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.baeldung.externalizable; - -import org.junit.Test; - -import java.io.*; - -import static org.junit.Assert.assertTrue; - -public class ExternalizableUnitTest { - - private final static String OUTPUT_FILE = "externalizable.txt"; - - @Test - public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException { - - Country c = new Country(); - c.setCapital("Yerevan"); - c.setCode(374); - c.setName("Armenia"); - - FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); - c.writeExternal(objectOutputStream); - - objectOutputStream.flush(); - objectOutputStream.close(); - fileOutputStream.close(); - - FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE); - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); - - Country c2 = new Country(); - c2.readExternal(objectInputStream); - - objectInputStream.close(); - fileInputStream.close(); - - assertTrue(c2.getCode() == c.getCode()); - assertTrue(c2.getName().equals(c.getName())); - } - - @Test - public void whenInheritanceSerialization_then_UseExternalizable() throws IOException, ClassNotFoundException { - - Region r = new Region(); - r.setCapital("Yerevan"); - r.setCode(374); - r.setName("Armenia"); - r.setClimate("Mediterranean"); - r.setPopulation(120.000); - - FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); - r.writeExternal(objectOutputStream); - - objectOutputStream.flush(); - objectOutputStream.close(); - fileOutputStream.close(); - - FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE); - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); - - Region r2 = new Region(); - r2.readExternal(objectInputStream); - - objectInputStream.close(); - fileInputStream.close(); - - assertTrue(r2.getPopulation() == null); - } -} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index c3d17e7637..d8191e74d0 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -100,6 +100,7 @@ core-java-security core-java-security-2 core-java-security-3 + core-java-serialization core-java-streams core-java-streams-2 core-java-streams-3 @@ -115,6 +116,7 @@ core-java-sun core-java-regex core-java-regex-2 + core-java-uuid pre-jpms diff --git a/pom.xml b/pom.xml index 372bc5a9f3..4af2e422f4 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,9 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + + core-java-uuid + parent-modules pom From bcf27a7a7047d81430f9d70c478037b1154dbba4 Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 13 Nov 2021 21:31:25 +0100 Subject: [PATCH 168/551] JAVA-8279 Split or move core java module (remove wrong module in main pom) --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4af2e422f4..372bc5a9f3 100644 --- a/pom.xml +++ b/pom.xml @@ -7,9 +7,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - - core-java-uuid - parent-modules pom From 37961b7d27d5ff8408e1881838122394511949a9 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 14 Nov 2021 11:05:34 +0530 Subject: [PATCH 169/551] JAVA-8282: Moved 5 articles from core-java-security-2 module to new module core-java-security-algorithms --- .../core-java-security-2/README.md | 5 - .../main/java/com/baeldung/aes/AESUtil.java | 156 ------------------ .../main/java/com/baeldung/aes/Student.java | 40 ----- .../com/baeldung/aes/AESUtilUnitTest.java | 101 ------------ .../cipher/AvailableCiphersUnitTest.java | 35 ---- .../com/baeldung/des/TripleDESUnitTest.java | 90 ---------- .../java/com/baeldung/rsa/RsaUnitTest.java | 92 ----------- .../core-java-security-algorithms/README.md | 11 ++ .../src/test/resources/baeldung.txt | 0 9 files changed, 11 insertions(+), 519 deletions(-) delete mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/AESUtil.java delete mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/Student.java delete mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java delete mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java delete mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/des/TripleDESUnitTest.java delete mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java create mode 100644 core-java-modules/core-java-security-algorithms/README.md rename core-java-modules/{core-java-security-2 => core-java-security-algorithms}/src/test/resources/baeldung.txt (100%) diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md index 680a7de925..31404d24a5 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -10,12 +10,7 @@ This module contains articles about core Java Security - [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) - [Checksums in Java](https://www.baeldung.com/java-checksums) - [How to Read PEM File to Get Public and Private Keys](https://www.baeldung.com/java-read-pem-file-keys) -- [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) - [Get a List of Trusted Certificates in Java](https://www.baeldung.com/java-list-trusted-certificates) - [Security Context Basics: User, Subject and Principal](https://www.baeldung.com/security-context-basics) -- [Java AES Encryption and Decryption](https://www.baeldung.com/java-aes-encryption-decryption) -- [InvalidAlgorithmParameterException: Wrong IV Length](https://www.baeldung.com/java-invalidalgorithmparameter-exception) - [The java.security.egd JVM Option](https://www.baeldung.com/java-security-egd) -- [RSA in Java](https://www.baeldung.com/java-rsa) -- [3DES in Java](https://www.baeldung.com/java-3des) - More articles: [[<-- prev]](/core-java-modules/core-java-security) diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/AESUtil.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/AESUtil.java deleted file mode 100644 index 2952eef625..0000000000 --- a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/AESUtil.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.baeldung.aes; - -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKey; -import javax.crypto.BadPaddingException; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKeyFactory; -import javax.crypto.SealedObject; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.SecretKeySpec; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.util.Base64; - -public class AESUtil { - - public static String encrypt(String algorithm, String input, SecretKey key, IvParameterSpec iv) - throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, - InvalidKeyException, BadPaddingException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.ENCRYPT_MODE, key, iv); - byte[] cipherText = cipher.doFinal(input.getBytes()); - return Base64.getEncoder() - .encodeToString(cipherText); - } - - public static String decrypt(String algorithm, String cipherText, SecretKey key, IvParameterSpec iv) - throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, - InvalidKeyException, BadPaddingException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.DECRYPT_MODE, key, iv); - byte[] plainText = cipher.doFinal(Base64.getDecoder() - .decode(cipherText)); - return new String(plainText); - } - - public static SecretKey generateKey(int n) throws NoSuchAlgorithmException { - KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); - keyGenerator.init(n); - SecretKey key = keyGenerator.generateKey(); - return key; - } - - public static SecretKey getKeyFromPassword(String password, String salt) - throws NoSuchAlgorithmException, InvalidKeySpecException { - SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); - KeySpec spec = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 65536, 256); - SecretKey secret = new SecretKeySpec(factory.generateSecret(spec) - .getEncoded(), "AES"); - return secret; - } - - public static IvParameterSpec generateIv() { - byte[] iv = new byte[16]; - new SecureRandom().nextBytes(iv); - return new IvParameterSpec(iv); - } - - public static void encryptFile(String algorithm, SecretKey key, IvParameterSpec iv, - File inputFile, File outputFile) throws IOException, NoSuchPaddingException, - NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, - BadPaddingException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.ENCRYPT_MODE, key, iv); - FileInputStream inputStream = new FileInputStream(inputFile); - FileOutputStream outputStream = new FileOutputStream(outputFile); - byte[] buffer = new byte[64]; - int bytesRead; - while ((bytesRead = inputStream.read(buffer)) != -1) { - byte[] output = cipher.update(buffer, 0, bytesRead); - if (output != null) { - outputStream.write(output); - } - } - byte[] outputBytes = cipher.doFinal(); - if (outputBytes != null) { - outputStream.write(outputBytes); - } - inputStream.close(); - outputStream.close(); - } - - public static void decryptFile(String algorithm, SecretKey key, IvParameterSpec iv, - File encryptedFile, File decryptedFile) throws IOException, NoSuchPaddingException, - NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, - BadPaddingException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.DECRYPT_MODE, key, iv); - FileInputStream inputStream = new FileInputStream(encryptedFile); - FileOutputStream outputStream = new FileOutputStream(decryptedFile); - byte[] buffer = new byte[64]; - int bytesRead; - while ((bytesRead = inputStream.read(buffer)) != -1) { - byte[] output = cipher.update(buffer, 0, bytesRead); - if (output != null) { - outputStream.write(output); - } - } - byte[] output = cipher.doFinal(); - if (output != null) { - outputStream.write(output); - } - inputStream.close(); - outputStream.close(); - } - - public static SealedObject encryptObject(String algorithm, Serializable object, SecretKey key, - IvParameterSpec iv) throws NoSuchPaddingException, NoSuchAlgorithmException, - InvalidAlgorithmParameterException, InvalidKeyException, IOException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.ENCRYPT_MODE, key, iv); - SealedObject sealedObject = new SealedObject(object, cipher); - return sealedObject; - } - - public static Serializable decryptObject(String algorithm, SealedObject sealedObject, SecretKey key, - IvParameterSpec iv) throws NoSuchPaddingException, NoSuchAlgorithmException, - InvalidAlgorithmParameterException, InvalidKeyException, ClassNotFoundException, - BadPaddingException, IllegalBlockSizeException, IOException { - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.DECRYPT_MODE, key, iv); - Serializable unsealObject = (Serializable) sealedObject.getObject(cipher); - return unsealObject; - } - - public static String encryptPasswordBased(String plainText, SecretKey key, IvParameterSpec iv) - throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, - InvalidKeyException, BadPaddingException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, key, iv); - return Base64.getEncoder() - .encodeToString(cipher.doFinal(plainText.getBytes())); - } - - public static String decryptPasswordBased(String cipherText, SecretKey key, IvParameterSpec iv) - throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, - InvalidKeyException, BadPaddingException, IllegalBlockSizeException { - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); - cipher.init(Cipher.DECRYPT_MODE, key, iv); - return new String(cipher.doFinal(Base64.getDecoder() - .decode(cipherText))); - } - -} diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/Student.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/Student.java deleted file mode 100644 index 13cd1c5e9d..0000000000 --- a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/Student.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.aes; - -import java.io.Serializable; -import java.util.Objects; - -public class Student implements Serializable { - private String name; - private int age; - - public Student(String name, int age) { - this.name = name; - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Student student = (Student) o; - return age == student.age && Objects.equals(name, student.name); - } -} diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java deleted file mode 100644 index 531c20ca79..0000000000 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.baeldung.aes; - -import org.assertj.core.api.WithAssertions; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import javax.crypto.SealedObject; -import javax.crypto.SecretKey; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; - -class AESUtilUnitTest implements WithAssertions { - - @Test - void givenString_whenEncrypt_thenSuccess() - throws NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, - BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException { - // given - String input = "baeldung"; - SecretKey key = AESUtil.generateKey(128); - IvParameterSpec ivParameterSpec = AESUtil.generateIv(); - String algorithm = "AES/CBC/PKCS5Padding"; - - // when - String cipherText = AESUtil.encrypt(algorithm, input, key, ivParameterSpec); - String plainText = AESUtil.decrypt(algorithm, cipherText, key, ivParameterSpec); - - // then - Assertions.assertEquals(input, plainText); - } - - @Test - void givenFile_whenEncrypt_thenSuccess() - throws NoSuchAlgorithmException, IOException, IllegalBlockSizeException, InvalidKeyException, - BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException { - // given - SecretKey key = AESUtil.generateKey(128); - String algorithm = "AES/CBC/PKCS5Padding"; - IvParameterSpec ivParameterSpec = AESUtil.generateIv(); - File inputFile = Paths.get("src/test/resources/baeldung.txt") - .toFile(); - File encryptedFile = new File("classpath:baeldung.encrypted"); - File decryptedFile = new File("document.decrypted"); - - // when - AESUtil.encryptFile(algorithm, key, ivParameterSpec, inputFile, encryptedFile); - AESUtil.decryptFile(algorithm, key, ivParameterSpec, encryptedFile, decryptedFile); - - // then - assertThat(inputFile).hasSameTextualContentAs(decryptedFile); - encryptedFile.delete(); - decryptedFile.delete(); - } - - @Test - void givenObject_whenEncrypt_thenSuccess() - throws NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, - InvalidAlgorithmParameterException, NoSuchPaddingException, IOException, BadPaddingException, - ClassNotFoundException { - // given - Student student = new Student("Baeldung", 20); - SecretKey key = AESUtil.generateKey(128); - IvParameterSpec ivParameterSpec = AESUtil.generateIv(); - String algorithm = "AES/CBC/PKCS5Padding"; - - // when - SealedObject sealedObject = AESUtil.encryptObject(algorithm, student, key, ivParameterSpec); - Student object = (Student) AESUtil.decryptObject(algorithm, sealedObject, key, ivParameterSpec); - - // then - assertThat(student).isEqualTo(object); - } - - @Test - void givenPassword_whenEncrypt_thenSuccess() - throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, - InvalidKeyException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException { - // given - String plainText = "www.baeldung.com"; - String password = "baeldung"; - String salt = "12345678"; - IvParameterSpec ivParameterSpec = AESUtil.generateIv(); - SecretKey key = AESUtil.getKeyFromPassword(password, salt); - - // when - String cipherText = AESUtil.encryptPasswordBased(plainText, key, ivParameterSpec); - String decryptedCipherText = AESUtil.decryptPasswordBased(cipherText, key, ivParameterSpec); - - // then - Assertions.assertEquals(plainText, decryptedCipherText); - } -} diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java deleted file mode 100644 index fa38aca272..0000000000 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.cipher; - -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.security.Provider; -import java.security.Security; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -public class AvailableCiphersUnitTest { - private final Logger logger = LoggerFactory.getLogger(AvailableCiphersUnitTest.class); - - @Test - public void whenGetServices_thenGetAllCipherAlgorithms() { - for (Provider provider : Security.getProviders()) { - for (Provider.Service service : provider.getServices()) { - logger.info(service.getAlgorithm()); - } - } - } - - @Test - public void whenGetServicesWithFilter_thenGetAllCompatibleCipherAlgorithms() { - List algorithms = Arrays.stream(Security.getProviders()) - .flatMap(provider -> provider.getServices().stream()) - .filter(service -> "Cipher".equals(service.getType())) - .map(Provider.Service::getAlgorithm) - .collect(Collectors.toList()); - - algorithms.forEach(logger::info); - } -} diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/des/TripleDESUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/des/TripleDESUnitTest.java deleted file mode 100644 index 6e5df8e619..0000000000 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/des/TripleDESUnitTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.baeldung.des; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import javax.crypto.Cipher; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; - -public class TripleDESUnitTest { - - @Test - public void given3DesKey_whenEncryptAndDecryptString_thenCompareResults() throws Exception { - byte[] secretKey = "9mng65v8jf4lxn93nabf981m".getBytes(); - byte[] iv = "a76nb5h9".getBytes(); - - String secretMessage = "Baeldung secret message"; - - SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "DESede"); - IvParameterSpec ivSpec = new IvParameterSpec(iv); - Cipher encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); - encryptCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivSpec); - byte[] secretMessagesBytes = secretMessage.getBytes(StandardCharsets.UTF_8); - byte[] encryptedMessageBytes = encryptCipher.doFinal(secretMessagesBytes); - - Cipher decryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); - decryptCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivSpec); - byte[] decryptedMessageBytes = decryptCipher.doFinal(encryptedMessageBytes); - String decryptedMessage = new String(decryptedMessageBytes, StandardCharsets.UTF_8); - - Assertions.assertEquals(secretMessage, decryptedMessage); - } - - @Test - public void given3DesKey_whenEncryptAndDecryptFile_thenCompareResults() throws Exception { - byte[] secretKey = "9mng65v8jf4lxn93nabf981m".getBytes(); - byte[] iv = "a76nb5h9".getBytes(); - - SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "DESede"); - IvParameterSpec ivSpec = new IvParameterSpec(iv); - - String originalContent = "some secret message"; - Path tempFile = Files.createTempFile("temp", "txt"); - writeString(tempFile, originalContent); - - byte[] fileBytes = Files.readAllBytes(tempFile); - Cipher encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); - encryptCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivSpec); - byte[] encryptedFileBytes = encryptCipher.doFinal(fileBytes); - try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { - stream.write(encryptedFileBytes); - } - - encryptedFileBytes = Files.readAllBytes(tempFile); - Cipher decryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); - decryptCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivSpec); - byte[] decryptedFileBytes = decryptCipher.doFinal(encryptedFileBytes); - try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { - stream.write(decryptedFileBytes); - } - - String fileContent = readString(tempFile); - - Assertions.assertEquals(originalContent, fileContent); - } - - private void writeString(Path path, String content) throws Exception { - try (BufferedWriter writer = Files.newBufferedWriter(path)) { - writer.write(content); - } - } - - private String readString(Path path) throws Exception { - StringBuilder resultStringBuilder = new StringBuilder(); - try (BufferedReader br = new BufferedReader(new FileReader(path.toFile()))) { - String line; - while ((line = br.readLine()) != null) { - resultStringBuilder.append(line); - } - } - return resultStringBuilder.toString(); - } -} diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java deleted file mode 100644 index ac93f71125..0000000000 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.baeldung.cipher; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import javax.crypto.Cipher; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.PrivateKey; -import java.security.PublicKey; - -public class RsaUnitTest { - - @Test - public void givenRsaKeyPair_whenEncryptAndDecryptString_thenCompareResults() throws Exception { - KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); - generator.initialize(2048); - KeyPair pair = generator.generateKeyPair(); - PrivateKey privateKey = pair.getPrivate(); - PublicKey publicKey = pair.getPublic(); - - String secretMessage = "Baeldung secret message"; - Cipher encryptCipher = Cipher.getInstance("RSA"); - encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey); - byte[] secretMessageBytes = secretMessage.getBytes(StandardCharsets.UTF_8); - byte[] encryptedMessageBytes = encryptCipher.doFinal(secretMessageBytes); - - Cipher decryptCipher = Cipher.getInstance("RSA"); - decryptCipher.init(Cipher.DECRYPT_MODE, privateKey); - byte[] decryptedMessageBytes = decryptCipher.doFinal(encryptedMessageBytes); - String decryptedMessage = new String(decryptedMessageBytes, StandardCharsets.UTF_8); - - Assertions.assertEquals(secretMessage, decryptedMessage); - } - - @Test - public void givenRsaKeyPair_whenEncryptAndDecryptFile_thenCompareResults() throws Exception { - KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); - generator.initialize(2048); - KeyPair pair = generator.generateKeyPair(); - PrivateKey privateKey = pair.getPrivate(); - PublicKey publicKey = pair.getPublic(); - - String originalContent = "some secret message"; - Path tempFile = Files.createTempFile("temp", "txt"); - writeString(tempFile, originalContent); - - byte[] fileBytes = Files.readAllBytes(tempFile); - Cipher encryptCipher = Cipher.getInstance("RSA"); - encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey); - byte[] encryptedFileBytes = encryptCipher.doFinal(fileBytes); - try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { - stream.write(encryptedFileBytes); - } - - encryptedFileBytes = Files.readAllBytes(tempFile); - Cipher decryptCipher = Cipher.getInstance("RSA"); - decryptCipher.init(Cipher.DECRYPT_MODE, privateKey); - byte[] decryptedFileBytes = decryptCipher.doFinal(encryptedFileBytes); - try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { - stream.write(decryptedFileBytes); - } - - String fileContent = readString(tempFile); - - Assertions.assertEquals(originalContent, fileContent); - } - - private void writeString(Path path, String content) throws Exception { - try (BufferedWriter writer = Files.newBufferedWriter(path)) { - writer.write(content); - } - } - - private String readString(Path path) throws Exception { - StringBuilder resultStringBuilder = new StringBuilder(); - try (BufferedReader br = new BufferedReader(new FileReader(path.toFile()))) { - String line; - while ((line = br.readLine()) != null) { - resultStringBuilder.append(line); - } - } - return resultStringBuilder.toString(); - } -} diff --git a/core-java-modules/core-java-security-algorithms/README.md b/core-java-modules/core-java-security-algorithms/README.md new file mode 100644 index 0000000000..a1ce244ab8 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/README.md @@ -0,0 +1,11 @@ +## Core Java Security Algorithms + +This module contains articles about core Java Security Algorithms such as AES, DES, RSA, etc + +### Relevant Articles: + +- [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) +- [Java AES Encryption and Decryption](https://www.baeldung.com/java-aes-encryption-decryption) +- [InvalidAlgorithmParameterException: Wrong IV Length](https://www.baeldung.com/java-invalidalgorithmparameter-exception) +- [RSA in Java](https://www.baeldung.com/java-rsa) +- [3DES in Java](https://www.baeldung.com/java-3des) diff --git a/core-java-modules/core-java-security-2/src/test/resources/baeldung.txt b/core-java-modules/core-java-security-algorithms/src/test/resources/baeldung.txt similarity index 100% rename from core-java-modules/core-java-security-2/src/test/resources/baeldung.txt rename to core-java-modules/core-java-security-algorithms/src/test/resources/baeldung.txt From da99f980b8740bccb18bce25f6c6217ae9a5c2a5 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 14 Nov 2021 11:07:22 +0530 Subject: [PATCH 170/551] JAVA-8282: Moved 5 articles from core-java-security-2 module to new module core-java-security-algorithms --- .../core-java-security-algorithms/pom.xml | 52 ++++++ .../main/java/com/baeldung/aes/AESUtil.java | 156 ++++++++++++++++++ .../main/java/com/baeldung/aes/Student.java | 40 +++++ .../com/baeldung/aes/AESUtilUnitTest.java | 101 ++++++++++++ .../cipher/AvailableCiphersUnitTest.java | 35 ++++ .../com/baeldung/des/TripleDESUnitTest.java | 90 ++++++++++ .../java/com/baeldung/rsa/RsaUnitTest.java | 92 +++++++++++ 7 files changed, 566 insertions(+) create mode 100644 core-java-modules/core-java-security-algorithms/pom.xml create mode 100644 core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/AESUtil.java create mode 100644 core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/Student.java create mode 100644 core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/aes/AESUtilUnitTest.java create mode 100644 core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java create mode 100644 core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/des/TripleDESUnitTest.java create mode 100644 core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java diff --git a/core-java-modules/core-java-security-algorithms/pom.xml b/core-java-modules/core-java-security-algorithms/pom.xml new file mode 100644 index 0000000000..db1bf09ead --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + core-java-security-algorithms + 0.1.0-SNAPSHOT + core-java-security-algorithms + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.bouncycastle + bcprov-jdk15on + ${bouncycastle.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + javax.xml.bind + jaxb-api + ${jaxb-api.version} + + + + + + 1.60 + 1.11 + + 3.18.0 + 2.3.1 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/AESUtil.java b/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/AESUtil.java new file mode 100644 index 0000000000..2952eef625 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/AESUtil.java @@ -0,0 +1,156 @@ +package com.baeldung.aes; + +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.BadPaddingException; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKeyFactory; +import javax.crypto.SealedObject; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.Serializable; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.util.Base64; + +public class AESUtil { + + public static String encrypt(String algorithm, String input, SecretKey key, IvParameterSpec iv) + throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, + InvalidKeyException, BadPaddingException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + byte[] cipherText = cipher.doFinal(input.getBytes()); + return Base64.getEncoder() + .encodeToString(cipherText); + } + + public static String decrypt(String algorithm, String cipherText, SecretKey key, IvParameterSpec iv) + throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, + InvalidKeyException, BadPaddingException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + byte[] plainText = cipher.doFinal(Base64.getDecoder() + .decode(cipherText)); + return new String(plainText); + } + + public static SecretKey generateKey(int n) throws NoSuchAlgorithmException { + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + keyGenerator.init(n); + SecretKey key = keyGenerator.generateKey(); + return key; + } + + public static SecretKey getKeyFromPassword(String password, String salt) + throws NoSuchAlgorithmException, InvalidKeySpecException { + SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); + KeySpec spec = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 65536, 256); + SecretKey secret = new SecretKeySpec(factory.generateSecret(spec) + .getEncoded(), "AES"); + return secret; + } + + public static IvParameterSpec generateIv() { + byte[] iv = new byte[16]; + new SecureRandom().nextBytes(iv); + return new IvParameterSpec(iv); + } + + public static void encryptFile(String algorithm, SecretKey key, IvParameterSpec iv, + File inputFile, File outputFile) throws IOException, NoSuchPaddingException, + NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, + BadPaddingException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + FileInputStream inputStream = new FileInputStream(inputFile); + FileOutputStream outputStream = new FileOutputStream(outputFile); + byte[] buffer = new byte[64]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + byte[] output = cipher.update(buffer, 0, bytesRead); + if (output != null) { + outputStream.write(output); + } + } + byte[] outputBytes = cipher.doFinal(); + if (outputBytes != null) { + outputStream.write(outputBytes); + } + inputStream.close(); + outputStream.close(); + } + + public static void decryptFile(String algorithm, SecretKey key, IvParameterSpec iv, + File encryptedFile, File decryptedFile) throws IOException, NoSuchPaddingException, + NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, + BadPaddingException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + FileInputStream inputStream = new FileInputStream(encryptedFile); + FileOutputStream outputStream = new FileOutputStream(decryptedFile); + byte[] buffer = new byte[64]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + byte[] output = cipher.update(buffer, 0, bytesRead); + if (output != null) { + outputStream.write(output); + } + } + byte[] output = cipher.doFinal(); + if (output != null) { + outputStream.write(output); + } + inputStream.close(); + outputStream.close(); + } + + public static SealedObject encryptObject(String algorithm, Serializable object, SecretKey key, + IvParameterSpec iv) throws NoSuchPaddingException, NoSuchAlgorithmException, + InvalidAlgorithmParameterException, InvalidKeyException, IOException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + SealedObject sealedObject = new SealedObject(object, cipher); + return sealedObject; + } + + public static Serializable decryptObject(String algorithm, SealedObject sealedObject, SecretKey key, + IvParameterSpec iv) throws NoSuchPaddingException, NoSuchAlgorithmException, + InvalidAlgorithmParameterException, InvalidKeyException, ClassNotFoundException, + BadPaddingException, IllegalBlockSizeException, IOException { + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + Serializable unsealObject = (Serializable) sealedObject.getObject(cipher); + return unsealObject; + } + + public static String encryptPasswordBased(String plainText, SecretKey key, IvParameterSpec iv) + throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, + InvalidKeyException, BadPaddingException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + return Base64.getEncoder() + .encodeToString(cipher.doFinal(plainText.getBytes())); + } + + public static String decryptPasswordBased(String cipherText, SecretKey key, IvParameterSpec iv) + throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, + InvalidKeyException, BadPaddingException, IllegalBlockSizeException { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + return new String(cipher.doFinal(Base64.getDecoder() + .decode(cipherText))); + } + +} diff --git a/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/Student.java b/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/Student.java new file mode 100644 index 0000000000..13cd1c5e9d --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/Student.java @@ -0,0 +1,40 @@ +package com.baeldung.aes; + +import java.io.Serializable; +import java.util.Objects; + +public class Student implements Serializable { + private String name; + private int age; + + public Student(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Student student = (Student) o; + return age == student.age && Objects.equals(name, student.name); + } +} diff --git a/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/aes/AESUtilUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/aes/AESUtilUnitTest.java new file mode 100644 index 0000000000..531c20ca79 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/aes/AESUtilUnitTest.java @@ -0,0 +1,101 @@ +package com.baeldung.aes; + +import org.assertj.core.api.WithAssertions; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import javax.crypto.SealedObject; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; + +class AESUtilUnitTest implements WithAssertions { + + @Test + void givenString_whenEncrypt_thenSuccess() + throws NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, + BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException { + // given + String input = "baeldung"; + SecretKey key = AESUtil.generateKey(128); + IvParameterSpec ivParameterSpec = AESUtil.generateIv(); + String algorithm = "AES/CBC/PKCS5Padding"; + + // when + String cipherText = AESUtil.encrypt(algorithm, input, key, ivParameterSpec); + String plainText = AESUtil.decrypt(algorithm, cipherText, key, ivParameterSpec); + + // then + Assertions.assertEquals(input, plainText); + } + + @Test + void givenFile_whenEncrypt_thenSuccess() + throws NoSuchAlgorithmException, IOException, IllegalBlockSizeException, InvalidKeyException, + BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException { + // given + SecretKey key = AESUtil.generateKey(128); + String algorithm = "AES/CBC/PKCS5Padding"; + IvParameterSpec ivParameterSpec = AESUtil.generateIv(); + File inputFile = Paths.get("src/test/resources/baeldung.txt") + .toFile(); + File encryptedFile = new File("classpath:baeldung.encrypted"); + File decryptedFile = new File("document.decrypted"); + + // when + AESUtil.encryptFile(algorithm, key, ivParameterSpec, inputFile, encryptedFile); + AESUtil.decryptFile(algorithm, key, ivParameterSpec, encryptedFile, decryptedFile); + + // then + assertThat(inputFile).hasSameTextualContentAs(decryptedFile); + encryptedFile.delete(); + decryptedFile.delete(); + } + + @Test + void givenObject_whenEncrypt_thenSuccess() + throws NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, + InvalidAlgorithmParameterException, NoSuchPaddingException, IOException, BadPaddingException, + ClassNotFoundException { + // given + Student student = new Student("Baeldung", 20); + SecretKey key = AESUtil.generateKey(128); + IvParameterSpec ivParameterSpec = AESUtil.generateIv(); + String algorithm = "AES/CBC/PKCS5Padding"; + + // when + SealedObject sealedObject = AESUtil.encryptObject(algorithm, student, key, ivParameterSpec); + Student object = (Student) AESUtil.decryptObject(algorithm, sealedObject, key, ivParameterSpec); + + // then + assertThat(student).isEqualTo(object); + } + + @Test + void givenPassword_whenEncrypt_thenSuccess() + throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, + InvalidKeyException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchPaddingException { + // given + String plainText = "www.baeldung.com"; + String password = "baeldung"; + String salt = "12345678"; + IvParameterSpec ivParameterSpec = AESUtil.generateIv(); + SecretKey key = AESUtil.getKeyFromPassword(password, salt); + + // when + String cipherText = AESUtil.encryptPasswordBased(plainText, key, ivParameterSpec); + String decryptedCipherText = AESUtil.decryptPasswordBased(cipherText, key, ivParameterSpec); + + // then + Assertions.assertEquals(plainText, decryptedCipherText); + } +} diff --git a/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java new file mode 100644 index 0000000000..fa38aca272 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.cipher; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.security.Provider; +import java.security.Security; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class AvailableCiphersUnitTest { + private final Logger logger = LoggerFactory.getLogger(AvailableCiphersUnitTest.class); + + @Test + public void whenGetServices_thenGetAllCipherAlgorithms() { + for (Provider provider : Security.getProviders()) { + for (Provider.Service service : provider.getServices()) { + logger.info(service.getAlgorithm()); + } + } + } + + @Test + public void whenGetServicesWithFilter_thenGetAllCompatibleCipherAlgorithms() { + List algorithms = Arrays.stream(Security.getProviders()) + .flatMap(provider -> provider.getServices().stream()) + .filter(service -> "Cipher".equals(service.getType())) + .map(Provider.Service::getAlgorithm) + .collect(Collectors.toList()); + + algorithms.forEach(logger::info); + } +} diff --git a/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/des/TripleDESUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/des/TripleDESUnitTest.java new file mode 100644 index 0000000000..6e5df8e619 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/des/TripleDESUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.des; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; + +public class TripleDESUnitTest { + + @Test + public void given3DesKey_whenEncryptAndDecryptString_thenCompareResults() throws Exception { + byte[] secretKey = "9mng65v8jf4lxn93nabf981m".getBytes(); + byte[] iv = "a76nb5h9".getBytes(); + + String secretMessage = "Baeldung secret message"; + + SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "DESede"); + IvParameterSpec ivSpec = new IvParameterSpec(iv); + Cipher encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); + encryptCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivSpec); + byte[] secretMessagesBytes = secretMessage.getBytes(StandardCharsets.UTF_8); + byte[] encryptedMessageBytes = encryptCipher.doFinal(secretMessagesBytes); + + Cipher decryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); + decryptCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivSpec); + byte[] decryptedMessageBytes = decryptCipher.doFinal(encryptedMessageBytes); + String decryptedMessage = new String(decryptedMessageBytes, StandardCharsets.UTF_8); + + Assertions.assertEquals(secretMessage, decryptedMessage); + } + + @Test + public void given3DesKey_whenEncryptAndDecryptFile_thenCompareResults() throws Exception { + byte[] secretKey = "9mng65v8jf4lxn93nabf981m".getBytes(); + byte[] iv = "a76nb5h9".getBytes(); + + SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "DESede"); + IvParameterSpec ivSpec = new IvParameterSpec(iv); + + String originalContent = "some secret message"; + Path tempFile = Files.createTempFile("temp", "txt"); + writeString(tempFile, originalContent); + + byte[] fileBytes = Files.readAllBytes(tempFile); + Cipher encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); + encryptCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivSpec); + byte[] encryptedFileBytes = encryptCipher.doFinal(fileBytes); + try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { + stream.write(encryptedFileBytes); + } + + encryptedFileBytes = Files.readAllBytes(tempFile); + Cipher decryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); + decryptCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivSpec); + byte[] decryptedFileBytes = decryptCipher.doFinal(encryptedFileBytes); + try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { + stream.write(decryptedFileBytes); + } + + String fileContent = readString(tempFile); + + Assertions.assertEquals(originalContent, fileContent); + } + + private void writeString(Path path, String content) throws Exception { + try (BufferedWriter writer = Files.newBufferedWriter(path)) { + writer.write(content); + } + } + + private String readString(Path path) throws Exception { + StringBuilder resultStringBuilder = new StringBuilder(); + try (BufferedReader br = new BufferedReader(new FileReader(path.toFile()))) { + String line; + while ((line = br.readLine()) != null) { + resultStringBuilder.append(line); + } + } + return resultStringBuilder.toString(); + } +} diff --git a/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java new file mode 100644 index 0000000000..9659fd8871 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java @@ -0,0 +1,92 @@ +package com.baeldung.rsa; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import javax.crypto.Cipher; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.PublicKey; + +public class RsaUnitTest { + + @Test + public void givenRsaKeyPair_whenEncryptAndDecryptString_thenCompareResults() throws Exception { + KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); + generator.initialize(2048); + KeyPair pair = generator.generateKeyPair(); + PrivateKey privateKey = pair.getPrivate(); + PublicKey publicKey = pair.getPublic(); + + String secretMessage = "Baeldung secret message"; + Cipher encryptCipher = Cipher.getInstance("RSA"); + encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey); + byte[] secretMessageBytes = secretMessage.getBytes(StandardCharsets.UTF_8); + byte[] encryptedMessageBytes = encryptCipher.doFinal(secretMessageBytes); + + Cipher decryptCipher = Cipher.getInstance("RSA"); + decryptCipher.init(Cipher.DECRYPT_MODE, privateKey); + byte[] decryptedMessageBytes = decryptCipher.doFinal(encryptedMessageBytes); + String decryptedMessage = new String(decryptedMessageBytes, StandardCharsets.UTF_8); + + Assertions.assertEquals(secretMessage, decryptedMessage); + } + + @Test + public void givenRsaKeyPair_whenEncryptAndDecryptFile_thenCompareResults() throws Exception { + KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); + generator.initialize(2048); + KeyPair pair = generator.generateKeyPair(); + PrivateKey privateKey = pair.getPrivate(); + PublicKey publicKey = pair.getPublic(); + + String originalContent = "some secret message"; + Path tempFile = Files.createTempFile("temp", "txt"); + writeString(tempFile, originalContent); + + byte[] fileBytes = Files.readAllBytes(tempFile); + Cipher encryptCipher = Cipher.getInstance("RSA"); + encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey); + byte[] encryptedFileBytes = encryptCipher.doFinal(fileBytes); + try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { + stream.write(encryptedFileBytes); + } + + encryptedFileBytes = Files.readAllBytes(tempFile); + Cipher decryptCipher = Cipher.getInstance("RSA"); + decryptCipher.init(Cipher.DECRYPT_MODE, privateKey); + byte[] decryptedFileBytes = decryptCipher.doFinal(encryptedFileBytes); + try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) { + stream.write(decryptedFileBytes); + } + + String fileContent = readString(tempFile); + + Assertions.assertEquals(originalContent, fileContent); + } + + private void writeString(Path path, String content) throws Exception { + try (BufferedWriter writer = Files.newBufferedWriter(path)) { + writer.write(content); + } + } + + private String readString(Path path) throws Exception { + StringBuilder resultStringBuilder = new StringBuilder(); + try (BufferedReader br = new BufferedReader(new FileReader(path.toFile()))) { + String line; + while ((line = br.readLine()) != null) { + resultStringBuilder.append(line); + } + } + return resultStringBuilder.toString(); + } +} From b1fb2c34e4ffccc7b65d4c910dfddad121515ffb Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 14 Nov 2021 11:08:05 +0530 Subject: [PATCH 171/551] JAVA-8282: added new module core-java-security-algorithms to parent pom --- core-java-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index c3d17e7637..5df65bd93f 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -100,6 +100,7 @@ core-java-security core-java-security-2 core-java-security-3 + core-java-security-algorithms core-java-streams core-java-streams-2 core-java-streams-3 From 0269c686d7ded41d5a0ffa14daf1e7349ee933f6 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 14 Nov 2021 13:20:22 +0530 Subject: [PATCH 172/551] JAVA-8365: Split or move core-java-io-conversions module --- .../core-java-io-conversions-2/README.md | 1 + .../JavaXToInputStreamUnitTest.java | 44 +++++++++++++++++++ .../core-java-io-conversions/README.md | 1 - .../JavaXToInputStreamUnitTest.java | 41 +++++------------ 4 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java diff --git a/core-java-modules/core-java-io-conversions-2/README.md b/core-java-modules/core-java-io-conversions-2/README.md index b2153b3669..9abb539066 100644 --- a/core-java-modules/core-java-io-conversions-2/README.md +++ b/core-java-modules/core-java-io-conversions-2/README.md @@ -4,6 +4,7 @@ This module contains articles about core Java input/output(IO) conversions. ### Relevant Articles: - [Java InputStream to String](https://www.baeldung.com/convert-input-stream-to-string) +- [Java String to InputStream](https://www.baeldung.com/convert-string-to-input-stream) - [Java – Write an InputStream to a File](https://www.baeldung.com/convert-input-stream-to-a-file) - [Converting a BufferedReader to a JSONObject](https://www.baeldung.com/java-bufferedreader-to-jsonobject) - [Reading a CSV File into an Array](https://www.baeldung.com/java-csv-file-array) diff --git a/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java new file mode 100644 index 0000000000..7e7c79f764 --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.stringtoinputstream; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.CharSource; + +public class JavaXToInputStreamUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + // tests - String - InputStream + + @Test + public final void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = CharSource.wrap(initialString).asByteSource(StandardCharsets.UTF_8).openStream(); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = IOUtils.toInputStream(initialString); + + IOUtils.closeQuietly(targetStream); + } + +} diff --git a/core-java-modules/core-java-io-conversions/README.md b/core-java-modules/core-java-io-conversions/README.md index 52f5222040..1f12c87241 100644 --- a/core-java-modules/core-java-io-conversions/README.md +++ b/core-java-modules/core-java-io-conversions/README.md @@ -13,5 +13,4 @@ This module contains articles about core Java input/output(IO) conversions. - [Java – Write a Reader to File](https://www.baeldung.com/java-write-reader-to-file) - [Java – Reader to Byte Array](https://www.baeldung.com/java-convert-reader-to-byte-array) - [Java – Reader to InputStream](https://www.baeldung.com/java-convert-reader-to-inputstream) -- [Java String to InputStream](https://www.baeldung.com/convert-string-to-input-stream) - More articles: [[next -->]](/core-java-modules/core-java-io-conversions-2) diff --git a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java index c20752639f..9d061307ce 100644 --- a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java +++ b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java @@ -1,46 +1,25 @@ package com.baeldung.filetoinputstream; -import com.google.common.io.ByteSource; -import com.google.common.io.CharSource; -import com.google.common.io.Files; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.SequenceInputStream; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; -import java.nio.charset.StandardCharsets; +import com.google.common.io.ByteSource; +import com.google.common.io.Files; public class JavaXToInputStreamUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); - // tests - String - InputStream - - @Test - public final void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { - final String initialString = "text"; - final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); - - IOUtils.closeQuietly(targetStream); - } - - @Test - public final void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { - final String initialString = "text"; - final InputStream targetStream = CharSource.wrap(initialString).asByteSource(StandardCharsets.UTF_8).openStream(); - - IOUtils.closeQuietly(targetStream); - } - - @Test - public final void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { - final String initialString = "text"; - final InputStream targetStream = IOUtils.toInputStream(initialString); - - IOUtils.closeQuietly(targetStream); - } - // byte array - InputStream @Test From 3c5cb8f4704338f9d6d1fc0b18a75348343dbbd6 Mon Sep 17 00:00:00 2001 From: mikr Date: Sun, 14 Nov 2021 11:08:17 +0100 Subject: [PATCH 173/551] JAVA-8286 Split or move spring boot runtime module --- spring-boot-modules/spring-boot-runtime-2/README.md | 2 ++ spring-boot-modules/spring-boot-runtime-2/pom.xml | 4 ++++ .../src/main/java/com/baeldung/cors/Account.java | 0 .../src/main/java/com/baeldung/cors/AccountController.java | 0 .../src/main/java/com/baeldung/cors/config/WebConfig.java | 0 .../maxhttpheadersize/MaxHttpHeaderSizeApplication.java | 0 .../maxhttpheadersize/config/MaxHTTPHeaderSizeConfig.java | 0 .../controller/MaxHttpHeaderSizeController.java | 0 .../MaxHttpHeaderSizeControllerIntegrationTest.java | 0 .../controller/MaxHttpHeaderSizeControllerLiveTest.java | 0 spring-boot-modules/spring-boot-runtime/README.md | 2 -- 11 files changed, 6 insertions(+), 2 deletions(-) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/main/java/com/baeldung/cors/Account.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/main/java/com/baeldung/cors/AccountController.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/main/java/com/baeldung/cors/config/WebConfig.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/main/java/com/baeldung/maxhttpheadersize/MaxHttpHeaderSizeApplication.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/main/java/com/baeldung/maxhttpheadersize/config/MaxHTTPHeaderSizeConfig.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/main/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeController.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerIntegrationTest.java (100%) rename spring-boot-modules/{spring-boot-runtime => spring-boot-runtime-2}/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerLiveTest.java (100%) diff --git a/spring-boot-modules/spring-boot-runtime-2/README.md b/spring-boot-modules/spring-boot-runtime-2/README.md index 9f0d814d8d..f439b0d0bd 100644 --- a/spring-boot-modules/spring-boot-runtime-2/README.md +++ b/spring-boot-modules/spring-boot-runtime-2/README.md @@ -4,3 +4,5 @@ This module contains articles about administering a Spring Boot runtime ### Relevant Articles: - [Configure the Heap Size When Starting a Spring Boot Application](https://www.baeldung.com/spring-boot-heap-size) + - [CORS with Spring](https://www.baeldung.com/spring-cors) + - [Max-HTTP-Header-Size in Spring Boot 2](https://www.baeldung.com/spring-boot-max-http-header-size) diff --git a/spring-boot-modules/spring-boot-runtime-2/pom.xml b/spring-boot-modules/spring-boot-runtime-2/pom.xml index c177529a41..62c43d20f0 100644 --- a/spring-boot-modules/spring-boot-runtime-2/pom.xml +++ b/spring-boot-modules/spring-boot-runtime-2/pom.xml @@ -25,6 +25,10 @@ spring-boot-starter-test test
+ + org.springframework.security + spring-security-test +
diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/Account.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/cors/Account.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/Account.java rename to spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/cors/Account.java diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/AccountController.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/cors/AccountController.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/AccountController.java rename to spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/cors/AccountController.java diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/config/WebConfig.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/cors/config/WebConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/config/WebConfig.java rename to spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/cors/config/WebConfig.java diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/maxhttpheadersize/MaxHttpHeaderSizeApplication.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/maxhttpheadersize/MaxHttpHeaderSizeApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/maxhttpheadersize/MaxHttpHeaderSizeApplication.java rename to spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/maxhttpheadersize/MaxHttpHeaderSizeApplication.java diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/maxhttpheadersize/config/MaxHTTPHeaderSizeConfig.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/maxhttpheadersize/config/MaxHTTPHeaderSizeConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/maxhttpheadersize/config/MaxHTTPHeaderSizeConfig.java rename to spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/maxhttpheadersize/config/MaxHTTPHeaderSizeConfig.java diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeController.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeController.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeController.java rename to spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeController.java diff --git a/spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerIntegrationTest.java b/spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerIntegrationTest.java rename to spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerLiveTest.java b/spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerLiveTest.java similarity index 100% rename from spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerLiveTest.java rename to spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/maxhttpheadersize/controller/MaxHttpHeaderSizeControllerLiveTest.java diff --git a/spring-boot-modules/spring-boot-runtime/README.md b/spring-boot-modules/spring-boot-runtime/README.md index 072bd16a78..6f21efe793 100644 --- a/spring-boot-modules/spring-boot-runtime/README.md +++ b/spring-boot-modules/spring-boot-runtime/README.md @@ -8,7 +8,5 @@ This module contains articles about administering a Spring Boot runtime - [Logging HTTP Requests with Spring Boot Actuator HTTP Tracing](https://www.baeldung.com/spring-boot-actuator-http) - [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs) - [Project Configuration with Spring](https://www.baeldung.com/project-configuration-with-spring) - - [CORS with Spring](https://www.baeldung.com/spring-cors) - [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging) - [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat) - - [Max-HTTP-Header-Size in Spring Boot 2](https://www.baeldung.com/spring-boot-max-http-header-size) From 157d7ee61c95365176fb88933c8fc1ea1f9c1217 Mon Sep 17 00:00:00 2001 From: lucaCambi77 Date: Sun, 14 Nov 2021 11:09:48 +0100 Subject: [PATCH 174/551] [BAEL-5211] - How to test a Java Optional (#11417) * feat: add how to test an optional * fix: review comments * fix: static final naming convention * fix: optional equals assertion --- .../baeldung/optional/OptionalUnitTest.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java new file mode 100644 index 0000000000..351b3dd3e0 --- /dev/null +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.optional; + +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class OptionalUnitTest { + + private static final String OPTIONAL_RETURN_VALUE = "optionalReturnValue"; + + @Test + public void givenOptionalWithValue_whenAssertThatIsNotEmpty_thenOk() { + assertThat(Optional.of(OPTIONAL_RETURN_VALUE)).isNotEmpty(); + } + + @Test + public void givenOptionalWithValue_whenAssertThatHasValue_thenOk() { + assertThat(Optional.of(OPTIONAL_RETURN_VALUE)).hasValue(OPTIONAL_RETURN_VALUE); + } + + @Test + public void givenOptionalWithValue_whenAssertEqualsOptionalObject_thenOk() { + Optional expected = Optional.of(OPTIONAL_RETURN_VALUE); + Optional actual = Optional.of(OPTIONAL_RETURN_VALUE); + assertEquals(expected, actual); + } + + @Test + public void givenOptionalWithValue_whenAssertEqualsGet_thenOk() { + Optional optional = Optional.of(OPTIONAL_RETURN_VALUE); + assertEquals(OPTIONAL_RETURN_VALUE, optional.get()); + } + + @Test + public void givenOptionalWithValue_whenIsPresentAndGetSplit_thenOk() { + Optional optional = Optional.of(OPTIONAL_RETURN_VALUE); + + assertTrue(optional.isPresent()); + assertEquals(OPTIONAL_RETURN_VALUE, optional.get()); + } + + @Test + public void givenEmptyOptional_whenAssertThatIsEmpty_thenOk() { + Optional emptyOptional = Optional.empty(); + assertThat(emptyOptional).isEmpty(); + } + + @Test + public void givenEmptyOptional_whenAssertIsNotPresent_thenOk() { + Optional emptyOptional = Optional.empty(); + assertFalse(emptyOptional.isPresent()); + } +} From 69975a655268338ea62cebf40d89f956acaf37ab Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Sun, 14 Nov 2021 14:13:47 +0100 Subject: [PATCH 175/551] Spring Webflux and @Cacheable Annotation - reverted to older version of caffeine for jdk compatibility --- spring-5-webflux/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index cd3564d404..d6afb686fc 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -74,7 +74,7 @@ com.github.ben-manes.caffeine caffeine - 3.0.4 + 2.9.2 org.springframework.boot From 68bcffe243b8eab11e994cd1c9da154a1ca2abf8 Mon Sep 17 00:00:00 2001 From: mikr Date: Sun, 14 Nov 2021 22:51:58 +0100 Subject: [PATCH 176/551] JAVA-8293 Split or move spring boot module --- spring-boot-modules/spring-boot-1/README.md | 5 ++++ spring-boot-modules/spring-boot-1/pom.xml | 23 +++++++++++++++++++ .../dynamicvalidation/ContactInfo.java | 0 .../ContactInfoValidator.java | 0 .../DynamicValidationApp.java | 0 .../config/CustomerController.java | 0 .../config/PersistenceConfig.java | 0 .../dao/ContactInfoExpressionRepository.java | 0 .../model/ContactInfoExpression.java | 0 .../dynamicvalidation/model/Customer.java | 0 .../WarInitializerApplication.java | 3 ++- .../ShutdownHookApplication.java | 0 .../baeldung/shutdownhooks/beans/Bean1.java | 0 .../baeldung/shutdownhooks/beans/Bean2.java | 0 .../baeldung/shutdownhooks/beans/Bean3.java | 0 .../config/ExampleServletContextListener.java | 0 .../config/ShutdownHookConfiguration.java | 0 ...InitializerApplicationIntegrationTest.java | 0 .../src/test/resources/application.properties | 20 ++++++++++++++++ spring-boot-modules/spring-boot/README.md | 7 ++---- 20 files changed, 52 insertions(+), 6 deletions(-) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java (88%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-1}/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java (100%) create mode 100644 spring-boot-modules/spring-boot-1/src/test/resources/application.properties diff --git a/spring-boot-modules/spring-boot-1/README.md b/spring-boot-modules/spring-boot-1/README.md index a818f60fb5..8e5214c69a 100644 --- a/spring-boot-modules/spring-boot-1/README.md +++ b/spring-boot-modules/spring-boot-1/README.md @@ -4,3 +4,8 @@ This module contains articles about Spring Boot Actuator in Spring Boot version ## Relevant articles: - [Spring Boot Actuator](https://www.baeldung.com/spring-boot-actuators) +- [A Quick Intro to the SpringBootServletInitializer](https://www.baeldung.com/spring-boot-servlet-initializer) +- [Spring Shutdown Callbacks](https://www.baeldung.com/spring-shutdown-callbacks) +- [Dynamic DTO Validation Config Retrieved from the Database](https://www.baeldung.com/spring-dynamic-dto-validation) + + diff --git a/spring-boot-modules/spring-boot-1/pom.xml b/spring-boot-modules/spring-boot-1/pom.xml index 9f91cc8f2e..82a1a38397 100644 --- a/spring-boot-modules/spring-boot-1/pom.xml +++ b/spring-boot-modules/spring-boot-1/pom.xml @@ -20,14 +20,36 @@ org.springframework.boot spring-boot-starter + + org.springframework.boot + spring-boot-starter-thymeleaf + org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-tomcat + org.springframework.boot spring-boot-starter-actuator + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.apache.logging.log4j + log4j-core + 2.14.1 + + + com.h2database + h2 + test + org.springframework.boot spring-boot-starter-test @@ -40,6 +62,7 @@ org.springframework.boot spring-boot-maven-plugin + ${spring-boot.version} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java similarity index 88% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java index 5b9ce1271e..3b360b4adc 100644 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java +++ b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java @@ -5,7 +5,8 @@ import java.time.LocalDateTime; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +//import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java rename to spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java diff --git a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-1/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-1/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-1/src/test/resources/application.properties b/spring-boot-modules/spring-boot-1/src/test/resources/application.properties new file mode 100644 index 0000000000..b14abfcc81 --- /dev/null +++ b/spring-boot-modules/spring-boot-1/src/test/resources/application.properties @@ -0,0 +1,20 @@ +spring.mail.host=localhost +spring.mail.port=8025 +spring.mail.properties.mail.smtp.auth=false + +# spring.datasource.x +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +spring.datasource.username=sa +spring.datasource.password=sa + +# hibernate.X +spring.jpa.hibernate.dialect=org.hibernate.dialect.H2Dialect +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.show_sql=true +spring.jpa.hibernate.hbm2ddl.auto=create-drop +spring.jpa.hibernate.cache.use_second_level_cache=true +spring.jpa.hibernate.cache.use_query_cache=true +spring.jpa.hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory + +management.security.enabled=false \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/README.md b/spring-boot-modules/spring-boot/README.md index 5a45502fd8..fdc8093806 100644 --- a/spring-boot-modules/spring-boot/README.md +++ b/spring-boot-modules/spring-boot/README.md @@ -8,12 +8,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [A Guide to Spring in Eclipse STS](https://www.baeldung.com/eclipse-sts-spring) -- [How to Register a Servlet in Java](https://www.baeldung.com/register-servlet) -- [Guide to Spring WebUtils and ServletRequestUtils](https://www.baeldung.com/spring-webutils-servletrequestutils) -- [Dynamic DTO Validation Config Retrieved from the Database](https://www.baeldung.com/spring-dynamic-dto-validation) - [Guide to Spring Type Conversions](https://www.baeldung.com/spring-type-conversions) - [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class) -- [A Quick Intro to the SpringBootServletInitializer](https://www.baeldung.com/spring-boot-servlet-initializer) -- [Spring Shutdown Callbacks](https://www.baeldung.com/spring-shutdown-callbacks) - [Container Configuration in Spring Boot 2](https://www.baeldung.com/embeddedservletcontainercustomizer-configurableembeddedservletcontainer-spring-boot) - [Validation in Spring Boot](https://www.baeldung.com/spring-boot-bean-validation) +- [How to Register a Servlet in Java](https://www.baeldung.com/register-servlet) +- [Guide to Spring WebUtils and ServletRequestUtils](https://www.baeldung.com/spring-webutils-servletrequestutils) From 3ca1762f6f4df324707df849adb70aa91f40596d Mon Sep 17 00:00:00 2001 From: mikr Date: Sun, 14 Nov 2021 23:02:03 +0100 Subject: [PATCH 177/551] JAVA-8279 Split or move Java core module (fix review comments) --- .../core-java-serialization/pom.xml | 5 +- .../DeserializationUnitTest.java | 4 +- .../ExternalizableUnitTest.java | 71 +++++++++++++++++++ core-java-modules/core-java-uuid/pom.xml | 2 - 4 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 core-java-modules/core-java-serialization/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java diff --git a/core-java-modules/core-java-serialization/pom.xml b/core-java-modules/core-java-serialization/pom.xml index 74a78e8b48..8fcebca356 100644 --- a/core-java-modules/core-java-serialization/pom.xml +++ b/core-java-modules/core-java-serialization/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ @@ -186,8 +185,8 @@ 1.1 3.0.0-M1 - 1.8 - 1.8 + + 4.3.20.RELEASE diff --git a/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java index cc45cbc8e0..89a603a298 100644 --- a/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java +++ b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java @@ -25,7 +25,7 @@ public class DeserializationUnitTest { @Test public void testDeserializeObj_compatible() throws IOException, ClassNotFoundException { - Assert.assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); + assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); AppleProduct macBook = new AppleProduct(); macBook.headphonePort = "headphonePort2020"; @@ -61,7 +61,7 @@ public class DeserializationUnitTest { @Test(expected = InvalidClassException.class) public void testDeserializeObj_incompatible() throws ClassNotFoundException, IOException { - Assert.assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); + assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); // attempts to deserialize the "AppleProduct" object DeserializationUtility.deSerializeObjectFromString(serializedObj); } diff --git a/core-java-modules/core-java-serialization/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java new file mode 100644 index 0000000000..651364fb13 --- /dev/null +++ b/core-java-modules/core-java-serialization/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java @@ -0,0 +1,71 @@ +package com.baeldung.externalizable; + +import org.junit.Test; + +import java.io.*; + +import static org.junit.Assert.assertTrue; + +public class ExternalizableUnitTest { + + private final static String OUTPUT_FILE = "externalizable.txt"; + + @Test + public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException { + + Country c = new Country(); + c.setCapital("Yerevan"); + c.setCode(374); + c.setName("Armenia"); + + FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); + c.writeExternal(objectOutputStream); + + objectOutputStream.flush(); + objectOutputStream.close(); + fileOutputStream.close(); + + FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE); + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); + + Country c2 = new Country(); + c2.readExternal(objectInputStream); + + objectInputStream.close(); + fileInputStream.close(); + + assertTrue(c2.getCode() == c.getCode()); + assertTrue(c2.getName().equals(c.getName())); + } + + @Test + public void whenInheritanceSerialization_then_UseExternalizable() throws IOException, ClassNotFoundException { + + Region r = new Region(); + r.setCapital("Yerevan"); + r.setCode(374); + r.setName("Armenia"); + r.setClimate("Mediterranean"); + r.setPopulation(120.000); + + FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); + r.writeExternal(objectOutputStream); + + objectOutputStream.flush(); + objectOutputStream.close(); + fileOutputStream.close(); + + FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE); + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); + + Region r2 = new Region(); + r2.readExternal(objectInputStream); + + objectInputStream.close(); + fileInputStream.close(); + + assertTrue(r2.getPopulation() == null); + } +} diff --git a/core-java-modules/core-java-uuid/pom.xml b/core-java-modules/core-java-uuid/pom.xml index fba36ada8e..a38306f269 100644 --- a/core-java-modules/core-java-uuid/pom.xml +++ b/core-java-modules/core-java-uuid/pom.xml @@ -149,8 +149,6 @@ 3.10.0 3.0.0-M1 - 1.8 - 1.8 \ No newline at end of file From 607bd2215ade1bdcdf37df15443c375f35b04ada Mon Sep 17 00:00:00 2001 From: Willian Nalepa Oizumi Date: Mon, 15 Nov 2021 10:15:35 -0300 Subject: [PATCH 178/551] BAEL-5196 - Split a comma-separated string while ignoring commas in quotes (#11432) * Creating the module 'core-java-string-operations-4' for new string related code samples. Implemented code samples for the article BAEL-5196 * including new module 'core-java-string-operations-4 in the parent project * fixing spacing in the pom file * fixing the maven configuration for our new project core-java-string-operations-4 --- .../core-java-string-operations-4/README.md | 3 + .../core-java-string-operations-4/pom.xml | 58 ++++++++++++++++ .../SplitCommaSeparatedString.java | 66 +++++++++++++++++++ .../SplitCommaSeparatedStringUnitTest.java | 44 +++++++++++++ pom.xml | 1 + 5 files changed, 172 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-4/README.md create mode 100644 core-java-modules/core-java-string-operations-4/pom.xml create mode 100644 core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedString.java create mode 100644 core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedStringUnitTest.java diff --git a/core-java-modules/core-java-string-operations-4/README.md b/core-java-modules/core-java-string-operations-4/README.md new file mode 100644 index 0000000000..88d562204b --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + + diff --git a/core-java-modules/core-java-string-operations-4/pom.xml b/core-java-modules/core-java-string-operations-4/pom.xml new file mode 100644 index 0000000000..ea6bdcd849 --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + core-java-string-operations-4 + 0.1.0-SNAPSHOT + core-java-string-operations-4 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + com.google.guava + guava + ${guava.version} + + + com.opencsv + opencsv + ${opencsv.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + 11 + 11 + 3.6.1 + 31.0.1-jre + 4.1 + + + diff --git a/core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedString.java b/core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedString.java new file mode 100644 index 0000000000..c3bbdb4dfb --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedString.java @@ -0,0 +1,66 @@ +package com.baeldung.commaseparatedstring; + +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +import com.google.common.base.Splitter; +import com.opencsv.CSVParser; +import com.opencsv.CSVParserBuilder; +import com.opencsv.CSVReader; +import com.opencsv.CSVReaderBuilder; + +public class SplitCommaSeparatedString { + + public static List splitWithParser(String input) { + + List tokens = new ArrayList(); + int startPosition = 0; + boolean isInQuotes = false; + for (int currentPosition = 0; currentPosition < input.length(); currentPosition++) { + if (input.charAt(currentPosition) == '\"') { + isInQuotes = !isInQuotes; + } else if (input.charAt(currentPosition) == ',' && !isInQuotes) { + tokens.add(input.substring(startPosition, currentPosition)); + startPosition = currentPosition + 1; + } + } + + String lastToken = input.substring(startPosition); + if (lastToken.equals(",")) { + tokens.add(""); + } else { + tokens.add(lastToken); + } + + return tokens; + } + + public static List splitWithRegex(String input) { + String[] tokens = input.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1); + return Arrays.asList(tokens); + } + + public static List splitWithGuava(String input) { + Pattern pattern = Pattern.compile(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); + Splitter splitter = Splitter.on(pattern); + return splitter.splitToList(input); + } + + public static List splitMultiLineWithOpenCSV(String input) throws IOException { + CSVParser parser = new CSVParserBuilder().withSeparator(',') + .build(); + + CSVReader reader = new CSVReaderBuilder(new StringReader(input)).withCSVParser(parser) + .build(); + + List list = new ArrayList<>(); + list = reader.readAll(); + reader.close(); + + return list; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedStringUnitTest.java b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedStringUnitTest.java new file mode 100644 index 0000000000..ca34430099 --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/commaseparatedstring/SplitCommaSeparatedStringUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.commaseparatedstring; + +import static com.baeldung.commaseparatedstring.SplitCommaSeparatedString.splitMultiLineWithOpenCSV; +import static com.baeldung.commaseparatedstring.SplitCommaSeparatedString.splitWithGuava; +import static com.baeldung.commaseparatedstring.SplitCommaSeparatedString.splitWithParser; +import static com.baeldung.commaseparatedstring.SplitCommaSeparatedString.splitWithRegex; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertArrayEquals; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +public class SplitCommaSeparatedStringUnitTest { + + @Test + public void givenSingleLineInput_whenParsing_shouldIgnoreCommasInsideDoubleQuotes() { + String input = "baeldung,tutorial,splitting,text,\"ignoring this comma,\""; + + var matcher = contains("baeldung", "tutorial", "splitting", "text", "\"ignoring this comma,\""); + assertThat(splitWithParser(input), matcher); + assertThat(splitWithRegex(input), matcher); + assertThat(splitWithGuava(input), matcher); + } + + @Test + public void givenMultiLineInput_whenParsing_shouldIgnoreCommasInsideDoubleQuotes() throws IOException { + String input = "baeldung,tutorial,splitting,text,\"ignoring this comma,\"" + System.lineSeparator() + + "splitting,a,regular,line,no double quotes"; + + String[] firstLine = new String[]{"baeldung", "tutorial", "splitting", "text", "ignoring this comma,"}; + String[] secondLine = new String[]{"splitting", "a", "regular", "line", "no double quotes"}; + + List result = splitMultiLineWithOpenCSV(input); + + assertThat(result, hasSize(2)); + assertArrayEquals(firstLine, result.get(0)); + assertArrayEquals(secondLine, result.get(1)); + } + +} diff --git a/pom.xml b/pom.xml index 372bc5a9f3..2672706f6b 100644 --- a/pom.xml +++ b/pom.xml @@ -1304,6 +1304,7 @@ core-java-modules/core-java-jpms core-java-modules/core-java-os core-java-modules/core-java-string-operations-3 + core-java-modules/core-java-string-operations-4 core-java-modules/core-java-time-measurements core-java-modules/multimodulemavenproject persistence-modules/sirix From c4ed8d458e26c98c595acde60a595edb4f1a7b8b Mon Sep 17 00:00:00 2001 From: mikr Date: Mon, 15 Nov 2021 21:37:22 +0100 Subject: [PATCH 179/551] JAVA-8293 Split or move Spring Boot module (fix review comments) --- spring-boot-modules/spring-boot-1/pom.xml | 6 +++++- .../servletinitializer/WarInitializerApplication.java | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-1/pom.xml b/spring-boot-modules/spring-boot-1/pom.xml index 82a1a38397..b6e3717f7c 100644 --- a/spring-boot-modules/spring-boot-1/pom.xml +++ b/spring-boot-modules/spring-boot-1/pom.xml @@ -43,7 +43,7 @@ org.apache.logging.log4j log4j-core - 2.14.1 + ${log4j2.version} com.h2database @@ -67,4 +67,8 @@ + + 2.14.1 + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java index 3b360b4adc..0aa0f0ae0b 100644 --- a/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java +++ b/spring-boot-modules/spring-boot-1/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java @@ -5,7 +5,6 @@ import java.time.LocalDateTime; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -//import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; From d7caae1c24bc4cc34f415ad42c2f5eef32d8ccd0 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 16 Nov 2021 11:25:14 +0100 Subject: [PATCH 180/551] JAVA-7783: POM properties cleanup --- spring-web-modules/spring-5-mvc/pom.xml | 6 --- spring-web-modules/spring-rest-shell/pom.xml | 9 ---- .../spring-resttemplate-2/pom.xml | 9 ---- .../spring-resttemplate-3/pom.xml | 1 - spring-web-modules/spring-thymeleaf-2/pom.xml | 2 - testing-modules/gatling/pom.xml | 8 +-- testing-modules/junit-5/pom.xml | 1 - .../load-testing-comparison/pom.xml | 54 ++----------------- xml/pom.xml | 3 -- 9 files changed, 8 insertions(+), 85 deletions(-) diff --git a/spring-web-modules/spring-5-mvc/pom.xml b/spring-web-modules/spring-5-mvc/pom.xml index 79a4f73ace..23bcb00801 100644 --- a/spring-web-modules/spring-5-mvc/pom.xml +++ b/spring-web-modules/spring-5-mvc/pom.xml @@ -81,12 +81,6 @@ ${project.basedir}/src/test/kotlin - - - org.springframework.boot - spring-boot-maven-plugin - - diff --git a/spring-web-modules/spring-rest-shell/pom.xml b/spring-web-modules/spring-rest-shell/pom.xml index b83a0b6002..992092f43f 100644 --- a/spring-web-modules/spring-rest-shell/pom.xml +++ b/spring-web-modules/spring-rest-shell/pom.xml @@ -37,13 +37,4 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-2/pom.xml b/spring-web-modules/spring-resttemplate-2/pom.xml index d0191b970e..b87b245da9 100644 --- a/spring-web-modules/spring-resttemplate-2/pom.xml +++ b/spring-web-modules/spring-resttemplate-2/pom.xml @@ -66,13 +66,4 @@
- - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/pom.xml b/spring-web-modules/spring-resttemplate-3/pom.xml index 8e313ccf39..b036a5ffcb 100644 --- a/spring-web-modules/spring-resttemplate-3/pom.xml +++ b/spring-web-modules/spring-resttemplate-3/pom.xml @@ -16,7 +16,6 @@ - org.springframework.boot spring-boot-starter-web diff --git a/spring-web-modules/spring-thymeleaf-2/pom.xml b/spring-web-modules/spring-thymeleaf-2/pom.xml index b2b893ecd5..14e4de668b 100644 --- a/spring-web-modules/spring-thymeleaf-2/pom.xml +++ b/spring-web-modules/spring-thymeleaf-2/pom.xml @@ -65,8 +65,6 @@ - 1.8 - 1.8 2.2 diff --git a/testing-modules/gatling/pom.xml b/testing-modules/gatling/pom.xml index c702b576c5..f1c9906581 100644 --- a/testing-modules/gatling/pom.xml +++ b/testing-modules/gatling/pom.xml @@ -109,10 +109,10 @@ 1.8 1.8 UTF-8 - 2.12.6 - 3.3.1 - 4.3.0 - 3.0.4 + 2.12.6 + 3.3.1 + 4.3.0 + 3.0.4 \ No newline at end of file diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index ef6e92faa4..7a511dfe7a 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -28,7 +28,6 @@ ${junit-platform.version} test - org.junit.platform junit-platform-console-standalone diff --git a/testing-modules/load-testing-comparison/pom.xml b/testing-modules/load-testing-comparison/pom.xml index 63f2d9ce2f..d5a389d311 100644 --- a/testing-modules/load-testing-comparison/pom.xml +++ b/testing-modules/load-testing-comparison/pom.xml @@ -57,57 +57,11 @@ - - - - - - - - - - org.springframework.boot spring-boot-maven-plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -115,10 +69,10 @@ 1.8 1.8 UTF-8 - 2.12.12 - 3.4.0 - 4.4.0 - 3.1.0 + 2.12.12 + 3.4.0 + 4.4.0 + 3.1.0 5.0 diff --git a/xml/pom.xml b/xml/pom.xml index d05f2401e3..9acaecbd22 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -372,11 +372,8 @@ 2.6.3 2.3.29 0.9.6 - - 2.4 1.3.1 - 3.8.0 1.14.3 2.25 3.4 From 46df55b61ea3e3669df58299d2d784d73820d223 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 16 Nov 2021 15:10:49 +0100 Subject: [PATCH 181/551] JAVA-7783: POM properties cleanup --- core-java-modules/core-java-11-2/pom.xml | 1 - core-java-modules/core-java-12/pom.xml | 2 +- core-java-modules/core-java-16/pom.xml | 3 +-- core-java-modules/core-java-17/pom.xml | 1 - core-java-modules/core-java-9/pom.xml | 1 - core-java-modules/core-java-annotations/pom.xml | 8 ++++---- core-java-modules/core-java-arrays-guides/pom.xml | 6 +++++- .../core-java-date-operations-1/pom.xml | 3 ++- .../core-java-datetime-string/pom.xml | 3 ++- core-java-modules/core-java-exceptions-2/pom.xml | 3 +-- core-java-modules/core-java-exceptions-3/pom.xml | 3 ++- core-java-modules/core-java-exceptions/pom.xml | 3 +-- core-java-modules/core-java-jndi/pom.xml | 3 ++- core-java-modules/core-java-jpms/pom.xml | 3 +-- .../core-java-lang-oop-methods/pom.xml | 1 - core-java-modules/core-java-networking-3/pom.xml | 3 ++- core-java-modules/core-java-nio-2/pom.xml | 6 +++++- core-java-modules/core-java-reflection-2/pom.xml | 7 ++++--- core-java-modules/core-java-reflection/pom.xml | 1 - core-java-modules/core-java-serialization/pom.xml | 2 +- core-java-modules/core-java-streams-3/pom.xml | 3 +-- .../core-java-string-conversions-2/pom.xml | 14 +++++++------- .../spring-security-web-mvc-custom/pom.xml | 6 ------ .../spring-security-web-persistent-login/pom.xml | 6 ------ .../spring-security-web-rest-basic-auth/pom.xml | 11 ----------- .../spring-security-web-thymeleaf/pom.xml | 9 --------- spring-vertx/pom.xml | 9 --------- spring-webflux-amqp/pom.xml | 9 --------- spring-webflux-threads/pom.xml | 9 --------- 29 files changed, 42 insertions(+), 97 deletions(-) diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 863c9b0717..2b7b042c61 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -89,7 +89,6 @@ 29.0-jre 3.17.2 5.11.1 - 3.12.0 3.0.0 3.0.0 2.3.1 diff --git a/core-java-modules/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml index 26b7d0c14d..516f28fc3a 100644 --- a/core-java-modules/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -25,7 +25,7 @@ commons-io commons-io - 2.11.0 + ${commons-io.version} diff --git a/core-java-modules/core-java-16/pom.xml b/core-java-modules/core-java-16/pom.xml index 14f15cdd92..99952a73d9 100644 --- a/core-java-modules/core-java-16/pom.xml +++ b/core-java-modules/core-java-16/pom.xml @@ -26,7 +26,7 @@ org.apache.commons commons-lang3 - 3.12.0 + ${commons-lang3.version} @@ -66,7 +66,6 @@ 16 16 16 - 3.8.1 3.0.0-M5 3.17.2 diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml index 3cee27b276..677454a64b 100644 --- a/core-java-modules/core-java-17/pom.xml +++ b/core-java-modules/core-java-17/pom.xml @@ -62,7 +62,6 @@ 17 17 17 - 3.8.1 3.0.0-M5 3.17.2 diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 1bd650f7d2..d4d58085c8 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -85,7 +85,6 @@ 1.9 25.1-jre 4.1 - 3.2.2 \ No newline at end of file diff --git a/core-java-modules/core-java-annotations/pom.xml b/core-java-modules/core-java-annotations/pom.xml index 19d02aa2ac..7e87678159 100644 --- a/core-java-modules/core-java-annotations/pom.xml +++ b/core-java-modules/core-java-annotations/pom.xml @@ -23,10 +23,6 @@ - - 3.10.0 - - core-java-annotations @@ -36,5 +32,9 @@ + + + 3.10.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-guides/pom.xml b/core-java-modules/core-java-arrays-guides/pom.xml index 3dba2dc05f..0c8b680c1b 100644 --- a/core-java-modules/core-java-arrays-guides/pom.xml +++ b/core-java-modules/core-java-arrays-guides/pom.xml @@ -27,9 +27,13 @@ org.assertj assertj-core - 3.19.0 + ${assertj.version} test + + 3.19.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-date-operations-1/pom.xml b/core-java-modules/core-java-date-operations-1/pom.xml index 854d6ed916..8a13163ba4 100644 --- a/core-java-modules/core-java-date-operations-1/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -34,7 +34,7 @@ com.darwinsys hirondelle-date4j - RELEASE + ${hirondelle-date4j.version} test @@ -64,6 +64,7 @@ 2.10 3.6.1 + RELEASE 1.9 1.9 diff --git a/core-java-modules/core-java-datetime-string/pom.xml b/core-java-modules/core-java-datetime-string/pom.xml index 8bc7b60126..a65659be71 100644 --- a/core-java-modules/core-java-datetime-string/pom.xml +++ b/core-java-modules/core-java-datetime-string/pom.xml @@ -46,7 +46,7 @@ com.darwinsys hirondelle-date4j - RELEASE + ${hirondelle-date4j.version} test @@ -75,6 +75,7 @@ 1.6 2.10.10 + RELEASE 3.6.1 1.9 diff --git a/core-java-modules/core-java-exceptions-2/pom.xml b/core-java-modules/core-java-exceptions-2/pom.xml index af7a778b23..d952683a64 100644 --- a/core-java-modules/core-java-exceptions-2/pom.xml +++ b/core-java-modules/core-java-exceptions-2/pom.xml @@ -25,12 +25,11 @@ org.apache.commons commons-lang3 - ${commons.lang3.version} + ${commons-lang3.version} - 3.10 3.10.0 diff --git a/core-java-modules/core-java-exceptions-3/pom.xml b/core-java-modules/core-java-exceptions-3/pom.xml index bdee998e8d..ffc21799ce 100644 --- a/core-java-modules/core-java-exceptions-3/pom.xml +++ b/core-java-modules/core-java-exceptions-3/pom.xml @@ -19,7 +19,7 @@ com.h2database h2 - 1.4.191 + ${h2.version} test @@ -34,6 +34,7 @@ 3.10.0 + 1.4.191 \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml index 1f15dabe36..d5581279b5 100644 --- a/core-java-modules/core-java-exceptions/pom.xml +++ b/core-java-modules/core-java-exceptions/pom.xml @@ -30,7 +30,7 @@ org.apache.commons commons-lang3 - ${commons.lang3.version} + ${commons-lang3.version} @@ -43,7 +43,6 @@ 1.5.0-b01 - 3.10 3.10.0 diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index 6b7c4e1359..f971623bc2 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -50,7 +50,7 @@ org.assertj assertj-core - 3.21.0 + ${assertj-core.version} test @@ -71,6 +71,7 @@ 5.0.9.RELEASE 1.4.199 + 3.21.0 2.0.0.AM26 1.8 1.8 diff --git a/core-java-modules/core-java-jpms/pom.xml b/core-java-modules/core-java-jpms/pom.xml index 65f5afad47..62aa49f299 100644 --- a/core-java-modules/core-java-jpms/pom.xml +++ b/core-java-modules/core-java-jpms/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${compiler.plugin.version} + ${maven-compiler-plugin.version} ${source.version} ${target.version} @@ -36,7 +36,6 @@ - 3.8.0 11 11 diff --git a/core-java-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml index e493f716ec..938b457872 100644 --- a/core-java-modules/core-java-lang-oop-methods/pom.xml +++ b/core-java-modules/core-java-lang-oop-methods/pom.xml @@ -40,7 +40,6 @@ 1.18.12 - 2.6 3.10.0 3.0.3 diff --git a/core-java-modules/core-java-networking-3/pom.xml b/core-java-modules/core-java-networking-3/pom.xml index 1579418b54..2fd97ef831 100644 --- a/core-java-modules/core-java-networking-3/pom.xml +++ b/core-java-modules/core-java-networking-3/pom.xml @@ -38,7 +38,7 @@ com.sun.mail javax.mail - 1.6.2 + ${javax.mail.version} @@ -80,6 +80,7 @@ 5.3.3 1.32 0.17 + 1.6.2 \ No newline at end of file diff --git a/core-java-modules/core-java-nio-2/pom.xml b/core-java-modules/core-java-nio-2/pom.xml index f9cf1f3060..9d5e267b46 100644 --- a/core-java-modules/core-java-nio-2/pom.xml +++ b/core-java-modules/core-java-nio-2/pom.xml @@ -18,9 +18,13 @@ org.assertj assertj-core - 3.6.1 + ${assertj.version} test + + 3.6.1 + + \ No newline at end of file diff --git a/core-java-modules/core-java-reflection-2/pom.xml b/core-java-modules/core-java-reflection-2/pom.xml index 75168936a7..06ac745f17 100644 --- a/core-java-modules/core-java-reflection-2/pom.xml +++ b/core-java-modules/core-java-reflection-2/pom.xml @@ -24,12 +24,12 @@ org.reflections reflections - 0.9.12 + ${reflections.version} com.google.guava guava - 30.1.1-jre + ${guava.version} @@ -56,7 +56,8 @@ - 3.8.0 + 0.9.12 + 30.1.1-jre 1.8 1.8 5.3.4 diff --git a/core-java-modules/core-java-reflection/pom.xml b/core-java-modules/core-java-reflection/pom.xml index b28ecccb80..32777e228f 100644 --- a/core-java-modules/core-java-reflection/pom.xml +++ b/core-java-modules/core-java-reflection/pom.xml @@ -45,7 +45,6 @@ - 3.8.0 3.10.0 1.8 1.8 diff --git a/core-java-modules/core-java-serialization/pom.xml b/core-java-modules/core-java-serialization/pom.xml index 8fcebca356..754dcd434b 100644 --- a/core-java-modules/core-java-serialization/pom.xml +++ b/core-java-modules/core-java-serialization/pom.xml @@ -58,7 +58,7 @@ org.springframework spring-core - 4.3.20.RELEASE + ${spring.core.version} test diff --git a/core-java-modules/core-java-streams-3/pom.xml b/core-java-modules/core-java-streams-3/pom.xml index b384ef7e0e..eb440430f6 100644 --- a/core-java-modules/core-java-streams-3/pom.xml +++ b/core-java-modules/core-java-streams-3/pom.xml @@ -65,7 +65,7 @@ org.openjdk.jmh jmh-generator-annprocess - ${jmh.version} + ${jmh-generator.version} @@ -77,7 +77,6 @@ 1.18.20 3.6.1 - 1.29 \ No newline at end of file diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index 68be7d2c08..3e03f4c016 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -49,13 +49,6 @@ - - 64.2 - 3.12.2 - 1.9 - 30.1.1-jre - - core-java-string-conversions-2 @@ -65,5 +58,12 @@ + + + 64.2 + 3.12.2 + 1.9 + 30.1.1-jre + \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-mvc-custom/pom.xml b/spring-security-modules/spring-security-web-mvc-custom/pom.xml index 533a1bf83d..ba6b50a7bc 100644 --- a/spring-security-modules/spring-security-web-mvc-custom/pom.xml +++ b/spring-security-modules/spring-security-web-mvc-custom/pom.xml @@ -97,12 +97,6 @@ ${jstl.version} runtime - - - - - - com.fasterxml.jackson.core diff --git a/spring-security-modules/spring-security-web-persistent-login/pom.xml b/spring-security-modules/spring-security-web-persistent-login/pom.xml index 2d931c416c..8a61868172 100644 --- a/spring-security-modules/spring-security-web-persistent-login/pom.xml +++ b/spring-security-modules/spring-security-web-persistent-login/pom.xml @@ -127,12 +127,6 @@ ${spring-boot.version} test - - - - - - diff --git a/spring-security-modules/spring-security-web-rest-basic-auth/pom.xml b/spring-security-modules/spring-security-web-rest-basic-auth/pom.xml index de28df1933..a717339082 100644 --- a/spring-security-modules/spring-security-web-rest-basic-auth/pom.xml +++ b/spring-security-modules/spring-security-web-rest-basic-auth/pom.xml @@ -91,17 +91,6 @@ ${jackson.version} - - - - - - - - - - - org.apache.httpcomponents httpcore diff --git a/spring-security-modules/spring-security-web-thymeleaf/pom.xml b/spring-security-modules/spring-security-web-thymeleaf/pom.xml index 3a240f4129..c13aa6a471 100644 --- a/spring-security-modules/spring-security-web-thymeleaf/pom.xml +++ b/spring-security-modules/spring-security-web-thymeleaf/pom.xml @@ -45,13 +45,4 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/spring-vertx/pom.xml b/spring-vertx/pom.xml index bd2dfa6cf6..e24bb3f1ee 100644 --- a/spring-vertx/pom.xml +++ b/spring-vertx/pom.xml @@ -47,15 +47,6 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - 3.4.1 diff --git a/spring-webflux-amqp/pom.xml b/spring-webflux-amqp/pom.xml index 498556da2d..3ceb33dc3b 100755 --- a/spring-webflux-amqp/pom.xml +++ b/spring-webflux-amqp/pom.xml @@ -61,13 +61,4 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/spring-webflux-threads/pom.xml b/spring-webflux-threads/pom.xml index bc5050b660..fedfaa6967 100644 --- a/spring-webflux-threads/pom.xml +++ b/spring-webflux-threads/pom.xml @@ -62,13 +62,4 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file From 805660947a547e5e4714ca25f1654eedef8a501d Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 16 Nov 2021 15:19:52 +0100 Subject: [PATCH 182/551] JAVA-7783: Fix jmh dependencies --- .../core-java-arrays-operations-advanced/pom.xml | 13 ++++++------- core-java-modules/core-java-streams-3/pom.xml | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml index d122e3330c..50830eba2a 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/pom.xml +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -28,20 +28,15 @@ org.openjdk.jmh jmh-core - ${jmh.version} + ${jmh-core.version} org.openjdk.jmh jmh-generator-annprocess - ${jmh.version} + ${jmh-generator.version} - - 3.10.0 - 1.33 - - @@ -69,4 +64,8 @@ + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-streams-3/pom.xml b/core-java-modules/core-java-streams-3/pom.xml index eb440430f6..6ace96fc4d 100644 --- a/core-java-modules/core-java-streams-3/pom.xml +++ b/core-java-modules/core-java-streams-3/pom.xml @@ -29,12 +29,12 @@ org.openjdk.jmh jmh-core - ${jmh.version} + ${jmh-core.version} org.openjdk.jmh jmh-generator-annprocess - ${jmh.version} + ${jmh-generator.version} test From 94d0a715e6faac461acc1bc5e9e1d8c427bdc695 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 16 Nov 2021 20:45:27 +0100 Subject: [PATCH 183/551] JAVA-8376 Split or move spring-boot-properties-2 module --- spring-boot-modules/spring-boot-properties-2/README.md | 1 - spring-boot-modules/spring-boot-properties-3/README.md | 1 + .../properties/json/ConfigPropertiesDemoApplication.java | 0 .../java/com/baeldung/properties/json/CustomJsonProperties.java | 0 .../main/java/com/baeldung/properties/json/JsonProperties.java | 0 .../baeldung/properties/json/JsonPropertyContextInitializer.java | 0 .../properties/json/factory/JsonPropertySourceFactory.java | 0 .../src/main/resources/configprops.json | 0 .../baeldung/properties/json/JsonPropertiesIntegrationTest.java | 0 9 files changed, 1 insertion(+), 1 deletion(-) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/main/java/com/baeldung/properties/json/ConfigPropertiesDemoApplication.java (100%) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/main/java/com/baeldung/properties/json/CustomJsonProperties.java (100%) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/main/java/com/baeldung/properties/json/JsonProperties.java (100%) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/main/java/com/baeldung/properties/json/JsonPropertyContextInitializer.java (100%) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/main/java/com/baeldung/properties/json/factory/JsonPropertySourceFactory.java (100%) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/main/resources/configprops.json (100%) rename spring-boot-modules/{spring-boot-properties-2 => spring-boot-properties-3}/src/test/java/com/baeldung/properties/json/JsonPropertiesIntegrationTest.java (100%) diff --git a/spring-boot-modules/spring-boot-properties-2/README.md b/spring-boot-modules/spring-boot-properties-2/README.md index c81ad50e40..501beed092 100644 --- a/spring-boot-modules/spring-boot-properties-2/README.md +++ b/spring-boot-modules/spring-boot-properties-2/README.md @@ -3,7 +3,6 @@ This module contains articles about Properties in Spring Boot. ### Relevant Articles: -- [Load Spring Boot Properties From a JSON File](https://www.baeldung.com/spring-boot-json-properties) - [A Quick Guide to Spring @Value](https://www.baeldung.com/spring-value-annotation) - [Using Spring @Value with Defaults](https://www.baeldung.com/spring-value-defaults) - [How to Inject a Property Value Into a Class Not Managed by Spring?](https://www.baeldung.com/inject-properties-value-non-spring-class) diff --git a/spring-boot-modules/spring-boot-properties-3/README.md b/spring-boot-modules/spring-boot-properties-3/README.md index df272be7f4..a682ae0ac8 100644 --- a/spring-boot-modules/spring-boot-properties-3/README.md +++ b/spring-boot-modules/spring-boot-properties-3/README.md @@ -7,3 +7,4 @@ - [How to Define a Map in YAML for a POJO?](https://www.baeldung.com/yaml-map-pojo) - [Using application.yml vs application.properties in Spring Boot](https://www.baeldung.com/spring-boot-yaml-vs-properties) +- [Load Spring Boot Properties From a JSON File](https://www.baeldung.com/spring-boot-json-properties) \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/ConfigPropertiesDemoApplication.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/ConfigPropertiesDemoApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/ConfigPropertiesDemoApplication.java rename to spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/ConfigPropertiesDemoApplication.java diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/CustomJsonProperties.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/CustomJsonProperties.java similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/CustomJsonProperties.java rename to spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/CustomJsonProperties.java diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/JsonProperties.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/JsonProperties.java similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/JsonProperties.java rename to spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/JsonProperties.java diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/JsonPropertyContextInitializer.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/JsonPropertyContextInitializer.java similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/JsonPropertyContextInitializer.java rename to spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/JsonPropertyContextInitializer.java diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/factory/JsonPropertySourceFactory.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/factory/JsonPropertySourceFactory.java similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/json/factory/JsonPropertySourceFactory.java rename to spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/properties/json/factory/JsonPropertySourceFactory.java diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/resources/configprops.json b/spring-boot-modules/spring-boot-properties-3/src/main/resources/configprops.json similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/main/resources/configprops.json rename to spring-boot-modules/spring-boot-properties-3/src/main/resources/configprops.json diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/json/JsonPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/properties/json/JsonPropertiesIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/json/JsonPropertiesIntegrationTest.java rename to spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/properties/json/JsonPropertiesIntegrationTest.java From 9e22d43bab859baab9fbaa7f81845a85c0fc56fb Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Tue, 16 Nov 2021 20:44:48 +0000 Subject: [PATCH 184/551] [JAVA-6455] Update H2 code with latest Spring Boot changes --- .../springboot/SpringBootH2Application.java | 2 + .../springboot/daos/CountryRepository.java | 7 +++ .../h2db/springboot/daos/UserRepository.java | 10 ---- .../h2db/springboot/models/Country.java | 21 ++++++++ .../baeldung/h2db/springboot/models/User.java | 54 ------------------- .../main/resources/application-h2.properties | 1 + .../src/main/resources/data-h2.sql | 5 ++ .../src/main/resources/data-trans.sql | 14 ----- .../baeldung/SpringBootH2IntegrationTest.java | 36 +++---------- 9 files changed, 43 insertions(+), 107 deletions(-) create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/CountryRepository.java delete mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java delete mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/User.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/application-h2.properties create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java index 378093cfa9..d6d7a20f55 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java @@ -2,8 +2,10 @@ package com.baeldung.h2db.springboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; @SpringBootApplication +@PropertySource("classpath:application-h2.properties") public class SpringBootH2Application { public static void main(String... args) { diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/CountryRepository.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/CountryRepository.java new file mode 100644 index 0000000000..d576be9098 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/CountryRepository.java @@ -0,0 +1,7 @@ +package com.baeldung.h2db.springboot.daos; + +import com.baeldung.h2db.springboot.models.Country; +import org.springframework.data.repository.CrudRepository; + +public interface CountryRepository extends CrudRepository { +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java deleted file mode 100644 index 35e496e910..0000000000 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.h2db.springboot.daos; - - - - -import com.baeldung.h2db.springboot.models.User; -import org.springframework.data.repository.CrudRepository; - -public interface UserRepository extends CrudRepository { -} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java new file mode 100644 index 0000000000..f0f02c41d3 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java @@ -0,0 +1,21 @@ +package com.baeldung.h2db.springboot.models; + +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Table(name = "countries") +@Entity +@Data +public class Country { + + @Id + @GeneratedValue + private int id; + + private String name; + +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/User.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/User.java deleted file mode 100644 index fa3c01c035..0000000000 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/User.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baeldung.h2db.springboot.models; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -@Table(name = "users") -@Entity -public class User { - - @Id - @GeneratedValue - private int id; - - private String firstName; - - private String lastName; - - public User() { } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - @Override - public String toString() { - return "User{" + - "id=" + id + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - '}'; - } -} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-h2.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-h2.properties new file mode 100644 index 0000000000..6fb436f520 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-h2.properties @@ -0,0 +1 @@ +spring.sql.init.data-locations=data-h2.sql diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql new file mode 100644 index 0000000000..3d04b578d2 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql @@ -0,0 +1,5 @@ +INSERT INTO countries (id, name) VALUES (1, 'USA'); +INSERT INTO countries (id, name) VALUES (2, 'France'); +INSERT INTO countries (id, name) VALUES (3, 'Brazil'); +INSERT INTO countries (id, name) VALUES (4, 'Italy'); +INSERT INTO countries (id, name) VALUES (5, 'Canada'); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql index b8835e70cb..e4fda99437 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql @@ -1,17 +1,3 @@ -DROP TABLE IF EXISTS billionaires; - -CREATE TABLE billionaires ( - id INT AUTO_INCREMENT PRIMARY KEY, - first_name VARCHAR(250) NOT NULL, - last_name VARCHAR(250) NOT NULL, - career VARCHAR(250) DEFAULT NULL -); - -INSERT INTO billionaires (first_name, last_name, career) VALUES -('Aliko', 'Dangote', 'Billionaire Industrialist'), -('Bill', 'Gates', 'Billionaire Tech Entrepreneur'), -('Folrunsho', 'Alakija', 'Billionaire Oil Magnate'); - insert into USER values (101, 'user1', 'comment1'); insert into USER values (102, 'user2', 'comment2'); insert into USER values (103, 'user3', 'comment3'); diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java index aecc63c599..abdbd76c19 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java @@ -1,50 +1,28 @@ package com.baeldung; import com.baeldung.h2db.springboot.SpringBootH2Application; -import com.baeldung.h2db.springboot.daos.UserRepository; -import com.baeldung.h2db.springboot.models.User; +import com.baeldung.h2db.springboot.daos.CountryRepository; +import com.baeldung.h2db.springboot.models.Country; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import java.util.List; - -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringBootH2Application.class) public class SpringBootH2IntegrationTest { @Autowired - private UserRepository userRepository; + private CountryRepository countryRepository; @Test - public void contextLoads() { } + public void givenInitData_whenApplicationStarts_thenDataIsLoaded() { + Iterable users = countryRepository.findAll(); - @Test - public void givenUserProfile_whenAddUser_thenCreateNewUser() { - User user = new User(); - user.setFirstName("John"); - user.setLastName("Doe"); - userRepository.save(user); - List users = (List) userRepository.findAll(); - assertFalse(users.isEmpty()); - - String firstName = "Aliko"; - String lastName = "Dangote"; - User user1 = userRepository.findById(users.get(0).getId()).get(); - user1.setLastName(lastName); - user1.setFirstName(firstName); - userRepository.save(user1); - - user = userRepository.findById(user.getId()).get(); - assertEquals(user.getFirstName(), firstName); - assertEquals(user.getLastName(), lastName); - - userRepository.deleteById(user.getId()); - assertTrue( ((List) userRepository.findAll()).isEmpty()); + assertThat(users).hasSize(5); } } From 96d1d4658f64c2d615b11c402f342d740a5e2753 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 17 Nov 2021 08:39:05 +0100 Subject: [PATCH 185/551] JAVA-8374 Split or move spring-boot-libraries module --- spring-boot-modules/spring-boot-libraries-2/README.md | 2 ++ .../src/main/java/com/baeldung/kong/QueryController.java | 0 .../src/main/java/com/baeldung/kong/StockApp.java | 0 .../src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java | 0 .../test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java | 0 .../src/test/java/com/baeldung/kong/domain/APIObject.java | 0 .../src/test/java/com/baeldung/kong/domain/ConsumerObject.java | 0 .../src/test/java/com/baeldung/kong/domain/KeyAuthObject.java | 0 .../src/test/java/com/baeldung/kong/domain/PluginObject.java | 0 .../src/test/java/com/baeldung/kong/domain/TargetObject.java | 0 .../src/test/java/com/baeldung/kong/domain/UpstreamObject.java | 0 spring-boot-modules/spring-boot-libraries/README.md | 2 +- 12 files changed, 3 insertions(+), 1 deletion(-) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/main/java/com/baeldung/kong/QueryController.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/main/java/com/baeldung/kong/StockApp.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/domain/APIObject.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/domain/ConsumerObject.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/domain/PluginObject.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/domain/TargetObject.java (100%) rename spring-boot-modules/{spring-boot-libraries => spring-boot-libraries-2}/src/test/java/com/baeldung/kong/domain/UpstreamObject.java (100%) diff --git a/spring-boot-modules/spring-boot-libraries-2/README.md b/spring-boot-modules/spring-boot-libraries-2/README.md index 7bf51b5424..cf07279258 100644 --- a/spring-boot-modules/spring-boot-libraries-2/README.md +++ b/spring-boot-modules/spring-boot-libraries-2/README.md @@ -6,3 +6,5 @@ This module contains articles about various Spring Boot libraries - [Background Jobs in Spring with JobRunr](https://www.baeldung.com/java-jobrunr-spring) - [Open API Server Implementation Using OpenAPI Generator](https://www.baeldung.com/java-openapi-generator-server) +- [An Introduction to Kong](https://www.baeldung.com/kong) + More articles: [[prev -->]](/spring-boot-modules/spring-boot-libraries) diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/kong/QueryController.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/kong/QueryController.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/kong/QueryController.java rename to spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/kong/QueryController.java diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/kong/StockApp.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/kong/StockApp.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/kong/StockApp.java rename to spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/kong/StockApp.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/APIObject.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/APIObject.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/APIObject.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/APIObject.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/ConsumerObject.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/ConsumerObject.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/ConsumerObject.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/ConsumerObject.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/PluginObject.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/PluginObject.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/PluginObject.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/PluginObject.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/TargetObject.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/TargetObject.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/TargetObject.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/TargetObject.java diff --git a/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/UpstreamObject.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/UpstreamObject.java similarity index 100% rename from spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/kong/domain/UpstreamObject.java rename to spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/domain/UpstreamObject.java diff --git a/spring-boot-modules/spring-boot-libraries/README.md b/spring-boot-modules/spring-boot-libraries/README.md index 6976435866..b72815e4a9 100644 --- a/spring-boot-modules/spring-boot-libraries/README.md +++ b/spring-boot-modules/spring-boot-libraries/README.md @@ -14,7 +14,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring Boot and Caffeine Cache](https://www.baeldung.com/spring-boot-caffeine-cache) - [Spring Boot and Togglz Aspect](https://www.baeldung.com/spring-togglz) - [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql) -- [An Introduction to Kong](https://www.baeldung.com/kong) +- More articles: [[next -->]](/spring-boot-modules/spring-boot-libraries-2) ### GraphQL sample queries From f4ee97e3bd6c1532072fe6dfe977ecb432dad8c9 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 17 Nov 2021 09:20:17 +0100 Subject: [PATCH 186/551] JAVA-8393 Split or move spring-security-core module --- spring-boot-modules/spring-boot-security/README.md | 1 + spring-security-modules/spring-security-core/README.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-security/README.md b/spring-boot-modules/spring-boot-security/README.md index 2c9d37eac0..b9966709cb 100644 --- a/spring-boot-modules/spring-boot-security/README.md +++ b/spring-boot-modules/spring-boot-security/README.md @@ -9,6 +9,7 @@ This module contains articles about Spring Boot Security - [Introduction to Spring Security Taglibs](https://www.baeldung.com/spring-security-taglibs) - [Guide to @CurrentSecurityContext in Spring Security](https://www.baeldung.com/spring-currentsecuritycontext) - [Disable Security for a Profile in Spring Boot](https://www.baeldung.com/spring-security-disable-profile) +- [Spring @EnableWebSecurity vs. @EnableGlobalMethodSecurity](https://www.baeldung.com/spring-enablewebsecurity-vs-enableglobalmethodsecurity) ### Spring Boot Security Auto-Configuration diff --git a/spring-security-modules/spring-security-core/README.md b/spring-security-modules/spring-security-core/README.md index f9c6d2e5fb..9f8e4dda53 100644 --- a/spring-security-modules/spring-security-core/README.md +++ b/spring-security-modules/spring-security-core/README.md @@ -10,7 +10,6 @@ This module contains articles about core Spring Security - [Deny Access on Missing @PreAuthorize to Spring Controller Methods](https://www.baeldung.com/spring-deny-access) - [Spring Security: Check If a User Has a Role in Java](https://www.baeldung.com/spring-security-check-user-role) - [Filtering Jackson JSON Output Based on Spring Security Role](https://www.baeldung.com/spring-security-role-filter-json) -- [Spring @EnableWebSecurity vs. @EnableGlobalMethodSecurity](https://www.baeldung.com/spring-enablewebsecurity-vs-enableglobalmethodsecurity) ### Build the Project From cae6bbc8fed09c124ce3c48a5a4561ff7389a6e9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 17 Nov 2021 13:48:38 +0100 Subject: [PATCH 187/551] JAVA-8436: Add assertj.version property to the main pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 2672706f6b..5e693c9809 100644 --- a/pom.xml +++ b/pom.xml @@ -1388,6 +1388,7 @@ 4.13.2 + 3.21.0 2.2 1.3 3.3.0 From db2aa7e14b1bcfe419dddda67e8a059c016b0703 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:02:47 +0800 Subject: [PATCH 188/551] Update README.md --- xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/xml/README.md b/xml/README.md index 367a0334f6..16942c6836 100644 --- a/xml/README.md +++ b/xml/README.md @@ -12,3 +12,4 @@ This module contains articles about eXtensible Markup Language (XML) - [Convert XML to HTML in Java](https://www.baeldung.com/java-convert-xml-to-html) - [Parsing an XML File Using StAX](https://www.baeldung.com/java-stax) - [Parsing an XML File Using SAX Parser](https://www.baeldung.com/java-sax-parser) +- [Remove HTML Tags Using Java](https://www.baeldung.com/java-remove-html-tags) From 6934b67f3c01cc0950511903660e0d71657253e2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:05:19 +0800 Subject: [PATCH 189/551] Update README.md --- .../spring-boot-basic-customization-2/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-basic-customization-2/README.md b/spring-boot-modules/spring-boot-basic-customization-2/README.md index f041c1d38a..0e688bda2a 100644 --- a/spring-boot-modules/spring-boot-basic-customization-2/README.md +++ b/spring-boot-modules/spring-boot-basic-customization-2/README.md @@ -5,4 +5,5 @@ This module contains articles about Spring Boot customization 2 ### Relevant Articles: - [DispatcherServlet and web.xml in Spring Boot](https://www.baeldung.com/spring-boot-dispatcherservlet-web-xml) - - [XML Defined Beans in Spring Boot](https://www.baeldung.com/spring-boot-xml-beans) \ No newline at end of file + - [XML Defined Beans in Spring Boot](https://www.baeldung.com/spring-boot-xml-beans) + - [What Is OncePerRequestFilter?](https://www.baeldung.com/spring-onceperrequestfilter) From dd9eb450fda5010eb3e352620a7d01e9ba56b7d1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:09:16 +0800 Subject: [PATCH 190/551] Update README.md --- testing-modules/testing-assertions/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/testing-assertions/README.md b/testing-modules/testing-assertions/README.md index ea238af599..bf35505211 100644 --- a/testing-modules/testing-assertions/README.md +++ b/testing-modules/testing-assertions/README.md @@ -2,3 +2,4 @@ - [Asserting Log Messages With JUnit](https://www.baeldung.com/junit-asserting-logs) - [Assert Two Lists for Equality Ignoring Order in Java](https://www.baeldung.com/java-assert-lists-equality-ignore-order) +- [Assert That a Java Optional Has a Certain Value](https://www.baeldung.com/java-optional-assert-value) From e876696709748d6d055ea550a841453a7cdce662 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:10:53 +0800 Subject: [PATCH 191/551] Update README.md --- spring-5-webflux/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md index bd667468fb..889f211fc6 100644 --- a/spring-5-webflux/README.md +++ b/spring-5-webflux/README.md @@ -11,3 +11,4 @@ This module contains articles about Spring 5 WebFlux - [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) - [Set a Timeout in Spring 5 Webflux WebClient](https://www.baeldung.com/spring-webflux-timeout) - [Guide to Retry in Spring WebFlux](https://www.baeldung.com/spring-webflux-retry) +- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable) From 705ed4cf45d9f0ad65d1f8b9c9caa01f1cd5d2a8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:12:46 +0800 Subject: [PATCH 192/551] Update README.md --- core-java-modules/core-java-string-operations-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-4/README.md b/core-java-modules/core-java-string-operations-4/README.md index 88d562204b..304f604c5e 100644 --- a/core-java-modules/core-java-string-operations-4/README.md +++ b/core-java-modules/core-java-string-operations-4/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: +- [Ignoring Commas in Quotes When Splitting a Comma-separated String](https://www.baeldung.com/java-split-string-commas) From 2f836203153fadd939bb3cd790830ca68a5d9fd7 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:14:49 +0800 Subject: [PATCH 193/551] Update README.md --- core-java-modules/core-java-lang-oop-constructors/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-oop-constructors/README.md b/core-java-modules/core-java-lang-oop-constructors/README.md index 69ade3e25a..d3d05d31bf 100644 --- a/core-java-modules/core-java-lang-oop-constructors/README.md +++ b/core-java-modules/core-java-lang-oop-constructors/README.md @@ -8,3 +8,4 @@ This module contains article about constructors in Java - [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error) - [Private Constructors in Java](https://www.baeldung.com/java-private-constructors) - [Throwing Exceptions in Constructors](https://www.baeldung.com/java-constructors-exceptions) +- [Constructors in Java Abstract Classes](https://www.baeldung.com/java-abstract-classes-constructors) From 87c4b8ccf5224c83bc928ca07c57fd40abcfcd8e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 18 Nov 2021 01:18:47 +0800 Subject: [PATCH 194/551] Update README.md --- apache-poi/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apache-poi/README.md b/apache-poi/README.md index d19af8d6ef..13d62eeba0 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -13,3 +13,4 @@ This module contains articles about Apache POI - [Setting Formulas in Excel with Apache POI](https://www.baeldung.com/java-apache-poi-set-formulas) - [Insert a Row in Excel Using Apache POI](https://www.baeldung.com/apache-poi-insert-excel-row) - [Multiline Text in Excel Cell Using Apache POI](https://www.baeldung.com/apache-poi-write-multiline-text) +- [Set Background Color of a Cell with Apache POI](https://www.baeldung.com/apache-poi-background-color) From 17838fe0836645f922e13a89b10ae842dc9e713e Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Wed, 17 Nov 2021 21:06:29 +0000 Subject: [PATCH 195/551] [JAVA-8383] Add charset to email mime type to handle special chars --- .../java/com/baeldung/mail/EmailService.java | 90 +++++++++++-------- .../src/main/resources/attachment.txt | 1 + .../baeldung/mail/EmailServiceLiveTest.java | 60 +++++++++++++ 3 files changed, 113 insertions(+), 38 deletions(-) create mode 100644 core-java-modules/core-java-networking-2/src/main/resources/attachment.txt create mode 100644 core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/EmailServiceLiveTest.java diff --git a/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/EmailService.java b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/EmailService.java index bd2024fdfa..3d1e25e7a4 100644 --- a/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/EmailService.java +++ b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/EmailService.java @@ -1,40 +1,55 @@ package com.baeldung.mail; -import javax.mail.*; +import javax.mail.Authenticator; +import javax.mail.Message; +import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import java.io.File; +import java.net.URI; import java.util.Properties; public class EmailService { - private String host = ""; - private int port = 0; - private String username = ""; - private String password = ""; + private String username; + private String password; + private final Properties prop; public EmailService(String host, int port, String username, String password) { - - this.host = host; - this.port = port; - this.username = username; - this.password = password; - - sendMail(); - } - - private void sendMail() { - - Properties prop = new Properties(); + prop = new Properties(); prop.put("mail.smtp.auth", true); prop.put("mail.smtp.starttls.enable", "true"); prop.put("mail.smtp.host", host); prop.put("mail.smtp.port", port); prop.put("mail.smtp.ssl.trust", host); + this.username = username; + this.password = password; + } + + public EmailService(String host, int port) { + prop = new Properties(); + prop.put("mail.smtp.host", host); + prop.put("mail.smtp.port", port); + } + + public static void main(String... args) { + try { + new EmailService("smtp.mailtrap.io", 25, "87ba3d9555fae8", "91cb4379af43ed") + .sendMail(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void sendMail() throws Exception { + Session session = Session.getInstance(prop, new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { @@ -42,36 +57,35 @@ public class EmailService { } }); - try { + Message message = new MimeMessage(session); + message.setFrom(new InternetAddress("from@gmail.com")); + message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to@gmail.com")); + message.setSubject("Mail Subject"); - Message message = new MimeMessage(session); - message.setFrom(new InternetAddress("from@gmail.com")); - message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to@gmail.com")); - message.setSubject("Mail Subject"); + String msg = "This is my first email using JavaMailer"; - String msg = "This is my first email using JavaMailer"; + MimeBodyPart mimeBodyPart = new MimeBodyPart(); + mimeBodyPart.setContent(msg, "text/html; charset=utf-8"); - MimeBodyPart mimeBodyPart = new MimeBodyPart(); - mimeBodyPart.setContent(msg, "text/html"); + MimeBodyPart attachmentBodyPart = new MimeBodyPart(); - MimeBodyPart attachmentBodyPart = new MimeBodyPart(); - attachmentBodyPart.attachFile(new File("pom.xml")); + attachmentBodyPart.attachFile(getFile()); - Multipart multipart = new MimeMultipart(); - multipart.addBodyPart(mimeBodyPart); - multipart.addBodyPart(attachmentBodyPart); + Multipart multipart = new MimeMultipart(); + multipart.addBodyPart(mimeBodyPart); + multipart.addBodyPart(attachmentBodyPart); - message.setContent(multipart); + message.setContent(multipart); - Transport.send(message); - - } catch (Exception e) { - e.printStackTrace(); - } + Transport.send(message); } - public static void main(String ... args) { - new EmailService("smtp.mailtrap.io", 25, "87ba3d9555fae8", "91cb4379af43ed"); + private File getFile() throws Exception { + URI uri = this.getClass() + .getClassLoader() + .getResource("attachment.txt") + .toURI(); + return new File(uri); } } diff --git a/core-java-modules/core-java-networking-2/src/main/resources/attachment.txt b/core-java-modules/core-java-networking-2/src/main/resources/attachment.txt new file mode 100644 index 0000000000..a726ded018 --- /dev/null +++ b/core-java-modules/core-java-networking-2/src/main/resources/attachment.txt @@ -0,0 +1 @@ +sample attachment content \ No newline at end of file diff --git a/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/EmailServiceLiveTest.java b/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/EmailServiceLiveTest.java new file mode 100644 index 0000000000..7f543bc612 --- /dev/null +++ b/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/EmailServiceLiveTest.java @@ -0,0 +1,60 @@ +package com.baeldung.mail; + +import com.icegreen.greenmail.junit.GreenMailRule; +import com.icegreen.greenmail.util.ServerSetupTest; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +public class EmailServiceLiveTest { + + @Rule + public final GreenMailRule greenMail = new GreenMailRule(ServerSetupTest.SMTP); + + private EmailService emailService; + + @Before + public void setup() { + emailService = new EmailService("localhost", greenMail.getSmtp().getPort()); + } + + @Test + public void givenEmailMessageWithAttachment_whenEmailIsSent_MessageIsReceived() throws Exception { + + emailService.sendMail(); + + MimeMessage[] receivedMessages = greenMail.getReceivedMessages(); + assertEquals(1, receivedMessages.length); + + MimeMessage receivedMessage = receivedMessages[0]; + assertEquals("Mail Subject", subjectFromMessage(receivedMessage)); + assertEquals("This is my first email using JavaMailer", emailTextFrom(receivedMessage)); + assertEquals("sample attachment content", attachmentContentsFrom(receivedMessage)); + } + + private static String subjectFromMessage(MimeMessage receivedMessage) throws MessagingException { + return receivedMessage.getSubject(); + } + + private static String emailTextFrom(MimeMessage receivedMessage) throws IOException, MessagingException { + return ((MimeMultipart) receivedMessage.getContent()) + .getBodyPart(0) + .getContent() + .toString(); + } + + private static String attachmentContentsFrom(MimeMessage receivedMessage) throws Exception { + return ((MimeMultipart) receivedMessage.getContent()) + .getBodyPart(1) + .getContent() + .toString(); + } + +} From 238622e14d211b86e7624ad4989832dc5984c844 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 10:30:45 +0100 Subject: [PATCH 196/551] JAVA-8436: Add AssertJ dependency to the main pom.xml --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 5e693c9809..6d10dcb668 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,12 @@ ${junit-jupiter.version} test + + org.assertj + assertj-core + ${assertj.version} + test + org.hamcrest hamcrest From 997b3c5fbf076ef4a3de2311c7578f1c32d00493 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 10:36:49 +0100 Subject: [PATCH 197/551] JAVA-8436: Remove AssertJ depenendency from the child modules - part 1 --- spring-core-2/pom.xml | 6 ------ spring-core-4/pom.xml | 7 ------- spring-di/pom.xml | 7 ------- spring-ejb/spring-ejb-remote/pom.xml | 7 ------- spring-jersey/pom.xml | 7 ------- testing-modules/assertion-libraries/pom.xml | 7 ------- testing-modules/junit5-annotations/pom.xml | 7 ------- testing-modules/mockito-3/pom.xml | 7 ------- testing-modules/testing-assertions/pom.xml | 7 ------- testing-modules/testing-libraries-2/pom.xml | 7 ------- video-tutorials/jackson-annotations/pom.xml | 7 ------- xml/pom.xml | 7 ------- 12 files changed, 83 deletions(-) diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index de5c7c0d4d..dda23c4ea4 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -129,11 +129,6 @@ spring-test test - - org.assertj - assertj-core - test - org.hamcrest hamcrest @@ -205,7 +200,6 @@ 25.1-jre 3.6 - 3.6.1 2.1.0 3.22.0-GA 3.2.2 diff --git a/spring-core-4/pom.xml b/spring-core-4/pom.xml index f9665a672b..1c3e138670 100644 --- a/spring-core-4/pom.xml +++ b/spring-core-4/pom.xml @@ -61,12 +61,6 @@ ${awaitility.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - javax.servlet javax.servlet-api @@ -79,7 +73,6 @@ 2.2.2.RELEASE 28.2-jre 4.0.2 - 2.9.1 \ No newline at end of file diff --git a/spring-di/pom.xml b/spring-di/pom.xml index cbd49242e4..20207663cf 100644 --- a/spring-di/pom.xml +++ b/spring-di/pom.xml @@ -74,12 +74,6 @@ ${mockito.spring.boot.version} test - - org.assertj - assertj-core - ${assertj.version} - test - commons-io commons-io @@ -156,7 +150,6 @@ 20.0 1.5.2.RELEASE 1.10.19 - 3.12.2 1.9.5 diff --git a/spring-ejb/spring-ejb-remote/pom.xml b/spring-ejb/spring-ejb-remote/pom.xml index b7bf2aa79b..a180955dcf 100644 --- a/spring-ejb/spring-ejb-remote/pom.xml +++ b/spring-ejb/spring-ejb-remote/pom.xml @@ -19,12 +19,6 @@ javaee-api provided - - org.assertj - assertj-core - ${assertj.version} - test - @@ -86,7 +80,6 @@ - 3.9.0 1.6.1 1.1.0.Alpha5 diff --git a/spring-jersey/pom.xml b/spring-jersey/pom.xml index 64a34074bb..197469ccf9 100644 --- a/spring-jersey/pom.xml +++ b/spring-jersey/pom.xml @@ -105,12 +105,6 @@ slf4j-jdk14 ${org.slf4j.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.springframework.boot @@ -218,7 +212,6 @@ 4.5.5 4.0.0 2.27.2 - 3.10.0 1.5.10.RELEASE diff --git a/testing-modules/assertion-libraries/pom.xml b/testing-modules/assertion-libraries/pom.xml index 42dead6ee2..b5cfd711d2 100644 --- a/testing-modules/assertion-libraries/pom.xml +++ b/testing-modules/assertion-libraries/pom.xml @@ -39,12 +39,6 @@ assertj-guava ${assertj-guava.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.javalite javalite-common @@ -84,7 +78,6 @@ 0.32 3.1.0 - 3.9.0 2.1.0 1.4.13 0.12 diff --git a/testing-modules/junit5-annotations/pom.xml b/testing-modules/junit5-annotations/pom.xml index 86e71110c8..95c0d2d448 100644 --- a/testing-modules/junit5-annotations/pom.xml +++ b/testing-modules/junit5-annotations/pom.xml @@ -37,17 +37,10 @@ ${junit-platform.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - 2.8.2 - 3.11.1 \ No newline at end of file diff --git a/testing-modules/mockito-3/pom.xml b/testing-modules/mockito-3/pom.xml index 5a79d81080..10130290df 100644 --- a/testing-modules/mockito-3/pom.xml +++ b/testing-modules/mockito-3/pom.xml @@ -22,17 +22,10 @@ ${mockito.version} test - - org.assertj - assertj-core - ${assertj.version} - test - 3.8.0 - 3.8.0 \ No newline at end of file diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml index f9cd35c5e5..12af95b575 100644 --- a/testing-modules/testing-assertions/pom.xml +++ b/testing-modules/testing-assertions/pom.xml @@ -18,12 +18,6 @@ logback-classic ${logback.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.hamcrest hamcrest-all @@ -39,7 +33,6 @@ - 3.16.1 4.4 diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml index 2e8a1b4ed2..c7e9ea0e2b 100644 --- a/testing-modules/testing-libraries-2/pom.xml +++ b/testing-modules/testing-libraries-2/pom.xml @@ -30,12 +30,6 @@ ${lombok.version} provided - - org.assertj - assertj-core - ${assertj-core.version} - test - com.github.stefanbirkner system-rules @@ -114,7 +108,6 @@ 1.19.0 1.0.0 1.1.0 - 3.16.1 \ No newline at end of file diff --git a/video-tutorials/jackson-annotations/pom.xml b/video-tutorials/jackson-annotations/pom.xml index 827715fe5f..29f457964b 100644 --- a/video-tutorials/jackson-annotations/pom.xml +++ b/video-tutorials/jackson-annotations/pom.xml @@ -100,12 +100,6 @@ ${json-schema-validator.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -126,7 +120,6 @@ 3.0.1 3.0.0 - 3.6.1 2.2.6 3.0.1 diff --git a/xml/pom.xml b/xml/pom.xml index 9acaecbd22..968682ee38 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -123,12 +123,6 @@ commons-lang ${commons-lang.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.xmlunit xmlunit-assertj @@ -368,7 +362,6 @@ 2.3.0.1 2.3.2 1.0-2 - 3.12.2 2.6.3 2.3.29 0.9.6 From 5088366074ec4741178256a1a1117ff975e2bbea Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 12:23:39 +0100 Subject: [PATCH 198/551] JAVA-8436: Remove AssertJ depenendency from the child modules - part 2 --- apache-kafka/pom.xml | 7 ------- apache-libraries/pom.xml | 8 -------- aws/pom.xml | 7 ------- blade/pom.xml | 7 ------- cdi/pom.xml | 7 ------- ddd-modules/pom.xml | 8 -------- guest/core-java/pom.xml | 7 ------- immutables/pom.xml | 7 ------- javax-servlets/pom.xml | 7 ------- javaxval/pom.xml | 7 ------- jjwt/pom.xml | 5 ----- lombok/pom.xml | 7 ------- mapstruct/pom.xml | 7 ------- metrics/pom.xml | 7 ------- mustache/pom.xml | 4 ---- patterns/design-patterns-architectural/pom.xml | 7 ------- patterns/design-patterns-behavioral-2/pom.xml | 13 ------------- patterns/design-patterns-behavioral/pom.xml | 7 ------- patterns/design-patterns-creational/pom.xml | 7 ------- patterns/dip/pom.xml | 13 ------------- reactor-core/pom.xml | 7 ------- rxjava-core/pom.xml | 6 ------ rxjava-libraries/pom.xml | 6 ------ rxjava-observables/pom.xml | 6 ------ rxjava-operators/pom.xml | 6 ------ spring-boot-modules/spring-boot-keycloak/pom.xml | 8 -------- spring-cloud/spring-cloud-archaius/pom.xml | 5 ----- spring-core/pom.xml | 7 ------- 28 files changed, 200 deletions(-) diff --git a/apache-kafka/pom.xml b/apache-kafka/pom.xml index 8003743f95..9ff894bc55 100644 --- a/apache-kafka/pom.xml +++ b/apache-kafka/pom.xml @@ -98,12 +98,6 @@ jackson-databind ${jackson.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.testcontainers kafka @@ -170,7 +164,6 @@ - 3.6.2 2.8.0 1.15.3 1.15.3 diff --git a/apache-libraries/pom.xml b/apache-libraries/pom.xml index b4cf11b07d..3d78869865 100644 --- a/apache-libraries/pom.xml +++ b/apache-libraries/pom.xml @@ -156,13 +156,6 @@ solr-solrj ${solr.solr-solrj.version} - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -202,7 +195,6 @@ 1.8 1.8.2 2.19.0 - 3.9.0 1.1.2 1.1.0.Final 1.2.0 diff --git a/aws/pom.xml b/aws/pom.xml index 1663266612..7c363eb400 100644 --- a/aws/pom.xml +++ b/aws/pom.xml @@ -26,12 +26,6 @@ ${mockito-core.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - com.amazonaws aws-lambda-java-core @@ -118,7 +112,6 @@ 2.8.0 1.11.290 2.21.0 - 3.8.0 1.11.86 https://s3-us-west-2.amazonaws.com/dynamodb-local/release 1.10.L001 diff --git a/blade/pom.xml b/blade/pom.xml index 8fc517e966..9c8638f0bc 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -36,12 +36,6 @@ provided - - org.assertj - assertj-core - ${assertj-core.version} - test - org.apache.httpcomponents httpclient @@ -119,7 +113,6 @@ 4.5.6 4.5.6 4.4.10 - 3.11.1 3.0.0-M3 0.7 3.1.0 diff --git a/cdi/pom.xml b/cdi/pom.xml index 5eb566dcfb..ee23e082c7 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -25,12 +25,6 @@ weld-se-core ${weld-se-core.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.aspectj aspectjweaver @@ -53,7 +47,6 @@ 2.0.SP1 3.0.5.Final 1.9.2 - 3.10.0 \ No newline at end of file diff --git a/ddd-modules/pom.xml b/ddd-modules/pom.xml index fe3aaf1160..134a9d0566 100644 --- a/ddd-modules/pom.xml +++ b/ddd-modules/pom.xml @@ -39,12 +39,6 @@ ${junit-jupiter.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -80,8 +74,6 @@ 3.8.1 1.0 - - 3.12.2 diff --git a/guest/core-java/pom.xml b/guest/core-java/pom.xml index aaf67fd27e..2ab067ad40 100644 --- a/guest/core-java/pom.xml +++ b/guest/core-java/pom.xml @@ -20,17 +20,10 @@ log4j-core ${log4j2.version} - - org.assertj - assertj-core - ${assertj.version} - test - 2.8.2 - 3.6.1 \ No newline at end of file diff --git a/immutables/pom.xml b/immutables/pom.xml index 648166fd74..7704cddbb6 100644 --- a/immutables/pom.xml +++ b/immutables/pom.xml @@ -18,12 +18,6 @@ value ${immutables.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.mutabilitydetector MutabilityDetector @@ -34,7 +28,6 @@ 2.5.6 - 3.6.1 0.9.6 diff --git a/javax-servlets/pom.xml b/javax-servlets/pom.xml index f1677050cf..1dc58aa917 100644 --- a/javax-servlets/pom.xml +++ b/javax-servlets/pom.xml @@ -16,12 +16,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - commons-fileupload @@ -56,7 +50,6 @@ 4.5.3 2.8.2 - 3.9.1 4.0.1 diff --git a/javaxval/pom.xml b/javaxval/pom.xml index f0093e0aa4..57369c6f52 100644 --- a/javaxval/pom.xml +++ b/javaxval/pom.xml @@ -34,19 +34,12 @@ spring-test ${org.springframework.version} - - org.assertj - assertj-core - ${assertj.version} - test - 6.0.13.Final 3.0.0 5.0.2.RELEASE - 3.11.1 \ No newline at end of file diff --git a/jjwt/pom.xml b/jjwt/pom.xml index 4c194f9285..cc169ba9fc 100644 --- a/jjwt/pom.xml +++ b/jjwt/pom.xml @@ -38,11 +38,6 @@ jjwt ${jjwt.version} - - org.assertj - assertj-core - test - diff --git a/lombok/pom.xml b/lombok/pom.xml index c5758ea8df..2daaf9f438 100644 --- a/lombok/pom.xml +++ b/lombok/pom.xml @@ -26,12 +26,6 @@ hibernate-jpa-2.1-api ${hibernate-jpa-2.1-api.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -77,7 +71,6 @@ 1.0.0.Final 1.18.10.0 - 3.8.0 \ No newline at end of file diff --git a/mapstruct/pom.xml b/mapstruct/pom.xml index 48687a73b9..4696a46abb 100644 --- a/mapstruct/pom.xml +++ b/mapstruct/pom.xml @@ -41,12 +41,6 @@ lombok-mapstruct-binding ${lombok.mapstruct.binding.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -87,7 +81,6 @@ 1.8 1.8 0.2.0 - 3.16.1 \ No newline at end of file diff --git a/metrics/pom.xml b/metrics/pom.xml index 0ba590ceec..6ac1761ca0 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -75,12 +75,6 @@ metrics-aspectj-deps ${metrics-aspectj.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.netflix.spectator spectator-api @@ -95,7 +89,6 @@ 1.7.1 2.0.7.RELEASE - 3.11.1 1.1.0 diff --git a/mustache/pom.xml b/mustache/pom.xml index db72e693c1..faa8bfd8a1 100644 --- a/mustache/pom.xml +++ b/mustache/pom.xml @@ -20,10 +20,6 @@ compiler ${mustache.compiler.api.version} - - org.assertj - assertj-core - org.springframework.boot spring-boot-starter-web diff --git a/patterns/design-patterns-architectural/pom.xml b/patterns/design-patterns-architectural/pom.xml index 11194a9c92..fe7bd38df8 100644 --- a/patterns/design-patterns-architectural/pom.xml +++ b/patterns/design-patterns-architectural/pom.xml @@ -30,12 +30,6 @@ rest-assured ${rest-assured.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.hibernate hibernate-core @@ -50,7 +44,6 @@ - 3.9.1 5.2.16.Final 6.0.6 2.5.3 diff --git a/patterns/design-patterns-behavioral-2/pom.xml b/patterns/design-patterns-behavioral-2/pom.xml index f123a8f2f5..da29575526 100644 --- a/patterns/design-patterns-behavioral-2/pom.xml +++ b/patterns/design-patterns-behavioral-2/pom.xml @@ -14,17 +14,4 @@ 1.0.0-SNAPSHOT - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - 3.12.2 - - \ No newline at end of file diff --git a/patterns/design-patterns-behavioral/pom.xml b/patterns/design-patterns-behavioral/pom.xml index bc032a0f8f..3ddbd6f0fc 100644 --- a/patterns/design-patterns-behavioral/pom.xml +++ b/patterns/design-patterns-behavioral/pom.xml @@ -36,18 +36,11 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - 16.0.2 3.0.1 - 3.9.1 \ No newline at end of file diff --git a/patterns/design-patterns-creational/pom.xml b/patterns/design-patterns-creational/pom.xml index 21bc13c21c..de854d260e 100644 --- a/patterns/design-patterns-creational/pom.xml +++ b/patterns/design-patterns-creational/pom.xml @@ -26,18 +26,11 @@ jsr305 ${javax.annotations.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - 2.4.1 3.0.2 - 3.9.1 \ No newline at end of file diff --git a/patterns/dip/pom.xml b/patterns/dip/pom.xml index 44062aaede..3618791b97 100644 --- a/patterns/dip/pom.xml +++ b/patterns/dip/pom.xml @@ -14,17 +14,4 @@ 1.0.0-SNAPSHOT - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - 3.12.1 - - \ No newline at end of file diff --git a/reactor-core/pom.xml b/reactor-core/pom.xml index 420b1b028a..39a66cee3e 100644 --- a/reactor-core/pom.xml +++ b/reactor-core/pom.xml @@ -26,12 +26,6 @@ ${reactor.version} test - - org.assertj - assertj-core - ${assertj.version} - test - org.projectlombok lombok @@ -42,7 +36,6 @@ 3.4.9 - 3.6.1 \ No newline at end of file diff --git a/rxjava-core/pom.xml b/rxjava-core/pom.xml index cd6075e127..89ea1bf7a2 100644 --- a/rxjava-core/pom.xml +++ b/rxjava-core/pom.xml @@ -30,15 +30,9 @@ awaitility ${awaitility.version} - - org.assertj - assertj-core - ${assertj.version} - - 3.8.0 1.2.5 1.7.0 2.2.2 diff --git a/rxjava-libraries/pom.xml b/rxjava-libraries/pom.xml index 5d2c9ec3bb..f8df78d741 100644 --- a/rxjava-libraries/pom.xml +++ b/rxjava-libraries/pom.xml @@ -41,11 +41,6 @@ ${h2.version} runtime - - org.assertj - assertj-core - ${assertj.version} - @@ -53,7 +48,6 @@ 1.2.5 2.0.0 2.2.2 - 3.8.0 \ No newline at end of file diff --git a/rxjava-observables/pom.xml b/rxjava-observables/pom.xml index feb4fc1f39..bcc3c4bbce 100644 --- a/rxjava-observables/pom.xml +++ b/rxjava-observables/pom.xml @@ -25,17 +25,11 @@ rxjava-string ${rx.java.string.version} - - org.assertj - assertj-core - ${assertj.version} - 1.1.1 1.2.5 - 3.8.0 \ No newline at end of file diff --git a/rxjava-operators/pom.xml b/rxjava-operators/pom.xml index ba85dc428b..d833fb5d14 100644 --- a/rxjava-operators/pom.xml +++ b/rxjava-operators/pom.xml @@ -31,11 +31,6 @@ rxjava2-extensions ${rxjava2.ext.version} - - org.assertj - assertj-core - ${assertj.version} - io.reactivex rxjava-math @@ -51,7 +46,6 @@ 0.20.4 2.2.2 - 3.8.0 1.2.5 1.0.0 1.7.0 diff --git a/spring-boot-modules/spring-boot-keycloak/pom.xml b/spring-boot-modules/spring-boot-keycloak/pom.xml index adad6bb2d2..09ddcaa724 100644 --- a/spring-boot-modules/spring-boot-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-keycloak/pom.xml @@ -73,19 +73,11 @@ org.springframework.boot spring-boot-starter-web-services - org.springframework.security spring-security-test test - - org.assertj - assertj-core - 3.21.0 - test - - diff --git a/spring-cloud/spring-cloud-archaius/pom.xml b/spring-cloud/spring-cloud-archaius/pom.xml index efd912f8db..ba977bbdc9 100644 --- a/spring-cloud/spring-cloud-archaius/pom.xml +++ b/spring-cloud/spring-cloud-archaius/pom.xml @@ -46,11 +46,6 @@ org.springframework.boot spring-boot-starter-test - - org.assertj - assertj-core - test - org.junit.platform junit-platform-runner diff --git a/spring-core/pom.xml b/spring-core/pom.xml index ab41670224..7afcf7addd 100644 --- a/spring-core/pom.xml +++ b/spring-core/pom.xml @@ -57,12 +57,6 @@ ${mockito.spring.boot.version} test - - org.assertj - assertj-core - ${assertj.version} - test - commons-io commons-io @@ -89,7 +83,6 @@ 20.0 1.5.2.RELEASE 1.10.19 - 3.12.2 \ No newline at end of file From 676f45803210d953d7adda74c407577535cc1be3 Mon Sep 17 00:00:00 2001 From: andresluzu Date: Thu, 18 Nov 2021 06:38:36 -0500 Subject: [PATCH 199/551] BAEL-5132 Abstract class constructors examples (#11389) --- .../defaultconstructor/AbstractClass.java | 5 ++++ .../defaultconstructor/ConcreteClass.java | 8 ++++++ .../noargs/AbstractClass.java | 8 ++++++ .../noargs/ConcreteClassA.java | 4 +++ .../noargs/ConcreteClassB.java | 8 ++++++ .../abstractconstructors/noargs/Counter.java | 18 ++++++++++++ .../noargs/SimpleCounter.java | 13 +++++++++ .../parametrized/Car.java | 28 +++++++++++++++++++ .../parametrized/ElectricCar.java | 17 +++++++++++ .../parametrized/FuelCar.java | 17 +++++++++++ .../noargs/AbstractClassUnitTest.java | 18 ++++++++++++ .../noargs/CounterUnitTest.java | 16 +++++++++++ .../parametrized/CarUnitTest.java | 20 +++++++++++++ 13 files changed, 180 insertions(+) create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/AbstractClass.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/ConcreteClass.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/AbstractClass.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassA.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassB.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/Counter.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/SimpleCounter.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/Car.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/ElectricCar.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/FuelCar.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/AbstractClassUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/CounterUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/parametrized/CarUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/AbstractClass.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/AbstractClass.java new file mode 100644 index 0000000000..7599529014 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/AbstractClass.java @@ -0,0 +1,5 @@ +package com.baeldung.abstractconstructors.defaultconstructor; + +public abstract class AbstractClass { + // compiler creates a default constructor +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/ConcreteClass.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/ConcreteClass.java new file mode 100644 index 0000000000..71c418735d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/defaultconstructor/ConcreteClass.java @@ -0,0 +1,8 @@ +package com.baeldung.abstractconstructors.defaultconstructor; + +public class ConcreteClass extends AbstractClass { + + public ConcreteClass() { + super(); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/AbstractClass.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/AbstractClass.java new file mode 100644 index 0000000000..bdd554b2d9 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/AbstractClass.java @@ -0,0 +1,8 @@ +package com.baeldung.abstractconstructors.noargs; + +public abstract class AbstractClass { + + public AbstractClass() { + System.out.println("Initializing AbstractClass"); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassA.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassA.java new file mode 100644 index 0000000000..8339098127 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassA.java @@ -0,0 +1,4 @@ +package com.baeldung.abstractconstructors.noargs; + +public class ConcreteClassA extends AbstractClass { +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassB.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassB.java new file mode 100644 index 0000000000..cad20d2ec0 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/ConcreteClassB.java @@ -0,0 +1,8 @@ +package com.baeldung.abstractconstructors.noargs; + +public class ConcreteClassB extends AbstractClass { + + public ConcreteClassB() { + System.out.println("Initializing ConcreteClassB"); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/Counter.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/Counter.java new file mode 100644 index 0000000000..a0471ad777 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/Counter.java @@ -0,0 +1,18 @@ +package com.baeldung.abstractconstructors.noargs; + +public abstract class Counter { + + int value; + + private Counter() { + this.value = 0; + System.out.println("Counter No-Arguments constructor"); + } + + public Counter(int value) { + this.value = value; + System.out.println("Parametrized Counter constructor"); + } + + abstract int increment(); +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/SimpleCounter.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/SimpleCounter.java new file mode 100644 index 0000000000..93add905df --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/noargs/SimpleCounter.java @@ -0,0 +1,13 @@ +package com.baeldung.abstractconstructors.noargs; + +public class SimpleCounter extends Counter { + + public SimpleCounter(int value) { + super(value); + } + + @Override + int increment() { + return ++value; + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/Car.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/Car.java new file mode 100644 index 0000000000..8919636b7e --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/Car.java @@ -0,0 +1,28 @@ +package com.baeldung.abstractconstructors.parametrized; + +public abstract class Car { + + private int distance; + + private Car(int distance) { + this.distance = distance; + } + + public Car() { + this(0); + System.out.println("Car default constructor"); + } + + abstract String getInformation(); + + protected void display() { + String info = new StringBuilder(getInformation()) + .append("\nDistance: " + getDistance()) + .toString(); + System.out.println(info); + } + + public int getDistance() { + return distance; + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/ElectricCar.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/ElectricCar.java new file mode 100644 index 0000000000..e17ea6d9c5 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/ElectricCar.java @@ -0,0 +1,17 @@ +package com.baeldung.abstractconstructors.parametrized; + +public class ElectricCar extends Car { + + int chargingTime; + + public ElectricCar(int chargingTime) { + this.chargingTime = chargingTime; + } + + @Override + String getInformation() { + return new StringBuilder("Electric Car") + .append("\nCharging Time: " + chargingTime) + .toString(); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/FuelCar.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/FuelCar.java new file mode 100644 index 0000000000..c18c3a26ef --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/abstractconstructors/parametrized/FuelCar.java @@ -0,0 +1,17 @@ +package com.baeldung.abstractconstructors.parametrized; + +public class FuelCar extends Car { + + String fuel; + + public FuelCar(String fuel) { + this.fuel = fuel; + } + + @Override + String getInformation() { + return new StringBuilder("Fuel Car") + .append("\nFuel type: " + fuel) + .toString(); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/AbstractClassUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/AbstractClassUnitTest.java new file mode 100644 index 0000000000..c72d3b0f3f --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/AbstractClassUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.abstractconstructors.noargs; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class AbstractClassUnitTest { + + @Test + void givenNoArgsAbstractConstructor_whenNewSubclassA_thenCalled() { + assertNotNull(new ConcreteClassA()); + } + + @Test + void givenNoArgsAbstractConstructor_whenNewSubclassB_thenCalled() { + assertNotNull(new ConcreteClassB()); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/CounterUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/CounterUnitTest.java new file mode 100644 index 0000000000..774136c5b6 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/noargs/CounterUnitTest.java @@ -0,0 +1,16 @@ +package com.baeldung.abstractconstructors.noargs; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class CounterUnitTest { + + @Test + void givenNoArgAbstractConstructor_whenSubclassCreation_thenCalled() { + Counter counter = new SimpleCounter(1); + assertNotNull(counter); + assertEquals(1, counter.value); + } +} diff --git a/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/parametrized/CarUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/parametrized/CarUnitTest.java new file mode 100644 index 0000000000..6d17861355 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/abstractconstructors/parametrized/CarUnitTest.java @@ -0,0 +1,20 @@ +package com.baeldung.abstractconstructors.parametrized; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class CarUnitTest { + @Test + void givenParametrizedConstructor_whenConcreteCreation_thenCall() { + ElectricCar electricCar = new ElectricCar(8); + assertNotNull(electricCar); + electricCar.display(); + + System.out.println(); + + FuelCar fuelCar = new FuelCar("Gasoline"); + assertNotNull(fuelCar); + fuelCar.display(); + } +} From f22f99bf1f6784153522a83751b07279104c90e9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 12:48:35 +0100 Subject: [PATCH 200/551] JAVA-8436: Remove AssertJ depenendency from the child modules - part 3 --- algorithms-genetic/pom.xml | 7 ------- algorithms-miscellaneous-1/pom.xml | 7 ------- algorithms-miscellaneous-2/pom.xml | 7 ------- algorithms-miscellaneous-3/pom.xml | 7 ------- algorithms-miscellaneous-4/pom.xml | 7 ------- algorithms-miscellaneous-5/pom.xml | 7 ------- algorithms-miscellaneous-6/pom.xml | 7 ------- algorithms-searching/pom.xml | 13 ------------- algorithms-sorting-2/pom.xml | 7 ------- algorithms-sorting/pom.xml | 7 ------- guava-modules/guava-collections-list/pom.xml | 8 -------- guava-modules/guava-collections-set/pom.xml | 15 --------------- guava-modules/guava-collections/pom.xml | 8 -------- guava-modules/guava-core/pom.xml | 12 ------------ guava-modules/guava-utilities/pom.xml | 12 ------------ jackson-modules/jackson-annotations/pom.xml | 7 ------- jackson-modules/jackson-conversions-2/pom.xml | 10 ---------- jackson-modules/jackson/pom.xml | 7 ------- jackson-simple/pom.xml | 12 ------------ java-collections-conversions-2/pom.xml | 6 ------ java-collections-maps-3/pom.xml | 7 ------- java-numbers-3/pom.xml | 7 ------- java-numbers-4/pom.xml | 7 ------- java-numbers/pom.xml | 7 ------- json-2/pom.xml | 7 ------- json/pom.xml | 7 ------- ksqldb/pom.xml | 7 ------- language-interop/pom.xml | 7 ------- libraries-2/pom.xml | 6 ------ libraries-4/pom.xml | 6 ------ libraries-5/pom.xml | 6 ------ libraries-6/pom.xml | 6 ------ libraries-apache-commons-collections/pom.xml | 7 ------- libraries-apache-commons/pom.xml | 6 ------ libraries-data-2/pom.xml | 6 ------ libraries-data-io/pom.xml | 7 ------- libraries-http/pom.xml | 6 ------ libraries-server/pom.xml | 7 ------- libraries-testing/pom.xml | 12 ------------ libraries/pom.xml | 7 ------- persistence-modules/core-java-persistence/pom.xml | 7 ------- persistence-modules/hibernate-enterprise/pom.xml | 7 ------- persistence-modules/hibernate-jpa/pom.xml | 7 ------- persistence-modules/hibernate-libraries/pom.xml | 7 ------- persistence-modules/hibernate-mapping/pom.xml | 7 ------- persistence-modules/hibernate-queries/pom.xml | 7 ------- persistence-modules/hibernate5/pom.xml | 7 ------- persistence-modules/java-jpa-2/pom.xml | 7 ------- persistence-modules/java-jpa-3/pom.xml | 7 ------- .../jpa-hibernate-cascade-type/pom.xml | 7 ------- persistence-modules/spring-jpa/pom.xml | 6 ------ persistence-modules/spring-mybatis/pom.xml | 8 -------- 52 files changed, 395 deletions(-) diff --git a/algorithms-genetic/pom.xml b/algorithms-genetic/pom.xml index 00c9b88dfe..c53ae0f776 100644 --- a/algorithms-genetic/pom.xml +++ b/algorithms-genetic/pom.xml @@ -35,18 +35,11 @@ jenetics ${io.jenetics.version} - - org.assertj - assertj-core - ${org.assertj.core.version} - test - 3.6.1 3.7.0 - 3.9.0 1.11 diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml index dd3742d4b0..3b55d979fe 100644 --- a/algorithms-miscellaneous-1/pom.xml +++ b/algorithms-miscellaneous-1/pom.xml @@ -35,12 +35,6 @@ ${lombok.version} provided - - org.assertj - assertj-core - ${org.assertj.core.version} - test - com.github.dpaukov combinatoricslib3 @@ -70,7 +64,6 @@ 3.6.1 - 3.9.0 1.11 27.0.1-jre 3.3.0 diff --git a/algorithms-miscellaneous-2/pom.xml b/algorithms-miscellaneous-2/pom.xml index fcefc3ccba..a411cfdb71 100644 --- a/algorithms-miscellaneous-2/pom.xml +++ b/algorithms-miscellaneous-2/pom.xml @@ -45,12 +45,6 @@ tradukisto ${tradukisto.version} - - org.assertj - assertj-core - ${org.assertj.core.version} - test - @@ -78,7 +72,6 @@ 1.0.1 1.0.1 1.0.1 - 3.9.0 1.11 2.7 diff --git a/algorithms-miscellaneous-3/pom.xml b/algorithms-miscellaneous-3/pom.xml index 19eca8eca7..525a2556de 100644 --- a/algorithms-miscellaneous-3/pom.xml +++ b/algorithms-miscellaneous-3/pom.xml @@ -14,12 +14,6 @@ - - org.assertj - assertj-core - ${org.assertj.core.version} - test - org.apache.commons commons-collections4 @@ -69,7 +63,6 @@ - 3.9.0 4.3 28.0-jre 2.6.0 diff --git a/algorithms-miscellaneous-4/pom.xml b/algorithms-miscellaneous-4/pom.xml index 1eae038bc0..8417c121bf 100644 --- a/algorithms-miscellaneous-4/pom.xml +++ b/algorithms-miscellaneous-4/pom.xml @@ -25,16 +25,9 @@ ${lombok.version} provided - - org.assertj - assertj-core - ${org.assertj.core.version} - test - - 3.9.0 27.0.1-jre diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index c68ac96c38..4a0abc5cba 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -34,17 +34,10 @@ guava ${guava.version} - - org.assertj - assertj-core - ${org.assertj.core.version} - test - 1.0.1 - 3.9.0 1.11 3.6.1 28.1-jre diff --git a/algorithms-miscellaneous-6/pom.xml b/algorithms-miscellaneous-6/pom.xml index a9eb75cf1e..1984139069 100644 --- a/algorithms-miscellaneous-6/pom.xml +++ b/algorithms-miscellaneous-6/pom.xml @@ -19,12 +19,6 @@ guava ${guava.version} - - org.assertj - assertj-core - ${org.assertj.core.version} - test - org.projectlombok lombok @@ -40,7 +34,6 @@ 28.1-jre - 3.9.0 3.6.1 diff --git a/algorithms-searching/pom.xml b/algorithms-searching/pom.xml index a67c062403..edb8a0c423 100644 --- a/algorithms-searching/pom.xml +++ b/algorithms-searching/pom.xml @@ -13,15 +13,6 @@ 1.0.0-SNAPSHOT - - - org.assertj - assertj-core - ${org.assertj.core.version} - test - - - algorithms-searching @@ -32,8 +23,4 @@ - - 3.9.0 - - \ No newline at end of file diff --git a/algorithms-sorting-2/pom.xml b/algorithms-sorting-2/pom.xml index c9bec354f3..a8477bf624 100644 --- a/algorithms-sorting-2/pom.xml +++ b/algorithms-sorting-2/pom.xml @@ -29,17 +29,10 @@ ${lombok.version} provided - - org.assertj - assertj-core - ${org.assertj.core.version} - test - 3.6.1 - 3.9.0 1.11 diff --git a/algorithms-sorting/pom.xml b/algorithms-sorting/pom.xml index e916d0aae5..383014d528 100644 --- a/algorithms-sorting/pom.xml +++ b/algorithms-sorting/pom.xml @@ -30,17 +30,10 @@ ${lombok.version} provided - - org.assertj - assertj-core - ${org.assertj.core.version} - test - 3.6.1 - 3.9.0 1.11 diff --git a/guava-modules/guava-collections-list/pom.xml b/guava-modules/guava-collections-list/pom.xml index 30d684d673..1b989e79b0 100644 --- a/guava-modules/guava-collections-list/pom.xml +++ b/guava-modules/guava-collections-list/pom.xml @@ -26,13 +26,6 @@ ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - - org.hamcrest java-hamcrest @@ -55,7 +48,6 @@ 4.1 - 3.6.1 2.0.0.0 diff --git a/guava-modules/guava-collections-set/pom.xml b/guava-modules/guava-collections-set/pom.xml index bd58645adc..49bfc46ee2 100644 --- a/guava-modules/guava-collections-set/pom.xml +++ b/guava-modules/guava-collections-set/pom.xml @@ -13,23 +13,8 @@ 0.0.1-SNAPSHOT - - - - org.assertj - assertj-core - ${assertj.version} - test - - - guava-collections-set - - - 3.6.1 - - \ No newline at end of file diff --git a/guava-modules/guava-collections/pom.xml b/guava-modules/guava-collections/pom.xml index 91e3efcd8c..7929283616 100644 --- a/guava-modules/guava-collections/pom.xml +++ b/guava-modules/guava-collections/pom.xml @@ -31,13 +31,6 @@ ${jool.version} - - org.assertj - assertj-core - ${assertj.version} - test - - org.hamcrest java-hamcrest @@ -61,7 +54,6 @@ 4.1 0.9.12 - 3.6.1 2.0.0.0 diff --git a/guava-modules/guava-core/pom.xml b/guava-modules/guava-core/pom.xml index 2540ac97a7..dd68fef43a 100644 --- a/guava-modules/guava-core/pom.xml +++ b/guava-modules/guava-core/pom.xml @@ -19,13 +19,6 @@ commons-lang3 ${commons-lang3.version} - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -38,9 +31,4 @@ - - - 3.6.1 - - \ No newline at end of file diff --git a/guava-modules/guava-utilities/pom.xml b/guava-modules/guava-utilities/pom.xml index debf014ac7..ab849072a5 100644 --- a/guava-modules/guava-utilities/pom.xml +++ b/guava-modules/guava-utilities/pom.xml @@ -19,13 +19,6 @@ commons-lang3 ${commons-lang3.version} - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -38,9 +31,4 @@ - - - 3.6.1 - - \ No newline at end of file diff --git a/jackson-modules/jackson-annotations/pom.xml b/jackson-modules/jackson-annotations/pom.xml index bdc131c867..56fd6cf2fa 100644 --- a/jackson-modules/jackson-annotations/pom.xml +++ b/jackson-modules/jackson-annotations/pom.xml @@ -25,12 +25,6 @@ ${rest-assured.version} test - - org.assertj - assertj-core - ${assertj.version} - test - @@ -44,7 +38,6 @@ - 3.11.0 3.1.1 diff --git a/jackson-modules/jackson-conversions-2/pom.xml b/jackson-modules/jackson-conversions-2/pom.xml index a498c8b4f8..7e994fb52b 100644 --- a/jackson-modules/jackson-conversions-2/pom.xml +++ b/jackson-modules/jackson-conversions-2/pom.xml @@ -32,12 +32,6 @@ jackson-dataformat-csv ${jackson.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -50,8 +44,4 @@ - - 3.11.0 - - \ No newline at end of file diff --git a/jackson-modules/jackson/pom.xml b/jackson-modules/jackson/pom.xml index a4aecfa3de..9df0f40874 100644 --- a/jackson-modules/jackson/pom.xml +++ b/jackson-modules/jackson/pom.xml @@ -48,12 +48,6 @@ ${rest-assured.version} test - - org.assertj - assertj-core - ${assertj.version} - test - @@ -69,7 +63,6 @@ 3.1.1 - 3.11.0 \ No newline at end of file diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index ae8e380b33..f71cb1ffbf 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -21,13 +21,6 @@ jackson-dataformat-xml ${jackson.version} - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -40,9 +33,4 @@ - - - 3.11.0 - - \ No newline at end of file diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index cd4366e87c..694b416169 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -16,12 +16,6 @@ - - org.assertj - assertj-core - 3.17.2 - test - org.apache.commons commons-lang3 diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml index 0cdf24e31b..6f724ab5ef 100644 --- a/java-collections-maps-3/pom.xml +++ b/java-collections-maps-3/pom.xml @@ -22,12 +22,6 @@ ${spring.version} test - - org.assertj - assertj-core - ${assertj.version} - test - org.apache.commons commons-collections4 @@ -37,7 +31,6 @@ 4.1 - 3.6.1 5.2.5.RELEASE diff --git a/java-numbers-3/pom.xml b/java-numbers-3/pom.xml index e8e080c4c0..68c2ac98de 100644 --- a/java-numbers-3/pom.xml +++ b/java-numbers-3/pom.xml @@ -30,12 +30,6 @@ ${commons-lang3.version} test - - org.assertj - assertj-core - ${assertj.version} - test - @@ -51,7 +45,6 @@ 2.6.0 0.10.2 - 3.6.1 \ No newline at end of file diff --git a/java-numbers-4/pom.xml b/java-numbers-4/pom.xml index dbd6ac456a..9b2e799840 100644 --- a/java-numbers-4/pom.xml +++ b/java-numbers-4/pom.xml @@ -25,12 +25,6 @@ ${commons-lang3.version} test - - org.assertj - assertj-core - ${assertj.version} - test - @@ -45,7 +39,6 @@ 0.10.2 - 3.6.1 \ No newline at end of file diff --git a/java-numbers/pom.xml b/java-numbers/pom.xml index 8bab655f73..c06bc48c5d 100644 --- a/java-numbers/pom.xml +++ b/java-numbers/pom.xml @@ -31,12 +31,6 @@ decimal4j ${decimal4j.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -51,7 +45,6 @@ 1.0.3 - 3.6.1 \ No newline at end of file diff --git a/json-2/pom.xml b/json-2/pom.xml index b4301c41e5..591b7c0883 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -24,12 +24,6 @@ jsoniter ${jsoniter.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.squareup.moshi moshi @@ -147,7 +141,6 @@ 0.9.23 - 3.11.1 1.9.2 diff --git a/json/pom.xml b/json/pom.xml index 260b2d1ad9..2919a3a4ee 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -68,12 +68,6 @@ ${commons-collections4.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -85,7 +79,6 @@ 20171018 2.8.5 1.1.2 - 3.11.1 \ No newline at end of file diff --git a/ksqldb/pom.xml b/ksqldb/pom.xml index 2f92419d6e..ee4906090f 100644 --- a/ksqldb/pom.xml +++ b/ksqldb/pom.xml @@ -39,12 +39,6 @@ ${awaitility.version} test - - org.assertj - assertj-core - ${assertj.version} - test - org.testcontainers testcontainers @@ -61,7 +55,6 @@ 6.2.0 - 3.20.2 4.1.0 1.15.3 diff --git a/language-interop/pom.xml b/language-interop/pom.xml index f2b0a08969..57dd8bdd9a 100644 --- a/language-interop/pom.xml +++ b/language-interop/pom.xml @@ -24,12 +24,6 @@ commons-exec ${commons-exec.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -49,7 +43,6 @@ 2.7.2 1.3 - 3.6.1 \ No newline at end of file diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 0988ed454e..409363111a 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -39,11 +39,6 @@ parallel-collectors ${parallel-collectors.version} - - org.assertj - assertj-core - ${assertj.version} - io.github.classgraph classgraph @@ -128,7 +123,6 @@ 3.0.7 - 3.6.2 4.8.28 6.0.0.Final 3.9.6 diff --git a/libraries-4/pom.xml b/libraries-4/pom.xml index b16d1f216f..7d19f6d504 100644 --- a/libraries-4/pom.xml +++ b/libraries-4/pom.xml @@ -73,11 +73,6 @@ vavr ${vavr.version} - - org.assertj - assertj-core - ${assertj.version} - org.pcollections pcollections @@ -117,7 +112,6 @@ 2.5 3.2.0-m7 0.9.0 - 3.6.2 2.1.2 3.0.0 0.6.5 diff --git a/libraries-5/pom.xml b/libraries-5/pom.xml index a3ca204995..63d1924852 100644 --- a/libraries-5/pom.xml +++ b/libraries-5/pom.xml @@ -17,11 +17,6 @@ spring-web ${spring.version} - - org.assertj - assertj-core - ${assertj.version} - org.jooq jool @@ -119,7 +114,6 @@ 3.5.0 0.9.12 4.3.8.RELEASE - 3.6.2 2.11 2.5.11 0.6.5 diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index cf2c2c551d..accf5f3a9a 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -74,11 +74,6 @@ commons-net ${commons-net.version} - - org.assertj - assertj-core - ${assertj.version} - commons-io commons-io @@ -148,7 +143,6 @@ 0.12.1 1.15 3.6 - 3.6.2 3.5-beta72 3.0 1.8.1 diff --git a/libraries-apache-commons-collections/pom.xml b/libraries-apache-commons-collections/pom.xml index e2805552e3..2cb73babe6 100644 --- a/libraries-apache-commons-collections/pom.xml +++ b/libraries-apache-commons-collections/pom.xml @@ -24,17 +24,10 @@ ${org.hamcrest.java-hamcrest.version} test - - org.assertj - assertj-core - ${assertj.version} - test - 4.1 - 3.6.2 2.0.0.0 diff --git a/libraries-apache-commons/pom.xml b/libraries-apache-commons/pom.xml index 8fa55c1b0e..9bf6c40e19 100644 --- a/libraries-apache-commons/pom.xml +++ b/libraries-apache-commons/pom.xml @@ -13,11 +13,6 @@ - - org.assertj - assertj-core - ${assertj.version} - commons-beanutils commons-beanutils @@ -69,7 +64,6 @@ 1.1 1.9.3 1.2 - 3.6.2 1.6 3.5.2 3.6.1 diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index 75b2cc962d..b69d9808c4 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -96,11 +96,6 @@ derive4j ${derive4j.version} - - org.assertj - assertj-core - ${assertj.version} - org.slf4j slf4j-api @@ -160,7 +155,6 @@ 4.3.8.RELEASE 4.0.0 1.1.0 - 3.6.2 3.0.0 2.8.4 29.0-jre diff --git a/libraries-data-io/pom.xml b/libraries-data-io/pom.xml index 1335ba54d1..713c4342d1 100644 --- a/libraries-data-io/pom.xml +++ b/libraries-data-io/pom.xml @@ -95,12 +95,6 @@ protobuf-java ${google-protobuf.version} - - org.assertj - assertj-core - ${org.assertj.core.version} - test - @@ -110,7 +104,6 @@ 4.1 1.23.0 v4-rev493-1.21.0 - 3.9.0 3.3.5 2.1 2.8.7 diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index a00bb4bd39..0ee5f4b290 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -13,11 +13,6 @@ - - org.assertj - assertj-core - ${assertj.version} - com.squareup.okhttp3 @@ -116,7 +111,6 @@ 2.8.5 4.5.3 - 3.6.2 4.9.1 1.23.0 2.2.0 diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml index 954f666785..66d6295f7c 100644 --- a/libraries-server/pom.xml +++ b/libraries-server/pom.xml @@ -19,12 +19,6 @@ org.eclipse.paho.client.mqttv3 ${eclipse.paho.client.mqttv3.version} - - - org.assertj - assertj-core - ${assertj.version} - org.eclipse.jetty jetty-server @@ -96,7 +90,6 @@ - 3.6.2 4.5.3 9.4.27.v20200227 4.1.20.Final diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index d7b4a88369..d62d094f08 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -118,11 +118,6 @@ ${spring-mock-mvc.version} test - - org.assertj - assertj-core - ${assertj.version} - org.hamcrest @@ -147,12 +142,6 @@ ${h2.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - net.bytebuddy byte-buddy @@ -206,7 +195,6 @@ 0.8.1 4.3.8.RELEASE 4.1.1 - 3.14.0 2.0.0.0 1.4.200 2.7.0 diff --git a/libraries/pom.xml b/libraries/pom.xml index b2e429ff65..b0a0aa22ea 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -45,12 +45,6 @@ javassist ${javaassist.version} - - - org.assertj - assertj-core - ${assertj.version} - org.javers javers-core @@ -272,7 +266,6 @@ 0.7.0 3.2.7 1.2 - 3.6.2 3.1.0 2.92 1.9.26 diff --git a/persistence-modules/core-java-persistence/pom.xml b/persistence-modules/core-java-persistence/pom.xml index 96f8cef310..efef12a525 100644 --- a/persistence-modules/core-java-persistence/pom.xml +++ b/persistence-modules/core-java-persistence/pom.xml @@ -22,12 +22,6 @@ ${postgresql.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -62,7 +56,6 @@ 1.4.200 - 3.10.0 2.4.0 3.2.0 0.9.5.2 diff --git a/persistence-modules/hibernate-enterprise/pom.xml b/persistence-modules/hibernate-enterprise/pom.xml index 1d9ebfc156..18d1a4f3a6 100644 --- a/persistence-modules/hibernate-enterprise/pom.xml +++ b/persistence-modules/hibernate-enterprise/pom.xml @@ -19,12 +19,6 @@ hibernate-core ${hibernate.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -87,7 +81,6 @@ 5.3.7.Final 6.0.6 2.2.3 - 3.8.0 0.9 2.3.4 diff --git a/persistence-modules/hibernate-jpa/pom.xml b/persistence-modules/hibernate-jpa/pom.xml index 85bfdac07f..7779a85e79 100644 --- a/persistence-modules/hibernate-jpa/pom.xml +++ b/persistence-modules/hibernate-jpa/pom.xml @@ -45,12 +45,6 @@ spring-boot-starter-test ${spring-boot.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -92,7 +86,6 @@ 5.3.7.Final 8.0.13 2.2.3 - 3.8.0 2.1.7.RELEASE diff --git a/persistence-modules/hibernate-libraries/pom.xml b/persistence-modules/hibernate-libraries/pom.xml index 7d552b262d..81f084e102 100644 --- a/persistence-modules/hibernate-libraries/pom.xml +++ b/persistence-modules/hibernate-libraries/pom.xml @@ -62,12 +62,6 @@ ${hibernate.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - mysql mysql-connector-java @@ -166,7 +160,6 @@ - 3.15.0 1.6 29.0-jre 2.9.7 diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index 805402951e..9661c3fd4c 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -29,12 +29,6 @@ hibernate-types-52 ${hibernate-types.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -77,7 +71,6 @@ 5.4.12.Final 2.10.4 - 3.8.0 6.0.16.Final 3.0.1-b11 1.0.3 diff --git a/persistence-modules/hibernate-queries/pom.xml b/persistence-modules/hibernate-queries/pom.xml index 83b2ea4d00..20c2da9ea9 100644 --- a/persistence-modules/hibernate-queries/pom.xml +++ b/persistence-modules/hibernate-queries/pom.xml @@ -19,12 +19,6 @@ hibernate-core ${hibernate.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -60,7 +54,6 @@ 6.0.6 2.2.3 - 3.8.0 \ No newline at end of file diff --git a/persistence-modules/hibernate5/pom.xml b/persistence-modules/hibernate5/pom.xml index d46d2c16d4..6bec0d4981 100644 --- a/persistence-modules/hibernate5/pom.xml +++ b/persistence-modules/hibernate5/pom.xml @@ -19,12 +19,6 @@ hibernate-core ${hibernate.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -66,7 +60,6 @@ 5.4.12.Final 6.0.6 2.2.3 - 3.8.0 \ No newline at end of file diff --git a/persistence-modules/java-jpa-2/pom.xml b/persistence-modules/java-jpa-2/pom.xml index 26895f3a87..884142f821 100644 --- a/persistence-modules/java-jpa-2/pom.xml +++ b/persistence-modules/java-jpa-2/pom.xml @@ -58,12 +58,6 @@ querydsl-jpa ${querydsl.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -139,7 +133,6 @@ 5.4.14.Final 2.7.4 2.2 - 3.11.1 3.5.1 3.3.3 3.0.0 diff --git a/persistence-modules/java-jpa-3/pom.xml b/persistence-modules/java-jpa-3/pom.xml index 0eb4b8075d..b67b8bf608 100644 --- a/persistence-modules/java-jpa-3/pom.xml +++ b/persistence-modules/java-jpa-3/pom.xml @@ -62,12 +62,6 @@ ${postgresql.version} runtime - - org.assertj - assertj-core - ${assertj.version} - test - org.testcontainers postgresql @@ -94,7 +88,6 @@ 2.7.4 8.0.21 2.2 - 3.11.1 3.5.1 3.3.3 3.0.0 diff --git a/persistence-modules/jpa-hibernate-cascade-type/pom.xml b/persistence-modules/jpa-hibernate-cascade-type/pom.xml index 467fe11bc3..fd0ae117c7 100644 --- a/persistence-modules/jpa-hibernate-cascade-type/pom.xml +++ b/persistence-modules/jpa-hibernate-cascade-type/pom.xml @@ -17,12 +17,6 @@ hibernate-core ${hibernate.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -48,7 +42,6 @@ 5.4.3.Final - 3.12.2 6.0.17.Final 3.0.0 3.0.1-b11 diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml index 1dca2baa98..c0324e9efd 100644 --- a/persistence-modules/spring-jpa/pom.xml +++ b/persistence-modules/spring-jpa/pom.xml @@ -98,11 +98,6 @@ guava ${guava.version} - - org.assertj - assertj-core - ${assertj.version} - org.apache.commons @@ -132,7 +127,6 @@ 2.2.5 21.0 - 3.8.0 \ No newline at end of file diff --git a/persistence-modules/spring-mybatis/pom.xml b/persistence-modules/spring-mybatis/pom.xml index 1a55e76900..4eda66e1a9 100644 --- a/persistence-modules/spring-mybatis/pom.xml +++ b/persistence-modules/spring-mybatis/pom.xml @@ -64,12 +64,6 @@ ${org.springframework.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -90,8 +84,6 @@ 3.5.2 2.1.0 1.4.197 - - 3.8.0 \ No newline at end of file From 66311a52d33a2f80f3f4457cb828adb43b165e71 Mon Sep 17 00:00:00 2001 From: vunamtien Date: Thu, 18 Nov 2021 19:25:27 +0700 Subject: [PATCH 201/551] BAEL-5193 Compare strings while ignoring whitespace (#11455) * BAEL-5193-compare-strings-ignoring-whitespace * refactor * refactor Co-authored-by: tienvn4 --- .../core-java-string-operations-4/pom.xml | 12 ++++++++ .../CompareIgnoreSpacesUnitTest.java | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/comparestrings/CompareIgnoreSpacesUnitTest.java diff --git a/core-java-modules/core-java-string-operations-4/pom.xml b/core-java-modules/core-java-string-operations-4/pom.xml index ea6bdcd849..ce6119cbbe 100644 --- a/core-java-modules/core-java-string-operations-4/pom.xml +++ b/core-java-modules/core-java-string-operations-4/pom.xml @@ -32,6 +32,16 @@ opencsv ${opencsv.version} + + org.springframework + spring-core + ${spring-core.version} + + + org.apache.commons + commons-lang3 + ${apache-commons-lang3.version} + @@ -53,6 +63,8 @@ 3.6.1 31.0.1-jre 4.1 + 5.3.13 + 3.12.0 diff --git a/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/comparestrings/CompareIgnoreSpacesUnitTest.java b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/comparestrings/CompareIgnoreSpacesUnitTest.java new file mode 100644 index 0000000000..570ceb1598 --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/comparestrings/CompareIgnoreSpacesUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.comparestrings; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class CompareIgnoreSpacesUnitTest { + + private static String normalString = "ABCDEF"; + private static String stringWithSpaces = " AB CD EF "; + + @Test + public void givenTwoStrings_thenCompareWithReplaceAllMethod() { + assertEquals(normalString.replaceAll("\\s+",""), stringWithSpaces.replaceAll("\\s+","")); + } + + @Test + public void givenTwoStrings_thenCompareWithApacheStringUtils() { + assertEquals(StringUtils.deleteWhitespace(normalString), StringUtils.deleteWhitespace(stringWithSpaces)); + } + + @Test + public void givenTwoStrings_thenCompareWithSpringStringUtils() { + assertEquals(org.springframework.util.StringUtils.trimAllWhitespace(normalString), org.springframework.util.StringUtils.trimAllWhitespace(stringWithSpaces)); + } + +} From 32c8413f824e12ff5cfc391bf37cd77362bba346 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 14:03:13 +0100 Subject: [PATCH 202/551] JAVA-8436: Remove AssertJ depenendency from the child modules - part 4 --- core-java-modules/core-java-11-2/pom.xml | 7 ------- core-java-modules/core-java-11/pom.xml | 7 ------- core-java-modules/core-java-12/pom.xml | 7 ------- core-java-modules/core-java-13/pom.xml | 10 ---------- core-java-modules/core-java-14/pom.xml | 10 ---------- core-java-modules/core-java-15/pom.xml | 7 ------- core-java-modules/core-java-16/pom.xml | 7 ------- core-java-modules/core-java-17/pom.xml | 10 ---------- core-java-modules/core-java-8-2/pom.xml | 7 ------- core-java-modules/core-java-8-datetime-2/pom.xml | 8 -------- core-java-modules/core-java-8-datetime/pom.xml | 8 -------- core-java-modules/core-java-8/pom.xml | 9 --------- .../core-java-9-improvements/pom.xml | 8 -------- .../core-java-9-new-features/pom.xml | 8 -------- core-java-modules/core-java-9/pom.xml | 8 -------- core-java-modules/core-java-annotations/pom.xml | 13 ------------- core-java-modules/core-java-arrays-guides/pom.xml | 10 ---------- .../core-java-arrays-operations-advanced/pom.xml | 10 ---------- .../core-java-arrays-operations-basic/pom.xml | 7 ------- .../core-java-arrays-sorting/pom.xml | 8 -------- core-java-modules/core-java-char/pom.xml | 10 ---------- core-java-modules/core-java-collections-2/pom.xml | 7 ------- core-java-modules/core-java-collections-3/pom.xml | 7 ------- core-java-modules/core-java-collections-4/pom.xml | 13 ------------- .../core-java-collections-array-list/pom.xml | 7 ------- .../core-java-collections-list-2/pom.xml | 7 ------- .../core-java-collections-list-3/pom.xml | 7 ------- .../core-java-collections-list/pom.xml | 7 ------- .../core-java-collections-maps-2/pom.xml | 7 ------- .../core-java-collections-maps/pom.xml | 7 ------- core-java-modules/core-java-collections/pom.xml | 10 ---------- .../core-java-concurrency-advanced-2/pom.xml | 10 ---------- .../core-java-concurrency-advanced-3/pom.xml | 7 ------- .../core-java-concurrency-advanced/pom.xml | 9 --------- .../core-java-concurrency-basic/pom.xml | 8 -------- .../core-java-concurrency-collections-2/pom.xml | 8 -------- .../core-java-concurrency-collections/pom.xml | 14 -------------- .../core-java-date-operations-1/pom.xml | 9 +-------- .../core-java-date-operations-2/pom.xml | 7 ------- .../core-java-datetime-conversion/pom.xml | 9 --------- .../core-java-datetime-string/pom.xml | 9 --------- core-java-modules/core-java-exceptions-2/pom.xml | 12 ------------ core-java-modules/core-java-exceptions-3/pom.xml | 9 --------- core-java-modules/core-java-exceptions/pom.xml | 9 --------- core-java-modules/core-java-function/pom.xml | 15 --------------- core-java-modules/core-java-io-2/pom.xml | 8 -------- core-java-modules/core-java-io-3/pom.xml | 11 ----------- core-java-modules/core-java-io-4/pom.xml | 11 ----------- core-java-modules/core-java-io-apis/pom.xml | 11 ----------- core-java-modules/core-java-io/pom.xml | 9 --------- core-java-modules/core-java-jar/pom.xml | 9 --------- core-java-modules/core-java-jndi/pom.xml | 7 ------- core-java-modules/core-java-jvm-2/pom.xml | 7 ------- core-java-modules/core-java-jvm/pom.xml | 8 -------- core-java-modules/core-java-lang-2/pom.xml | 7 ------- core-java-modules/core-java-lang-3/pom.xml | 10 ---------- core-java-modules/core-java-lang-math-2/pom.xml | 7 ------- core-java-modules/core-java-lang-math/pom.xml | 15 --------------- .../core-java-lang-oop-constructors/pom.xml | 13 ------------- .../core-java-lang-oop-inheritance/pom.xml | 13 ------------- .../core-java-lang-oop-methods/pom.xml | 7 ------- .../core-java-lang-oop-modifiers/pom.xml | 10 ---------- .../core-java-lang-oop-patterns/pom.xml | 7 ------- .../core-java-lang-operators-2/pom.xml | 12 ------------ .../core-java-lang-operators/pom.xml | 12 ------------ core-java-modules/core-java-lang-syntax/pom.xml | 12 ------------ core-java-modules/core-java-networking-3/pom.xml | 7 ------- core-java-modules/core-java-nio-2/pom.xml | 13 ------------- core-java-modules/core-java-optional/pom.xml | 7 ------- core-java-modules/core-java-os/pom.xml | 10 ---------- core-java-modules/core-java-reflection/pom.xml | 9 --------- core-java-modules/core-java-regex-2/pom.xml | 13 ------------- core-java-modules/core-java-regex/pom.xml | 10 ---------- core-java-modules/core-java-security-2/pom.xml | 10 ---------- core-java-modules/core-java-security-3/pom.xml | 10 ---------- .../core-java-security-algorithms/pom.xml | 10 ---------- core-java-modules/core-java-security/pom.xml | 15 --------------- core-java-modules/core-java-serialization/pom.xml | 13 ------------- core-java-modules/core-java-streams-2/pom.xml | 7 ------- core-java-modules/core-java-streams-3/pom.xml | 9 --------- core-java-modules/core-java-streams/pom.xml | 10 ---------- .../core-java-string-algorithms-2/pom.xml | 7 ------- .../core-java-string-algorithms-3/pom.xml | 8 -------- .../core-java-string-algorithms/pom.xml | 7 ------- .../core-java-string-conversions-2/pom.xml | 7 ------- .../core-java-string-conversions/pom.xml | 8 -------- .../core-java-string-operations-2/pom.xml | 7 ------- .../core-java-string-operations-3/pom.xml | 7 ------- .../core-java-string-operations-4/pom.xml | 7 ------- .../core-java-string-operations/pom.xml | 7 ------- core-java-modules/core-java-strings/pom.xml | 7 ------- core-java-modules/core-java-sun/pom.xml | 10 ---------- .../core-java-time-measurements/pom.xml | 10 ---------- core-java-modules/core-java-uuid/pom.xml | 7 ------- core-java-modules/core-java/pom.xml | 9 --------- core-java-modules/multimodulemavenproject/pom.xml | 12 ------------ 96 files changed, 1 insertion(+), 871 deletions(-) diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 2b7b042c61..332b24ff2e 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -20,12 +20,6 @@ guava ${guava.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.mock-server mockserver-junit-jupiter @@ -87,7 +81,6 @@ 11 11 29.0-jre - 3.17.2 5.11.1 3.0.0 3.0.0 diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index d3ffb0a8f0..fc61e373ec 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -21,12 +21,6 @@ guava ${guava.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.openjdk.jmh jmh-core @@ -103,7 +97,6 @@ 11 11 27.1-jre - 3.11.1 benchmarks 10.0.0 3.2.4 diff --git a/core-java-modules/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml index 516f28fc3a..9f95b1bc3f 100644 --- a/core-java-modules/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -16,12 +16,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - commons-io commons-io @@ -53,7 +47,6 @@ 12 12 - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-13/pom.xml b/core-java-modules/core-java-13/pom.xml index d28618a21a..9e42838971 100644 --- a/core-java-modules/core-java-13/pom.xml +++ b/core-java-modules/core-java-13/pom.xml @@ -16,15 +16,6 @@ 1.0.0-SNAPSHOT - - - org.assertj - assertj-core - ${assertj.version} - test - - - @@ -52,7 +43,6 @@ 13 13 - 3.6.1 3.0.0-M3 diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index 3967ce3455..35ea0bd2d0 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -14,15 +14,6 @@ 1.0.0-SNAPSHOT - - - org.assertj - assertj-core - ${assertj.version} - test - - - @@ -49,7 +40,6 @@ 14 - 3.6.1 3.8.1 3.0.0-M3 diff --git a/core-java-modules/core-java-15/pom.xml b/core-java-modules/core-java-15/pom.xml index a71987c23a..8cb6c2410d 100644 --- a/core-java-modules/core-java-15/pom.xml +++ b/core-java-modules/core-java-15/pom.xml @@ -21,12 +21,6 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -55,7 +49,6 @@ 15 - 3.17.2 3.8.1 3.0.0-M3 diff --git a/core-java-modules/core-java-16/pom.xml b/core-java-modules/core-java-16/pom.xml index 99952a73d9..4adc3ee6d1 100644 --- a/core-java-modules/core-java-16/pom.xml +++ b/core-java-modules/core-java-16/pom.xml @@ -17,12 +17,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - org.apache.commons commons-lang3 @@ -67,7 +61,6 @@ 16 16 3.0.0-M5 - 3.17.2 \ No newline at end of file diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml index 677454a64b..2fe16cad57 100644 --- a/core-java-modules/core-java-17/pom.xml +++ b/core-java-modules/core-java-17/pom.xml @@ -16,15 +16,6 @@ ../../ - - - org.assertj - assertj-core - ${assertj.version} - test - - - @@ -63,7 +54,6 @@ 17 17 3.0.0-M5 - 3.17.2 \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/pom.xml b/core-java-modules/core-java-8-2/pom.xml index af26289db8..7db1e1ed4e 100644 --- a/core-java-modules/core-java-8-2/pom.xml +++ b/core-java-modules/core-java-8-2/pom.xml @@ -20,17 +20,10 @@ icu4j ${icu.version} - - org.assertj - assertj-core - ${assertj.version} - test - 64.2 - 3.12.2 \ No newline at end of file diff --git a/core-java-modules/core-java-8-datetime-2/pom.xml b/core-java-modules/core-java-8-datetime-2/pom.xml index e662ba400c..9e54b0ee12 100644 --- a/core-java-modules/core-java-8-datetime-2/pom.xml +++ b/core-java-modules/core-java-8-datetime-2/pom.xml @@ -25,12 +25,6 @@ joda-time ${joda-time.version} - - org.assertj - assertj-core - ${assertj.version} - test - log4j log4j @@ -63,8 +57,6 @@ 1.8 1.8 2.10 - - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-8-datetime/pom.xml b/core-java-modules/core-java-8-datetime/pom.xml index f58557df7f..01ec6c0b76 100644 --- a/core-java-modules/core-java-8-datetime/pom.xml +++ b/core-java-modules/core-java-8-datetime/pom.xml @@ -25,12 +25,6 @@ joda-time ${joda-time.version} - - org.assertj - assertj-core - ${assertj.version} - test - log4j log4j @@ -64,8 +58,6 @@ 1.8 1.8 2.10 - - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml index 987ba2e568..85e289280b 100644 --- a/core-java-modules/core-java-8/pom.xml +++ b/core-java-modules/core-java-8/pom.xml @@ -31,13 +31,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -53,8 +46,6 @@ 4.1 - - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-9-improvements/pom.xml b/core-java-modules/core-java-9-improvements/pom.xml index 6abdd7dab8..e6c596937b 100644 --- a/core-java-modules/core-java-9-improvements/pom.xml +++ b/core-java-modules/core-java-9-improvements/pom.xml @@ -21,12 +21,6 @@ ${awaitility.version} test - - org.assertj - assertj-core - ${assertj.version} - test - com.google.guava guava @@ -68,8 +62,6 @@ - - 3.10.0 1.7.0 1.9 1.9 diff --git a/core-java-modules/core-java-9-new-features/pom.xml b/core-java-modules/core-java-9-new-features/pom.xml index 7dca8d5f88..ce90a0f04a 100644 --- a/core-java-modules/core-java-9-new-features/pom.xml +++ b/core-java-modules/core-java-9-new-features/pom.xml @@ -20,12 +20,6 @@ rxjava ${rxjava.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.junit.platform junit-platform-runner @@ -156,8 +150,6 @@ 3.0.0 - - 3.10.0 4.0.2 1.9 1.9 diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index d4d58085c8..03a097e7a9 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -21,12 +21,6 @@ ${awaitility.version} test - - org.assertj - assertj-core - ${assertj.version} - test - com.google.guava guava @@ -78,8 +72,6 @@ - - 3.10.0 1.7.0 1.9 1.9 diff --git a/core-java-modules/core-java-annotations/pom.xml b/core-java-modules/core-java-annotations/pom.xml index 7e87678159..a1f84ab563 100644 --- a/core-java-modules/core-java-annotations/pom.xml +++ b/core-java-modules/core-java-annotations/pom.xml @@ -14,15 +14,6 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - core-java-annotations @@ -32,9 +23,5 @@ - - - 3.10.0 - \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-guides/pom.xml b/core-java-modules/core-java-arrays-guides/pom.xml index 0c8b680c1b..d22f6b4d7d 100644 --- a/core-java-modules/core-java-arrays-guides/pom.xml +++ b/core-java-modules/core-java-arrays-guides/pom.xml @@ -24,16 +24,6 @@ jmh-generator-annprocess ${jmh-generator.version} - - org.assertj - assertj-core - ${assertj.version} - test - - - 3.19.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml index 50830eba2a..cbcd6ae440 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/pom.xml +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -19,12 +19,6 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - org.openjdk.jmh jmh-core @@ -64,8 +58,4 @@ - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-basic/pom.xml b/core-java-modules/core-java-arrays-operations-basic/pom.xml index 382cee102d..6517b2efb9 100644 --- a/core-java-modules/core-java-arrays-operations-basic/pom.xml +++ b/core-java-modules/core-java-arrays-operations-basic/pom.xml @@ -30,12 +30,6 @@ jmh-generator-annprocess ${jmh-generator.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -67,7 +61,6 @@ 3.2.0 - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-sorting/pom.xml b/core-java-modules/core-java-arrays-sorting/pom.xml index e9946d46ed..97ff95e92b 100644 --- a/core-java-modules/core-java-arrays-sorting/pom.xml +++ b/core-java-modules/core-java-arrays-sorting/pom.xml @@ -36,13 +36,6 @@ jmh-generator-annprocess ${jmh-generator.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -75,7 +68,6 @@ 3.2.0 28.2-jre - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-char/pom.xml b/core-java-modules/core-java-char/pom.xml index 009197a1d0..7dc0923fb5 100644 --- a/core-java-modules/core-java-char/pom.xml +++ b/core-java-modules/core-java-char/pom.xml @@ -15,12 +15,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - org.openjdk.jmh jmh-core @@ -33,8 +27,4 @@ - - 3.11.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-collections-2/pom.xml b/core-java-modules/core-java-collections-2/pom.xml index 0f1f1ee2fe..23100b1d87 100644 --- a/core-java-modules/core-java-collections-2/pom.xml +++ b/core-java-modules/core-java-collections-2/pom.xml @@ -34,12 +34,6 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.junit.platform junit-platform-runner @@ -51,7 +45,6 @@ 7.1.0 4.1 - 3.11.1 1.3 diff --git a/core-java-modules/core-java-collections-3/pom.xml b/core-java-modules/core-java-collections-3/pom.xml index 4ca4bda1ee..6ef8e3c81a 100644 --- a/core-java-modules/core-java-collections-3/pom.xml +++ b/core-java-modules/core-java-collections-3/pom.xml @@ -25,12 +25,6 @@ jmh-core ${jmh-core.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.apache.commons commons-lang3 @@ -39,7 +33,6 @@ - 3.11.1 0.10 diff --git a/core-java-modules/core-java-collections-4/pom.xml b/core-java-modules/core-java-collections-4/pom.xml index d86b04644c..2193b5118a 100644 --- a/core-java-modules/core-java-collections-4/pom.xml +++ b/core-java-modules/core-java-collections-4/pom.xml @@ -14,17 +14,4 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - 3.19.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-collections-array-list/pom.xml b/core-java-modules/core-java-collections-array-list/pom.xml index c14e59bac0..ca9c173947 100644 --- a/core-java-modules/core-java-collections-array-list/pom.xml +++ b/core-java-modules/core-java-collections-array-list/pom.xml @@ -20,17 +20,10 @@ commons-collections4 ${commons-collections4.version} - - org.assertj - assertj-core - ${assertj.version} - test - 4.1 - 3.11.1 \ No newline at end of file diff --git a/core-java-modules/core-java-collections-list-2/pom.xml b/core-java-modules/core-java-collections-list-2/pom.xml index 51e66fc0c2..7876b19cf9 100644 --- a/core-java-modules/core-java-collections-list-2/pom.xml +++ b/core-java-modules/core-java-collections-list-2/pom.xml @@ -20,12 +20,6 @@ commons-collections4 ${commons-collections4.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.projectlombok lombok @@ -36,7 +30,6 @@ 4.1 - 3.11.1 \ No newline at end of file diff --git a/core-java-modules/core-java-collections-list-3/pom.xml b/core-java-modules/core-java-collections-list-3/pom.xml index efe79509c1..9238939df7 100644 --- a/core-java-modules/core-java-collections-list-3/pom.xml +++ b/core-java-modules/core-java-collections-list-3/pom.xml @@ -26,12 +26,6 @@ ${guava.version} compile - - org.assertj - assertj-core - ${assertj.version} - test - net.sf.trove4j trove4j @@ -61,7 +55,6 @@ 4.1 - 3.11.1 3.0.2 8.1.0 1.2.0 diff --git a/core-java-modules/core-java-collections-list/pom.xml b/core-java-modules/core-java-collections-list/pom.xml index ae1e1561c6..b60906d1ba 100644 --- a/core-java-modules/core-java-collections-list/pom.xml +++ b/core-java-modules/core-java-collections-list/pom.xml @@ -25,17 +25,10 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - 4.1 - 3.11.1 \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-2/pom.xml b/core-java-modules/core-java-collections-maps-2/pom.xml index 772cf30416..060796fafa 100644 --- a/core-java-modules/core-java-collections-maps-2/pom.xml +++ b/core-java-modules/core-java-collections-maps-2/pom.xml @@ -51,12 +51,6 @@ ${avaitility.version} test - - org.assertj - assertj-core - ${assertj.version} - test - @@ -66,7 +60,6 @@ 8.2.0 0.7.2 8.1.0 - 3.11.1 \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index 245c4b04bb..66aca9c1b2 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -20,17 +20,10 @@ commons-collections4 ${commons-collections4.version} - - org.assertj - assertj-core - ${assertj.version} - test - 4.1 - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-collections/pom.xml b/core-java-modules/core-java-collections/pom.xml index 8fbc6e8de7..8df0d7cdd3 100644 --- a/core-java-modules/core-java-collections/pom.xml +++ b/core-java-modules/core-java-collections/pom.xml @@ -15,12 +15,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - org.openjdk.jmh jmh-core @@ -33,8 +27,4 @@ - - 3.11.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-advanced-2/pom.xml b/core-java-modules/core-java-concurrency-advanced-2/pom.xml index 93c23ccae7..1f19dc8cca 100644 --- a/core-java-modules/core-java-concurrency-advanced-2/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced-2/pom.xml @@ -30,12 +30,6 @@ jmh-generator-annprocess ${jmh-generator.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -48,8 +42,4 @@ - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-advanced-3/pom.xml b/core-java-modules/core-java-concurrency-advanced-3/pom.xml index 915aa8d912..591e46f505 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced-3/pom.xml @@ -15,12 +15,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - com.jcabi jcabi-aspects @@ -94,7 +88,6 @@ - 3.14.0 1.8 1.8 0.22.6 diff --git a/core-java-modules/core-java-concurrency-advanced/pom.xml b/core-java-modules/core-java-concurrency-advanced/pom.xml index 3c21b49ae5..a026bdb2cd 100644 --- a/core-java-modules/core-java-concurrency-advanced/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced/pom.xml @@ -35,12 +35,6 @@ commons-math3 ${commons-math3.version} - - org.assertj - assertj-core - ${assertj.version} - test - com.jayway.awaitility awaitility @@ -60,13 +54,10 @@ - 21.0 3.6.1 4.1 4.01 - - 3.6.1 1.7.0 diff --git a/core-java-modules/core-java-concurrency-basic/pom.xml b/core-java-modules/core-java-concurrency-basic/pom.xml index 7212a2dcb1..1e3157291a 100644 --- a/core-java-modules/core-java-concurrency-basic/pom.xml +++ b/core-java-modules/core-java-concurrency-basic/pom.xml @@ -20,12 +20,6 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - com.jayway.awaitility awaitility @@ -45,8 +39,6 @@ - - 3.6.1 1.7.0 diff --git a/core-java-modules/core-java-concurrency-collections-2/pom.xml b/core-java-modules/core-java-concurrency-collections-2/pom.xml index 8de0e1bef7..02c046b2ea 100644 --- a/core-java-modules/core-java-concurrency-collections-2/pom.xml +++ b/core-java-modules/core-java-concurrency-collections-2/pom.xml @@ -29,18 +29,10 @@ jmh-generator-annprocess ${jmh-generator.version} - - org.assertj - assertj-core - ${assertj.version} - test - 28.2-jre - - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-collections/pom.xml b/core-java-modules/core-java-concurrency-collections/pom.xml index f22da1c848..8b8d2fe03b 100644 --- a/core-java-modules/core-java-concurrency-collections/pom.xml +++ b/core-java-modules/core-java-concurrency-collections/pom.xml @@ -14,15 +14,6 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj.version} - test - - - core-java-concurrency-collections @@ -33,9 +24,4 @@ - - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-date-operations-1/pom.xml b/core-java-modules/core-java-date-operations-1/pom.xml index 8a13163ba4..ea9f94fa56 100644 --- a/core-java-modules/core-java-date-operations-1/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -25,12 +25,7 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - + com.darwinsys hirondelle-date4j @@ -62,8 +57,6 @@ 2.10 - - 3.6.1 RELEASE 1.9 1.9 diff --git a/core-java-modules/core-java-date-operations-2/pom.xml b/core-java-modules/core-java-date-operations-2/pom.xml index 1d283851ca..f60c7b7fc0 100644 --- a/core-java-modules/core-java-date-operations-2/pom.xml +++ b/core-java-modules/core-java-date-operations-2/pom.xml @@ -30,18 +30,11 @@ hirondelle-date4j ${hirondelle-date4j.version} - - org.assertj - assertj-core - ${assertj.version} - test - 2.10 1.5.1 - 3.14.0 \ No newline at end of file diff --git a/core-java-modules/core-java-datetime-conversion/pom.xml b/core-java-modules/core-java-datetime-conversion/pom.xml index 8f082e2793..6e9aeaf5af 100644 --- a/core-java-modules/core-java-datetime-conversion/pom.xml +++ b/core-java-modules/core-java-datetime-conversion/pom.xml @@ -31,13 +31,6 @@ log4j ${log4j.version} - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -63,8 +56,6 @@ 2.10 - - 3.6.1 1.9 1.9 diff --git a/core-java-modules/core-java-datetime-string/pom.xml b/core-java-modules/core-java-datetime-string/pom.xml index a65659be71..2b3c2edb02 100644 --- a/core-java-modules/core-java-datetime-string/pom.xml +++ b/core-java-modules/core-java-datetime-string/pom.xml @@ -31,13 +31,6 @@ log4j ${log4j.version} - - - org.assertj - assertj-core - ${assertj.version} - test - joda-time joda-time @@ -76,8 +69,6 @@ 1.6 2.10.10 RELEASE - - 3.6.1 1.9 1.9 diff --git a/core-java-modules/core-java-exceptions-2/pom.xml b/core-java-modules/core-java-exceptions-2/pom.xml index d952683a64..9103672cd4 100644 --- a/core-java-modules/core-java-exceptions-2/pom.xml +++ b/core-java-modules/core-java-exceptions-2/pom.xml @@ -15,13 +15,6 @@ - - - org.assertj - assertj-core - ${assertj-core.version} - test - org.apache.commons commons-lang3 @@ -29,9 +22,4 @@ - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions-3/pom.xml b/core-java-modules/core-java-exceptions-3/pom.xml index ffc21799ce..18dc52932e 100644 --- a/core-java-modules/core-java-exceptions-3/pom.xml +++ b/core-java-modules/core-java-exceptions-3/pom.xml @@ -22,18 +22,9 @@ ${h2.version} test - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - 3.10.0 1.4.191 diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml index d5581279b5..f1f60120a5 100644 --- a/core-java-modules/core-java-exceptions/pom.xml +++ b/core-java-modules/core-java-exceptions/pom.xml @@ -32,19 +32,10 @@ commons-lang3 ${commons-lang3.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - 1.5.0-b01 - - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-function/pom.xml b/core-java-modules/core-java-function/pom.xml index cc44ba5a7c..a3add5a686 100644 --- a/core-java-modules/core-java-function/pom.xml +++ b/core-java-modules/core-java-function/pom.xml @@ -14,16 +14,6 @@ 0.0.1-SNAPSHOT - - - - org.assertj - assertj-core - ${assertj.version} - test - - - core-java-function @@ -34,9 +24,4 @@ - - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-io-2/pom.xml b/core-java-modules/core-java-io-2/pom.xml index 924248f4f9..800756767c 100644 --- a/core-java-modules/core-java-io-2/pom.xml +++ b/core-java-modules/core-java-io-2/pom.xml @@ -38,13 +38,6 @@ log4j-over-slf4j ${org.slf4j.version} - - - org.assertj - assertj-core - ${assertj.version} - test - com.github.tomakehurst @@ -76,7 +69,6 @@ - 3.6.1 3.0.0-M1 2.26.3 diff --git a/core-java-modules/core-java-io-3/pom.xml b/core-java-modules/core-java-io-3/pom.xml index 017b56f03f..7af90dbab9 100644 --- a/core-java-modules/core-java-io-3/pom.xml +++ b/core-java-modules/core-java-io-3/pom.xml @@ -38,17 +38,6 @@ log4j-over-slf4j ${org.slf4j.version} - - - org.assertj - assertj-core - ${assertj.version} - test - - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-io-4/pom.xml b/core-java-modules/core-java-io-4/pom.xml index 0501bb4a66..9fc00ff586 100644 --- a/core-java-modules/core-java-io-4/pom.xml +++ b/core-java-modules/core-java-io-4/pom.xml @@ -32,17 +32,6 @@ log4j-over-slf4j ${org.slf4j.version} - - - org.assertj - assertj-core - ${assertj.version} - test - - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-io-apis/pom.xml b/core-java-modules/core-java-io-apis/pom.xml index f2a574ed89..fab2bff959 100644 --- a/core-java-modules/core-java-io-apis/pom.xml +++ b/core-java-modules/core-java-io-apis/pom.xml @@ -32,13 +32,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -51,8 +44,4 @@ - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-io/pom.xml b/core-java-modules/core-java-io/pom.xml index a036818226..7de29ac23c 100644 --- a/core-java-modules/core-java-io/pom.xml +++ b/core-java-modules/core-java-io/pom.xml @@ -15,13 +15,6 @@ - - - org.assertj - assertj-core - ${assertj.version} - test - org.hsqldb hsqldb @@ -132,8 +125,6 @@ - - 3.6.1 3.0.0-M1 2.4.0 diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index 3c5a1b35bf..da107c745f 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -49,13 +49,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj-core.version} - test - org.javamoney moneta @@ -376,8 +369,6 @@ 0.4 1.8.7 - - 3.10.0 1.1 3.0.0-M1 diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index f971623bc2..68b7f9361f 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -47,12 +47,6 @@ ${apacheds.version} test - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -71,7 +65,6 @@ 5.0.9.RELEASE 1.4.199 - 3.21.0 2.0.0.AM26 1.8 1.8 diff --git a/core-java-modules/core-java-jvm-2/pom.xml b/core-java-modules/core-java-jvm-2/pom.xml index b34aac5a78..60a2795116 100644 --- a/core-java-modules/core-java-jvm-2/pom.xml +++ b/core-java-modules/core-java-jvm-2/pom.xml @@ -15,12 +15,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - org.openjdk.jol jol-core @@ -39,7 +33,6 @@ - 3.6.1 0.10 0.10.2 31.0.1-jre diff --git a/core-java-modules/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml index 38cb1a7825..c47765e43d 100644 --- a/core-java-modules/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -20,12 +20,6 @@ commons-lang3 ${commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.javassist javassist @@ -66,8 +60,6 @@ - 3.6.1 - 3.27.0-GA 1.8.0 0.10 diff --git a/core-java-modules/core-java-lang-2/pom.xml b/core-java-modules/core-java-lang-2/pom.xml index d1a8d68075..f155f2abaf 100644 --- a/core-java-modules/core-java-lang-2/pom.xml +++ b/core-java-modules/core-java-lang-2/pom.xml @@ -45,12 +45,6 @@ jmh-core ${jmh-core.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -64,7 +58,6 @@ - 3.12.2 1.9.4 29.0-jre diff --git a/core-java-modules/core-java-lang-3/pom.xml b/core-java-modules/core-java-lang-3/pom.xml index 0eda5dd16b..92c724826c 100644 --- a/core-java-modules/core-java-lang-3/pom.xml +++ b/core-java-modules/core-java-lang-3/pom.xml @@ -15,12 +15,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - com.google.guava guava @@ -45,8 +39,4 @@ - - 3.12.2 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-math-2/pom.xml b/core-java-modules/core-java-lang-math-2/pom.xml index 4411d313db..4057429896 100644 --- a/core-java-modules/core-java-lang-math-2/pom.xml +++ b/core-java-modules/core-java-lang-math-2/pom.xml @@ -44,12 +44,6 @@ guava ${guava.version} - - org.assertj - assertj-core - ${org.assertj.core.version} - test - com.github.dpaukov combinatoricslib3 @@ -65,7 +59,6 @@ 3.6.1 - 3.9.0 27.0.1-jre 3.3.0 0.38 diff --git a/core-java-modules/core-java-lang-math/pom.xml b/core-java-modules/core-java-lang-math/pom.xml index 2cc9b90fa4..37550b67d8 100644 --- a/core-java-modules/core-java-lang-math/pom.xml +++ b/core-java-modules/core-java-lang-math/pom.xml @@ -14,16 +14,6 @@ 0.0.1-SNAPSHOT - - - - org.assertj - assertj-core - ${assertj.version} - test - - - core-java-lang-math @@ -34,9 +24,4 @@ - - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-constructors/pom.xml b/core-java-modules/core-java-lang-oop-constructors/pom.xml index 5635059fa9..061b3c08de 100644 --- a/core-java-modules/core-java-lang-oop-constructors/pom.xml +++ b/core-java-modules/core-java-lang-oop-constructors/pom.xml @@ -13,17 +13,4 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-inheritance/pom.xml b/core-java-modules/core-java-lang-oop-inheritance/pom.xml index e0272fb94e..4fc7e14d84 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/pom.xml +++ b/core-java-modules/core-java-lang-oop-inheritance/pom.xml @@ -13,17 +13,4 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml index 938b457872..e57b51b7bd 100644 --- a/core-java-modules/core-java-lang-oop-methods/pom.xml +++ b/core-java-modules/core-java-lang-oop-methods/pom.xml @@ -24,12 +24,6 @@ commons-lang ${commons-lang.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - nl.jqno.equalsverifier equalsverifier @@ -40,7 +34,6 @@ 1.18.12 - 3.10.0 3.0.3 diff --git a/core-java-modules/core-java-lang-oop-modifiers/pom.xml b/core-java-modules/core-java-lang-oop-modifiers/pom.xml index 70c70608eb..109a87c41e 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/pom.xml +++ b/core-java-modules/core-java-lang-oop-modifiers/pom.xml @@ -14,12 +14,6 @@ - - org.assertj - assertj-core - ${assertj-core.version} - test - com.h2database h2 @@ -28,8 +22,4 @@ - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-patterns/pom.xml b/core-java-modules/core-java-lang-oop-patterns/pom.xml index 8b8b4a7b46..4b89584def 100644 --- a/core-java-modules/core-java-lang-oop-patterns/pom.xml +++ b/core-java-modules/core-java-lang-oop-patterns/pom.xml @@ -29,17 +29,10 @@ gson ${gson.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - 2.8.2 - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-lang-operators-2/pom.xml b/core-java-modules/core-java-lang-operators-2/pom.xml index 1779b7384c..724dad95ee 100644 --- a/core-java-modules/core-java-lang-operators-2/pom.xml +++ b/core-java-modules/core-java-lang-operators-2/pom.xml @@ -21,13 +21,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -40,9 +33,4 @@ - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-operators/pom.xml b/core-java-modules/core-java-lang-operators/pom.xml index 63f42917b8..c61fb81354 100644 --- a/core-java-modules/core-java-lang-operators/pom.xml +++ b/core-java-modules/core-java-lang-operators/pom.xml @@ -21,13 +21,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -40,9 +33,4 @@ - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-syntax/pom.xml b/core-java-modules/core-java-lang-syntax/pom.xml index da7d56de7b..7cdbc40fbc 100644 --- a/core-java-modules/core-java-lang-syntax/pom.xml +++ b/core-java-modules/core-java-lang-syntax/pom.xml @@ -26,13 +26,6 @@ log4j-over-slf4j ${org.slf4j.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -45,9 +38,4 @@ - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-networking-3/pom.xml b/core-java-modules/core-java-networking-3/pom.xml index 2fd97ef831..ee822e57cb 100644 --- a/core-java-modules/core-java-networking-3/pom.xml +++ b/core-java-modules/core-java-networking-3/pom.xml @@ -29,12 +29,6 @@ tomcat-embed-core ${tomcat.embeded.version} - - org.assertj - assertj-core - ${assertj.version} - test - com.sun.mail javax.mail @@ -76,7 +70,6 @@ 5.2.8.RELEASE 9.4.31.v20200723 10.0.0-M7 - 3.11.1 5.3.3 1.32 0.17 diff --git a/core-java-modules/core-java-nio-2/pom.xml b/core-java-modules/core-java-nio-2/pom.xml index 9d5e267b46..eb56c2bf68 100644 --- a/core-java-modules/core-java-nio-2/pom.xml +++ b/core-java-modules/core-java-nio-2/pom.xml @@ -14,17 +14,4 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - 3.6.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-optional/pom.xml b/core-java-modules/core-java-optional/pom.xml index dd5217df74..d04763598d 100644 --- a/core-java-modules/core-java-optional/pom.xml +++ b/core-java-modules/core-java-optional/pom.xml @@ -56,18 +56,11 @@ ${rest-assured.version} test - - org.assertj - assertj-core - ${assertj.version} - test - 5.4.0.Final 27.1-jre - 3.10.0 3.1.1 diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index c0eac46db8..970c8a562a 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -35,13 +35,6 @@ log4j ${log4j.version} - - - org.assertj - assertj-core - ${assertj.version} - test - org.unix4j unix4j-command @@ -76,11 +69,8 @@ - 4.1 4.01 - - 3.6.1 1.8.9 1.9 1.9 diff --git a/core-java-modules/core-java-reflection/pom.xml b/core-java-modules/core-java-reflection/pom.xml index 32777e228f..1706bf3c45 100644 --- a/core-java-modules/core-java-reflection/pom.xml +++ b/core-java-modules/core-java-reflection/pom.xml @@ -14,14 +14,6 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj-core.version} - - - core-java-reflection @@ -45,7 +37,6 @@ - 3.10.0 1.8 1.8 diff --git a/core-java-modules/core-java-regex-2/pom.xml b/core-java-modules/core-java-regex-2/pom.xml index a47c0ff357..ae9385e63c 100644 --- a/core-java-modules/core-java-regex-2/pom.xml +++ b/core-java-modules/core-java-regex-2/pom.xml @@ -14,17 +14,4 @@ 0.0.1-SNAPSHOT - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - 3.15.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-regex/pom.xml b/core-java-modules/core-java-regex/pom.xml index 3fb63fb42a..93f3ae3cdb 100644 --- a/core-java-modules/core-java-regex/pom.xml +++ b/core-java-modules/core-java-regex/pom.xml @@ -25,12 +25,6 @@ jmh-generator-annprocess ${jmh-core.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -43,8 +37,4 @@ - - 3.15.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-security-2/pom.xml b/core-java-modules/core-java-security-2/pom.xml index 8de12c0c46..7a354ee9e2 100644 --- a/core-java-modules/core-java-security-2/pom.xml +++ b/core-java-modules/core-java-security-2/pom.xml @@ -25,13 +25,6 @@ bcprov-jdk15on ${bouncycastle.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - javax.xml.bind @@ -41,11 +34,8 @@ - 1.60 1.11 - - 3.18.0 2.3.1 diff --git a/core-java-modules/core-java-security-3/pom.xml b/core-java-modules/core-java-security-3/pom.xml index a0e73a1e29..3cd546e697 100644 --- a/core-java-modules/core-java-security-3/pom.xml +++ b/core-java-modules/core-java-security-3/pom.xml @@ -25,13 +25,6 @@ bcprov-jdk15on ${bouncycastle.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - javax.xml.bind @@ -41,11 +34,8 @@ - 1.60 1.11 - - 3.18.0 2.3.1 diff --git a/core-java-modules/core-java-security-algorithms/pom.xml b/core-java-modules/core-java-security-algorithms/pom.xml index db1bf09ead..967ddc103e 100644 --- a/core-java-modules/core-java-security-algorithms/pom.xml +++ b/core-java-modules/core-java-security-algorithms/pom.xml @@ -25,13 +25,6 @@ bcprov-jdk15on ${bouncycastle.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - javax.xml.bind @@ -41,11 +34,8 @@ - 1.60 1.11 - - 3.18.0 2.3.1 diff --git a/core-java-modules/core-java-security/pom.xml b/core-java-modules/core-java-security/pom.xml index daba990776..b36de5ac4c 100644 --- a/core-java-modules/core-java-security/pom.xml +++ b/core-java-modules/core-java-security/pom.xml @@ -14,19 +14,4 @@ 0.0.1-SNAPSHOT - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - - 3.10.0 - - \ No newline at end of file diff --git a/core-java-modules/core-java-serialization/pom.xml b/core-java-modules/core-java-serialization/pom.xml index 754dcd434b..0ce5785fd9 100644 --- a/core-java-modules/core-java-serialization/pom.xml +++ b/core-java-modules/core-java-serialization/pom.xml @@ -43,13 +43,6 @@ log4j-over-slf4j ${org.slf4j.version} - - - org.assertj - assertj-core - ${assertj-core.version} - test - org.springframework spring-core @@ -177,16 +170,10 @@ - 0.4 1.8.7 - - 3.10.0 - 1.1 3.0.0-M1 - - 4.3.20.RELEASE diff --git a/core-java-modules/core-java-streams-2/pom.xml b/core-java-modules/core-java-streams-2/pom.xml index 08b82bcc11..c8fa83c55a 100644 --- a/core-java-modules/core-java-streams-2/pom.xml +++ b/core-java-modules/core-java-streams-2/pom.xml @@ -30,18 +30,11 @@ log4j ${log4j.version} - - org.assertj - assertj-core - ${assertj.version} - test - 1.9 1.9 - 3.11.1 \ No newline at end of file diff --git a/core-java-modules/core-java-streams-3/pom.xml b/core-java-modules/core-java-streams-3/pom.xml index 6ace96fc4d..c2dfdc392b 100644 --- a/core-java-modules/core-java-streams-3/pom.xml +++ b/core-java-modules/core-java-streams-3/pom.xml @@ -37,13 +37,6 @@ ${jmh-generator.version} test - - - org.assertj - assertj-core - ${assertj.version} - test - @@ -75,8 +68,6 @@ 1.18.20 - - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-streams/pom.xml b/core-java-modules/core-java-streams/pom.xml index 4862672c8a..a6bb827e77 100644 --- a/core-java-modules/core-java-streams/pom.xml +++ b/core-java-modules/core-java-streams/pom.xml @@ -43,13 +43,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj.version} - test - com.codepoetics protonpack @@ -105,14 +98,11 @@ - 0.9.0 1.15 0.6.5 2.10 1.3 - - 3.11.1 1.8.9 3.1 1.8 diff --git a/core-java-modules/core-java-string-algorithms-2/pom.xml b/core-java-modules/core-java-string-algorithms-2/pom.xml index 4b0d55508f..9fbe10865d 100644 --- a/core-java-modules/core-java-string-algorithms-2/pom.xml +++ b/core-java-modules/core-java-string-algorithms-2/pom.xml @@ -35,12 +35,6 @@ jmh-generator-annprocess ${jmh-generator.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.bitbucket.cowwoc diff-match-patch @@ -60,7 +54,6 @@ - 3.6.1 1.2 diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 88a3029cf1..6700e9ba95 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -14,13 +14,6 @@ - - - org.assertj - assertj-core - ${assertj.version} - test - com.google.guava guava @@ -56,7 +49,6 @@ - 3.6.1 28.1-jre 1.7 diff --git a/core-java-modules/core-java-string-algorithms/pom.xml b/core-java-modules/core-java-string-algorithms/pom.xml index 9fea569b29..07018c7694 100644 --- a/core-java-modules/core-java-string-algorithms/pom.xml +++ b/core-java-modules/core-java-string-algorithms/pom.xml @@ -45,12 +45,6 @@ emoji-java ${emoji-java.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -66,7 +60,6 @@ 27.0.1-jre 0.4.0 - 3.6.1 4.0.0 diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index 3e03f4c016..f97443d9ca 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -41,12 +41,6 @@ commons-text ${commons-text.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -61,7 +55,6 @@ 64.2 - 3.12.2 1.9 30.1.1-jre diff --git a/core-java-modules/core-java-string-conversions/pom.xml b/core-java-modules/core-java-string-conversions/pom.xml index 1047e3e7c3..148f04101f 100644 --- a/core-java-modules/core-java-string-conversions/pom.xml +++ b/core-java-modules/core-java-string-conversions/pom.xml @@ -35,13 +35,6 @@ guava ${guava.version} - - - org.assertj - assertj-core - ${assertj.version} - test - org.hamcrest hamcrest @@ -62,7 +55,6 @@ 61.1 - 3.6.1 \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-2/pom.xml b/core-java-modules/core-java-string-operations-2/pom.xml index db8f78da70..0d31486759 100644 --- a/core-java-modules/core-java-string-operations-2/pom.xml +++ b/core-java-modules/core-java-string-operations-2/pom.xml @@ -66,12 +66,6 @@ commons-codec ${commons-codec.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -108,7 +102,6 @@ - 3.6.1 2.0.0.Final 28.2-jre 6.0.2.Final diff --git a/core-java-modules/core-java-string-operations-3/pom.xml b/core-java-modules/core-java-string-operations-3/pom.xml index 2567f776b1..1b1237a8c3 100644 --- a/core-java-modules/core-java-string-operations-3/pom.xml +++ b/core-java-modules/core-java-string-operations-3/pom.xml @@ -26,12 +26,6 @@ commons-lang3 ${apache-commons-lang3.version} - - org.assertj - assertj-core - ${assertj.version} - test - org.apache.maven maven-artifact @@ -82,7 +76,6 @@ 11 11 - 3.6.1 5.3.9 3.12.0 31.0.1-jre diff --git a/core-java-modules/core-java-string-operations-4/pom.xml b/core-java-modules/core-java-string-operations-4/pom.xml index ea6bdcd849..d0e5ae29d5 100644 --- a/core-java-modules/core-java-string-operations-4/pom.xml +++ b/core-java-modules/core-java-string-operations-4/pom.xml @@ -16,12 +16,6 @@ - - org.assertj - assertj-core - ${assertj.version} - test - com.google.guava guava @@ -50,7 +44,6 @@ 11 11 - 3.6.1 31.0.1-jre 4.1 diff --git a/core-java-modules/core-java-string-operations/pom.xml b/core-java-modules/core-java-string-operations/pom.xml index 67ce43277e..20e4df3ba3 100644 --- a/core-java-modules/core-java-string-operations/pom.xml +++ b/core-java-modules/core-java-string-operations/pom.xml @@ -40,12 +40,6 @@ commons-codec ${commons-codec.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -59,7 +53,6 @@ - 3.6.1 1.15 diff --git a/core-java-modules/core-java-strings/pom.xml b/core-java-modules/core-java-strings/pom.xml index aca0bb3346..d78cb7b92d 100644 --- a/core-java-modules/core-java-strings/pom.xml +++ b/core-java-modules/core-java-strings/pom.xml @@ -36,12 +36,6 @@ icu4j ${icu4j.version} - - org.assertj - assertj-core - ${assertj.version} - test - @@ -55,7 +49,6 @@ - 3.6.1 61.1 15 diff --git a/core-java-modules/core-java-sun/pom.xml b/core-java-modules/core-java-sun/pom.xml index 4c26b59168..e959932235 100644 --- a/core-java-modules/core-java-sun/pom.xml +++ b/core-java-modules/core-java-sun/pom.xml @@ -15,13 +15,6 @@ - - - org.assertj - assertj-core - ${assertj.version} - test - com.sun tools @@ -93,10 +86,7 @@ - - 3.6.1 1.7.0 - 1.8.0 diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index d3c351b385..e2924b5278 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -27,13 +27,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj.version} - test - joda-time joda-time @@ -87,12 +80,9 @@ - 3.6.1 2.10 1.18.12 - - 3.6.1 1.8.9 2.0.7 1.44 diff --git a/core-java-modules/core-java-uuid/pom.xml b/core-java-modules/core-java-uuid/pom.xml index a38306f269..983d0f2ba3 100644 --- a/core-java-modules/core-java-uuid/pom.xml +++ b/core-java-modules/core-java-uuid/pom.xml @@ -25,12 +25,6 @@ log4j-over-slf4j ${org.slf4j.version} - - org.assertj - assertj-core - ${assertj-core.version} - test - @@ -147,7 +141,6 @@ - 3.10.0 3.0.0-M1 diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index 42262be29a..8d6921b493 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -49,13 +49,6 @@ ${lombok.version} provided - - - org.assertj - assertj-core - ${assertj-core.version} - test - org.javamoney moneta @@ -185,8 +178,6 @@ 0.4 1.8.7 - - 3.10.0 1.1 3.0.0-M1 diff --git a/core-java-modules/multimodulemavenproject/pom.xml b/core-java-modules/multimodulemavenproject/pom.xml index 79d884cd86..fbafa7ebff 100644 --- a/core-java-modules/multimodulemavenproject/pom.xml +++ b/core-java-modules/multimodulemavenproject/pom.xml @@ -23,17 +23,6 @@ mainappmodule - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - @@ -54,7 +43,6 @@ 3.8.0 1.9 1.9 - 3.12.2 \ No newline at end of file From e1331505c599dcb39f1e5aadf01e8fba127ba135 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Thu, 18 Nov 2021 13:23:25 +0000 Subject: [PATCH 203/551] [JAVA-6455] Remove Lombok --- .../h2db/springboot/models/Country.java | 42 +++++++++++++++++-- .../baeldung/SpringBootH2IntegrationTest.java | 13 +++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java index f0f02c41d3..d6edab9421 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Country.java @@ -1,15 +1,13 @@ package com.baeldung.h2db.springboot.models; -import lombok.Data; - import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; +import java.util.Objects; @Table(name = "countries") @Entity -@Data public class Country { @Id @@ -18,4 +16,42 @@ public class Country { private String name; + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Country country = (Country) o; + return id == country.id && name.equals(country.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Country{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } } diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java index abdbd76c19..4c11ae6b0d 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java @@ -15,6 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = SpringBootH2Application.class) public class SpringBootH2IntegrationTest { + private static final Country AN_EXPECTED_COUNTRY = buildCountry(); + @Autowired private CountryRepository countryRepository; @@ -22,7 +24,16 @@ public class SpringBootH2IntegrationTest { public void givenInitData_whenApplicationStarts_thenDataIsLoaded() { Iterable users = countryRepository.findAll(); - assertThat(users).hasSize(5); + assertThat(users) + .hasSize(5) + .contains(AN_EXPECTED_COUNTRY); + } + + private static Country buildCountry() { + Country c = new Country(); + c.setId(5); + c.setName("Canada"); + return c; } } From b8861e8ea3e0f63dd500df3b17f7c05d6238edb2 Mon Sep 17 00:00:00 2001 From: Seshu Kumar T Date: Thu, 18 Nov 2021 23:34:28 +0530 Subject: [PATCH 204/551] Excel Cell Border Example (#11472) Co-authored-by: Seshu Thanneeru --- .../excel/cellstyle/CellBordersHandler.java | 37 +++++ .../cellstyle/CellBorderHandlerUnitTest.java | 130 ++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellBordersHandler.java create mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellBorderHandlerUnitTest.java diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellBordersHandler.java b/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellBordersHandler.java new file mode 100644 index 0000000000..1c96db0b60 --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellBordersHandler.java @@ -0,0 +1,37 @@ +package com.baeldung.poi.excel.cellstyle; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.RegionUtil; + +public class CellBordersHandler { + + public void setRegionBorder(CellRangeAddress region, Sheet sheet, BorderStyle borderStyle) { + RegionUtil.setBorderTop(borderStyle, region, sheet); + RegionUtil.setBorderBottom(borderStyle, region, sheet); + RegionUtil.setBorderLeft(borderStyle, region, sheet); + RegionUtil.setBorderRight(borderStyle, region, sheet); + } + + public void setRegionBorderWithColor(CellRangeAddress region, Sheet sheet, BorderStyle borderStyle, short color) { + RegionUtil.setTopBorderColor(color, region, sheet); + RegionUtil.setBottomBorderColor(color, region, sheet); + RegionUtil.setLeftBorderColor(color, region, sheet); + RegionUtil.setRightBorderColor(color, region, sheet); + RegionUtil.setBorderTop(borderStyle, region, sheet); + RegionUtil.setBorderBottom(borderStyle, region, sheet); + RegionUtil.setBorderLeft(borderStyle, region, sheet); + RegionUtil.setBorderRight(borderStyle, region, sheet); + } + + public void setCrazyBorder(CellRangeAddress region, Sheet sheet) { + RegionUtil.setTopBorderColor(IndexedColors.RED.index, region, sheet); + RegionUtil.setBottomBorderColor(IndexedColors.GREEN.index, region, sheet); + RegionUtil.setLeftBorderColor(IndexedColors.BLUE.index, region, sheet); + RegionUtil.setRightBorderColor(IndexedColors.VIOLET.index, region, sheet); + RegionUtil.setBorderTop(BorderStyle.DASH_DOT, region, sheet); + RegionUtil.setBorderBottom(BorderStyle.DOUBLE, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.DOTTED, region, sheet); + RegionUtil.setBorderRight(BorderStyle.SLANTED_DASH_DOT, region, sheet); + } +} diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellBorderHandlerUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellBorderHandlerUnitTest.java new file mode 100644 index 0000000000..3cabff2dff --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellBorderHandlerUnitTest.java @@ -0,0 +1,130 @@ +package com.baeldung.poi.excel.cellstyle; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.*; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import static org.junit.Assert.assertEquals; + +public class CellBorderHandlerUnitTest { + private static final String FILE_NAME = "cellstyle/CellStyleHandlerTest.xlsx"; + private static final int SHEET_INDEX = 0; + + private static CellBordersHandler cellBordersHandler; + private static Workbook workbook; + + @BeforeClass + public static void setup() throws URISyntaxException, IOException { + String fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + cellBordersHandler = new CellBordersHandler(); + workbook = new XSSFWorkbook(fileLocation); + createRowsAndCells(workbook); + } + + private static void createRowsAndCells(Workbook workbook) { + Sheet sheet = workbook.getSheetAt(SHEET_INDEX); + for (int rowIndex = 0; rowIndex < 10; rowIndex++) { + Row row = sheet.getRow(rowIndex); + if (row == null) { + row = sheet.createRow(rowIndex); + } + for (int colIndex = 0; colIndex < 10; colIndex++) { + Cell cell = row.getCell(colIndex); + if (cell == null) { + row.createCell(colIndex); + } + } + } + } + + @Test + public void givenWorkbookCell_whenSetRegionBorder() { + Sheet sheet = workbook.getSheetAt(SHEET_INDEX); + + CellRangeAddress region = new CellRangeAddress(1, 1, 1, 1); + cellBordersHandler.setRegionBorder(region, sheet, BorderStyle.THICK); + + Row row = sheet.getRow(1); + Cell cell = row.getCell(1); + assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getBorderBottom(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getBorderRight(), BorderStyle.THICK); + } + + @Test + public void givenWorkbookCell_whenSetRegionBorderWithColor() { + Sheet sheet = workbook.getSheetAt(SHEET_INDEX); + + CellRangeAddress region = new CellRangeAddress(1, 1, 3, 3); + cellBordersHandler.setRegionBorderWithColor(region, sheet, BorderStyle.THICK, IndexedColors.MAROON.index); + + Row row = sheet.getRow(1); + Cell cell = row.getCell(1 + 2); + assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getBorderBottom(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getBorderRight(), BorderStyle.THICK); + assertEquals(cell.getCellStyle().getTopBorderColor(), IndexedColors.MAROON.index); + assertEquals(cell.getCellStyle().getBottomBorderColor(), IndexedColors.MAROON.index); + assertEquals(cell.getCellStyle().getLeftBorderColor(), IndexedColors.MAROON.index); + assertEquals(cell.getCellStyle().getRightBorderColor(), IndexedColors.MAROON.index); + } + + @Test + public void givenWorkbookCell_whenSetCrazyBorder() { + Sheet sheet = workbook.getSheetAt(SHEET_INDEX); + + CellRangeAddress region = new CellRangeAddress(1, 1, 5, 5); + cellBordersHandler.setCrazyBorder(region, sheet); + + Row row = sheet.getRow(1); + Cell cell = row.getCell(5); + assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.DASH_DOT); + assertEquals(cell.getCellStyle().getBorderBottom(), BorderStyle.DOUBLE); + assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.DOTTED); + assertEquals(cell.getCellStyle().getBorderRight(), BorderStyle.SLANTED_DASH_DOT); + assertEquals(cell.getCellStyle().getTopBorderColor(), IndexedColors.RED.index); + assertEquals(cell.getCellStyle().getBottomBorderColor(), IndexedColors.GREEN.index); + assertEquals(cell.getCellStyle().getLeftBorderColor(), IndexedColors.BLUE.index); + assertEquals(cell.getCellStyle().getRightBorderColor(), IndexedColors.VIOLET.index); + } + + @Test + public void givenWorkbookRegion_whenSetRegionBorder() { + Sheet sheet = workbook.getSheetAt(SHEET_INDEX); + + CellRangeAddress region = new CellRangeAddress(3, 5, 1, 5); + cellBordersHandler.setRegionBorder(region, sheet, BorderStyle.MEDIUM); + + Row row = sheet.getRow(3); + Cell cell = row.getCell(1); + assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.MEDIUM); + assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.MEDIUM); + } + + @Test + public void givenWorkbookRegion_whenSetRegionBorderWithColor() { + Sheet sheet = workbook.getSheetAt(SHEET_INDEX); + + CellRangeAddress region = new CellRangeAddress(7, 8, 1, 5); + cellBordersHandler.setRegionBorderWithColor(region, sheet, BorderStyle.MEDIUM, IndexedColors.ORANGE.index); + + Row row = sheet.getRow(7); + Cell cell = row.getCell(1); + assertEquals(cell.getCellStyle().getBorderTop(), BorderStyle.MEDIUM); + assertEquals(cell.getCellStyle().getBorderLeft(), BorderStyle.MEDIUM); + assertEquals(cell.getCellStyle().getTopBorderColor(), IndexedColors.ORANGE.index); + assertEquals(cell.getCellStyle().getLeftBorderColor(), IndexedColors.ORANGE.index); + } + + @AfterClass + public static void close() throws IOException { + workbook.close(); + } +} From 1d8f5ee7ebae4cc568a6abca564f9dc3700b4133 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 19:29:30 +0100 Subject: [PATCH 205/551] JAVA-8436: Fix unit tests in assertion-libraries --- .../java/com/baeldung/assertj/AssertJConditionUnitTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing-modules/assertion-libraries/src/test/java/com/baeldung/assertj/AssertJConditionUnitTest.java b/testing-modules/assertion-libraries/src/test/java/com/baeldung/assertj/AssertJConditionUnitTest.java index ec2d93500f..4ed7fc3ee0 100644 --- a/testing-modules/assertion-libraries/src/test/java/com/baeldung/assertj/AssertJConditionUnitTest.java +++ b/testing-modules/assertion-libraries/src/test/java/com/baeldung/assertj/AssertJConditionUnitTest.java @@ -25,7 +25,7 @@ public class AssertJConditionUnitTest { assertThat(member).isNot(senior); fail(); } catch (AssertionError e) { - assertThat(e).hasMessageContaining("not to be "); + assertThat(e).hasMessageContaining("not to be senior"); } } @@ -38,7 +38,7 @@ public class AssertJConditionUnitTest { assertThat(member).has(nameJohn); fail(); } catch (AssertionError e) { - assertThat(e).hasMessageContaining(""); + assertThat(e).hasMessageContaining("name John"); } } From d26a604c20e262c7b5821cb270c40e545efc030d Mon Sep 17 00:00:00 2001 From: priya-soni Date: Fri, 19 Nov 2021 03:34:38 +0530 Subject: [PATCH 206/551] BAEL-5191-JsonNode-Get-All-Keys-From-A-Json-Structure (#11451) * BAEL-5191-JsonNode-Get-All-Keys-From-A-Json-Structure * Added test cases for GetAllKeysFromJSON class methods * Updated test class name --- .../jackson/jsonnode/GetAllKeysFromJSON.java | 172 ++++++++++++++++++ .../jsonnode/GetAllKeysFromJSONUnitTest.java | 56 ++++++ 2 files changed, 228 insertions(+) create mode 100644 jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java create mode 100644 jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java diff --git a/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java new file mode 100644 index 0000000000..d740b457af --- /dev/null +++ b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java @@ -0,0 +1,172 @@ +package com.baeldung.jackson.jsonnode; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; + +public class GetAllKeysFromJSON { + + public static List getKeysInJsonUsingMaps(String json, ObjectMapper mapper) { + List keys = new ArrayList<>(); + + try { + Map jsonElements = mapper.readValue(json, new TypeReference>() { + }); + getAllKeys(jsonElements, keys); + return keys; + + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + return keys; + } + + public static void getAllKeys(Map jsonElements, List keys) { + + jsonElements.entrySet() + .forEach(entry -> { + keys.add(entry.getKey()); + if (entry.getValue() instanceof Map) { + Map map = (Map) entry.getValue(); + getAllKeys(map, keys); + } else if (entry.getValue() instanceof List) { + List list = (List) entry.getValue(); + list.forEach(listEntry -> { + if (listEntry instanceof Map) { + Map map = (Map) listEntry; + getAllKeys(map, keys); + } + }); + } + }); + } + + public static List getKeysInJsonUsingJsonNodeFieldNames(String json, ObjectMapper mapper) { + List keys = new ArrayList<>(); + + try { + JsonNode jsonNode = mapper.readTree(json); + Iterator iterator = jsonNode.fieldNames(); + iterator.forEachRemaining(e -> keys.add(e)); + + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return keys; + } + + public static List getAllKeysInJsonUsingJsonNodeFieldNames(String json, ObjectMapper mapper) { + List keys = new ArrayList<>(); + + try { + JsonNode jsonNode = mapper.readTree(json); + getAllKeysUsingJsonNodeFieldNames(jsonNode, keys); + + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return keys; + } + + public static List getAllKeysInJsonUsingJsonNodeFields(String json, ObjectMapper mapper) { + List keys = new ArrayList<>(); + + try { + JsonNode jsonNode = mapper.readTree(json); + getAllKeysUsingJsonNodeFields(jsonNode, keys); + + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return keys; + } + + public static void getAllKeysUsingJsonNodeFields(JsonNode jsonNode, List keys) { + + if (jsonNode.isObject()) { + Iterator> fields = jsonNode.fields(); + + fields.forEachRemaining(field -> { + keys.add(field.getKey()); + getAllKeysUsingJsonNodeFieldNames((JsonNode) field.getValue(), keys); + }); + } else if (jsonNode.isArray()) { + ArrayNode arrayField = (ArrayNode) jsonNode; + arrayField.forEach(node -> { + getAllKeysUsingJsonNodeFieldNames(node, keys); + }); + } + + } + + public static void getAllKeysUsingJsonNodeFieldNames(JsonNode jsonNode, List keys) { + + if (jsonNode.isObject()) { + Iterator fieldNames = jsonNode.fieldNames(); + + fieldNames.forEachRemaining(fieldName -> { + keys.add(fieldName); + getAllKeysUsingJsonNodeFieldNames(jsonNode.get(fieldName), keys); + }); + } else if (jsonNode.isArray()) { + ArrayNode arrayField = (ArrayNode) jsonNode; + arrayField.forEach(node -> { + getAllKeysUsingJsonNodeFieldNames(node, keys); + }); + } + + } + + public static List getKeysInJsonUsingJsonParser(String json, ObjectMapper mapper) { + List keys = new ArrayList<>(); + + try { + JsonNode jsonNode = mapper.readTree(json); + JsonParser jsonParser = jsonNode.traverse(); + while (!jsonParser.isClosed()) { + if (jsonParser.nextToken() == JsonToken.FIELD_NAME) { + keys.add((jsonParser.getCurrentName())); + } + } + } catch (JsonProcessingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return keys; + } + + public static List getKeysInJsonUsingJsonParser(String json) { + List keys = new ArrayList<>(); + + try { + JsonFactory factory = new JsonFactory(); + JsonParser jsonParser = factory.createParser(json); + while (!jsonParser.isClosed()) { + if (jsonParser.nextToken() == JsonToken.FIELD_NAME) { + keys.add((jsonParser.getCurrentName())); + } + } + } catch (JsonProcessingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return keys; + } +} diff --git a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java new file mode 100644 index 0000000000..b547422aad --- /dev/null +++ b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.jackson.jsonnode; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class GetAllKeysFromJSONUnitTest { + + private static String json = "{\r\n" + " \"Name\":\"Craig\",\r\n" + " \"Age\":10,\r\n" + " \"BookInterests\":[\r\n" + " {\r\n" + " \"Book\":\"The Kite Runner\",\r\n" + " \"Author\":\"Khaled Hosseini\"\r\n" + " },\r\n" + + " {\r\n" + " \"Book\":\"Harry Potter\",\r\n" + " \"Author\":\"J. K. Rowling\"\r\n" + " }\r\n" + " ],\r\n" + " \"FoodInterests\":{\r\n" + " \"Breakfast\":[\r\n" + " {\r\n" + + " \"Bread\":\"Whole wheat\",\r\n" + " \"Beverage\":\"Fruit juice\"\r\n" + " },\r\n" + " {\r\n" + " \"Sandwich\":\"Vegetable Sandwich\",\r\n" + " \"Beverage\":\"Coffee\"\r\n" + + " }\r\n" + " ]\r\n" + " }\r\n" + "}"; + + private static ObjectMapper mapper = new ObjectMapper(); + + // Top level keys : [Name, Age, BookInterests, FoodInterests] + // All keys: [Name, Age, BookInterests, Book, Author, Book, Author, FoodInterests, Breakfast, Bread, Beverage, Sandwich, Beverage] + + @Test + public void givenAJsonNode_whenUsingFieldNamesMethod_thenWeGetTopFieldNames() { + List keys = GetAllKeysFromJSON.getKeysInJsonUsingJsonNodeFieldNames(json, mapper); + assertEquals(4, keys.size()); + } + + @Test + public void givenAJsonNode_whenUsingFieldNamesMethodForAllNodes_thenWeGetAllFieldNames() { + List keys = GetAllKeysFromJSON.getAllKeysInJsonUsingJsonNodeFieldNames(json, mapper); + assertEquals(13, keys.size()); + } + + @Test + public void givenAJsonNode_whenUsingFieldsMethod_thenWeGetAllFieldNames() { + List keys = GetAllKeysFromJSON.getAllKeysInJsonUsingJsonNodeFields(json, mapper); + assertEquals(13, keys.size()); + } + + @Test + public void givenAJsonNode_whenUsingJsonParserMethod_thenWeGetAllFieldNames() { + List keys = GetAllKeysFromJSON.getKeysInJsonUsingJsonParser(json, mapper); + assertEquals(13, keys.size()); + + keys = GetAllKeysFromJSON.getKeysInJsonUsingJsonParser(json); + assertEquals(13, keys.size()); + } + + @Test + public void givenAJsonNode_whenUsingMaps_thenWeGetAllFieldNames() { + List keys = GetAllKeysFromJSON.getKeysInJsonUsingMaps(json, mapper); + assertEquals(13, keys.size()); + } + +} From 5b541fa52405c553a9407b64a8e06b52eab43c92 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 18 Nov 2021 23:17:00 +0100 Subject: [PATCH 207/551] JAVA-8436: Upgrade AssertJ Guava to 3.4.0 --- testing-modules/assertion-libraries/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/assertion-libraries/pom.xml b/testing-modules/assertion-libraries/pom.xml index b5cfd711d2..ea9a37afaf 100644 --- a/testing-modules/assertion-libraries/pom.xml +++ b/testing-modules/assertion-libraries/pom.xml @@ -77,7 +77,7 @@ 0.32 - 3.1.0 + 3.4.0 2.1.0 1.4.13 0.12 From d086f57024cb7166b9e9ed3746f54f268d8d1f1e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 19 Nov 2021 13:37:18 +0800 Subject: [PATCH 208/551] Update README.md --- spring-boot-modules/spring-boot-runtime/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-runtime/README.md b/spring-boot-modules/spring-boot-runtime/README.md index 6f21efe793..94822af09e 100644 --- a/spring-boot-modules/spring-boot-runtime/README.md +++ b/spring-boot-modules/spring-boot-runtime/README.md @@ -10,3 +10,4 @@ This module contains articles about administering a Spring Boot runtime - [Project Configuration with Spring](https://www.baeldung.com/project-configuration-with-spring) - [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging) - [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat) + - [Max-HTTP-Header-Size in Spring Boot 2](https://www.baeldung.com/spring-boot-max-http-header-size) From 58e6087b3ddba7fa23eddd0b18e1ea1645c8e971 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Thu, 18 Nov 2021 11:19:23 +0530 Subject: [PATCH 209/551] JAVA-8405: reducing logging for tutorials-build-job --- .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../exceptions/LambdaExceptionWrappers.java | 11 +++-- .../MethodReferenceUnitTest.java | 8 +-- .../java/com/baeldung/generics/Building.java | 2 +- .../java/com/baeldung/generics/House.java | 2 +- .../baeldung/initializationguide/User.java | 13 +++-- .../java/com/baeldung/loops/LoopsInJava.java | 13 +++-- .../switchstatement/SwitchStatement.java | 10 +++- .../com/baeldung/loops/LoopsUnitTest.java | 23 ++++++--- jta/src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ logback-config.xml | 12 +++++ .../lazyinitialization/HibernateUtil.java | 2 +- .../transientobject/HibernateUtil.java | 2 +- .../interceptors/CustomInterceptor.java | 4 +- .../hibernate/interceptors/entity/User.java | 3 +- .../hibernate/hilo/HibernateHiloUnitTest.java | 6 +-- .../proxy/HibernateProxyUnitTest.java | 3 ++ .../test/resources/hibernate-hilo.properties | 2 +- .../hibernate-interceptors.properties | 2 +- .../resources/hibernate-lifecycle.properties | 2 +- .../hibernate-namingstrategy.properties | 2 +- .../hibernate-persistjson.properties | 2 +- .../src/test/resources/hibernate.properties | 2 +- .../src/test/resources/logback-test.xml | 12 +++++ .../java/com/baeldung/SpringContextTest.java | 2 + .../partialupdate/PartialUpdateUnitTest.java | 2 + .../src/test/resources/logback-test.xml | 13 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ pom.xml | 7 ++- .../src/test/resources/logback-test.xml | 12 +++++ .../backpressure/BackpressureUnitTest.java | 16 +++--- spring-aop/pom.xml | 9 ++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../ehcache/calculator/SquaredCalculator.java | 6 ++- .../ehcache/SquareCalculatorUnitTest.java | 24 ++++++--- .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../BeforeAndAfterAnnotationsUnitTest.java | 8 +-- ...ClassAndAfterClassAnnotationsUnitTest.java | 10 ++-- .../migration/junit4/RuleExampleUnitTest.java | 11 +++-- .../junit4/rules/TraceUnitTestRule.java | 14 ++++-- ...foreAllAndAfterAllAnnotationsUnitTest.java | 8 +-- ...reEachAndAfterEachAnnotationsUnitTest.java | 8 +-- .../migration/junit5/RuleExampleUnitTest.java | 9 ++-- .../junit5/extensions/TraceUnitExtension.java | 8 ++- .../ReadResourceDirectoryUnitTest.java | 11 +++-- .../RegisterExtensionSampleExtension.java | 4 +- .../RepeatedTestAnnotationUnitTest.java | 22 +++++---- .../ConditionalAnnotationsUnitTest.java | 49 ++++++++++++------- .../DisabledOnQAEnvironmentExtension.java | 7 ++- ...eneratorTestInvocationContextProvider.java | 21 ++++++-- .../baeldung/junit/log/BusinessWorker.java | 2 +- 81 files changed, 715 insertions(+), 126 deletions(-) create mode 100644 apache-olingo/olingo2/src/test/resources/logback-test.xml create mode 100644 apache-shiro/src/test/resources/logback-test.xml create mode 100644 jta/src/test/resources/logback-test.xml create mode 100644 kubernetes/k8s-admission-controller/src/test/resources/logback-test.xml create mode 100644 libraries-3/src/test/resources/logback-test.xml create mode 100644 libraries-security/src/test/resources/logback-test.xml create mode 100644 logback-config.xml create mode 100644 persistence-modules/spring-boot-persistence-h2/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-data-jpa-enterprise/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-mybatis/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-persistence-simple/src/test/resources/logback-test.xml create mode 100644 software-security/sql-injection-samples/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-1/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-data-2/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-properties-2/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-properties/src/test/resources/logback-test.xml create mode 100644 spring-boot-modules/spring-boot-validation/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-archaius/basic-config/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-archaius/extra-configs/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-archaius/jdbc-config/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-functions/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/src/test/resources/logback-test.xml create mode 100644 spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/readiness-example/src/test/resources/logback-test.xml create mode 100644 spring-core-5/src/test/resources/logback-test.xml create mode 100644 spring-di-2/src/test/resources/logback-test.xml create mode 100644 spring-security-modules/spring-5-security/src/test/resources/logback-test.xml create mode 100644 spring-security-modules/spring-security-oidc/src/test/resources/logback-test.xml create mode 100644 spring-security-modules/spring-security-web-boot-3/src/test/resources/logback-test.xml create mode 100644 spring-web-modules/spring-boot-jsp/src/test/resources/logback-test.xml create mode 100644 spring-web-modules/spring-mvc-basics/src/test/resources/logback-test.xml create mode 100644 spring-web-modules/spring-mvc-java-2/src/test/resources/logback-test.xml create mode 100644 spring-web-modules/spring-rest-http/src/test/resources/logback-test.xml create mode 100644 spring-web-modules/spring-resttemplate-2/src/test/resources/logback-test.xml create mode 100644 spring-web-modules/spring-thymeleaf-2/src/test/resources/logback-test.xml diff --git a/apache-olingo/olingo2/src/test/resources/logback-test.xml b/apache-olingo/olingo2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/apache-olingo/olingo2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/apache-shiro/src/test/resources/logback-test.xml b/apache-shiro/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/apache-shiro/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java b/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java index 64532c8b6f..ce33aaf237 100644 --- a/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java +++ b/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java @@ -1,15 +1,20 @@ package com.baeldung.java8.lambda.exceptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.function.Consumer; public class LambdaExceptionWrappers { + private static final Logger LOGGER = LoggerFactory.getLogger(LambdaExceptionWrappers.class); + public static Consumer lambdaWrapper(Consumer consumer) { return i -> { try { consumer.accept(i); } catch (ArithmeticException e) { - System.err.println("Arithmetic Exception occured : " + e.getMessage()); + LOGGER.error("Arithmetic Exception occured : {}", e.getMessage()); } }; } @@ -21,7 +26,7 @@ public class LambdaExceptionWrappers { } catch (Exception ex) { try { E exCast = clazz.cast(ex); - System.err.println("Exception occured : " + exCast.getMessage()); + LOGGER.error("Exception occured : {}", exCast.getMessage()); } catch (ClassCastException ccEx) { throw ex; } @@ -46,7 +51,7 @@ public class LambdaExceptionWrappers { } catch (Exception ex) { try { E exCast = exceptionClass.cast(ex); - System.err.println("Exception occured : " + exCast.getMessage()); + LOGGER.error("Exception occured : {}", exCast.getMessage()); } catch (ClassCastException ccEx) { throw new RuntimeException(ex); } diff --git a/core-java-modules/core-java-lambdas/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java b/core-java-modules/core-java-lambdas/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java index 957294153b..87c01c3ded 100644 --- a/core-java-modules/core-java-lambdas/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java +++ b/core-java-modules/core-java-lambdas/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java @@ -7,14 +7,16 @@ import java.util.function.BiFunction; import org.apache.commons.lang3.StringUtils; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MethodReferenceUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(MethodReferenceUnitTest.class); + private static void doNothingAtAll(Object... o) { } - ; - @Test public void referenceToStaticMethod() { List messages = Arrays.asList("Hello", "Baeldung", "readers!"); @@ -61,7 +63,7 @@ public class MethodReferenceUnitTest { @Test public void limitationsAndAdditionalExamples() { - createBicyclesList().forEach(b -> System.out.printf("Bike brand is '%s' and frame size is '%d'%n", b.getBrand(), b.getFrameSize())); + createBicyclesList().forEach(b -> LOGGER.debug("Bike brand is '{}' and frame size is '{}'", b.getBrand(), b.getFrameSize())); createBicyclesList().forEach((o) -> MethodReferenceUnitTest.doNothingAtAll(o)); } diff --git a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java index a34dcd3c7e..875b1d0f6d 100644 --- a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java @@ -7,6 +7,6 @@ public class Building { private static final Logger LOGGER = LoggerFactory.getLogger(Building.class); public void paint() { - LOGGER.info("Painting Building"); + LOGGER.debug("Painting Building"); } } diff --git a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java index 88e7d2710a..c1bc6483c4 100644 --- a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java @@ -7,6 +7,6 @@ public class House extends Building { private static final Logger LOGGER = LoggerFactory.getLogger(House.class); public void paint() { - LOGGER.info("Painting House"); + LOGGER.debug("Painting House"); } } diff --git a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java index 1d9a872d69..1604f27368 100644 --- a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java @@ -1,8 +1,13 @@ package com.baeldung.initializationguide; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.Serializable; public class User implements Serializable, Cloneable { + + private static final Logger LOGGER = LoggerFactory.getLogger(User.class); private static final long serialVersionUID = 1L; static String forum; private String name; @@ -10,12 +15,12 @@ public class User implements Serializable, Cloneable { { id = 0; - System.out.println("Instance Initializer"); + LOGGER.debug("Instance Initializer"); } static { - forum = "Java"; - System.out.println("Static Initializer"); + forum = "Java"; + LOGGER.debug("Static Initializer"); } public User(String name, int id) { @@ -25,7 +30,7 @@ public class User implements Serializable, Cloneable { } public User() { - System.out.println("Constructor"); + LOGGER.debug("Constructor"); } public String getName() { diff --git a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java index 1b2e621b52..cdbcd9e341 100644 --- a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java @@ -1,12 +1,17 @@ package com.baeldung.loops; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class LoopsInJava { + private static final Logger LOGGER = LoggerFactory.getLogger(LoopsInJava.class); + public int[] simple_for_loop() { int[] arr = new int[5]; for (int i = 0; i < 5; i++) { arr[i] = i; - System.out.println("Simple for loop: i - " + i); + LOGGER.debug("Simple for loop: i - " + i); } return arr; } @@ -16,7 +21,7 @@ public class LoopsInJava { int[] arr = new int[5]; for (int num : intArr) { arr[num] = num; - System.out.println("Enhanced for-each loop: i - " + num); + LOGGER.debug("Enhanced for-each loop: i - " + num); } return arr; } @@ -26,7 +31,7 @@ public class LoopsInJava { int[] arr = new int[5]; while (i < 5) { arr[i] = i; - System.out.println("While loop: i - " + i++); + LOGGER.debug("While loop: i - " + i++); } return arr; } @@ -36,7 +41,7 @@ public class LoopsInJava { int[] arr = new int[5]; do { arr[i] = i; - System.out.println("Do-While loop: i - " + i++); + LOGGER.debug("Do-While loop: i - " + i++); } while (i < 5); return arr; } diff --git a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java index 69e151bfcb..55b3cbfaaf 100644 --- a/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java @@ -1,7 +1,13 @@ package com.baeldung.switchstatement; +import com.baeldung.loops.LoopsInJava; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class SwitchStatement { + private static final Logger LOGGER = LoggerFactory.getLogger(SwitchStatement.class); + public String exampleOfIF(String animal) { String result; @@ -42,11 +48,11 @@ public class SwitchStatement { switch (animal) { case "DOG": - System.out.println("domestic animal"); + LOGGER.debug("domestic animal"); result = "domestic animal"; default: - System.out.println("unknown animal"); + LOGGER.debug("unknown animal"); result = "unknown animal"; } diff --git a/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/loops/LoopsUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/loops/LoopsUnitTest.java index 5a8b116a2c..354a408af6 100644 --- a/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/loops/LoopsUnitTest.java +++ b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/loops/LoopsUnitTest.java @@ -8,12 +8,16 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import com.baeldung.initializationguide.User; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LoopsUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(LoopsUnitTest.class); private LoopsInJava loops = new LoopsInJava(); private static List list = new ArrayList<>(); private static Set set = new HashSet<>(); @@ -65,41 +69,44 @@ public class LoopsUnitTest { @Test public void whenUsingSimpleFor_shouldIterateList() { for (int i = 0; i < list.size(); i++) { - System.out.println(list.get(i)); + LOGGER.debug(list.get(i)); } } @Test public void whenUsingEnhancedFor_shouldIterateList() { for (String item : list) { - System.out.println(item); + LOGGER.debug(item); } } @Test public void whenUsingEnhancedFor_shouldIterateSet() { for (String item : set) { - System.out.println(item); + LOGGER.debug(item); } } @Test public void whenUsingEnhancedFor_shouldIterateMap() { for (Entry entry : map.entrySet()) { - System.out.println("Key: " + entry.getKey() + " - " + "Value: " + entry.getValue()); + LOGGER.debug("Key: " + entry.getKey() + " - " + "Value: " + entry.getValue()); } } @Test public void whenUsingSimpleFor_shouldRunLabelledLoop() { - aa: for (int i = 1; i <= 3; i++) { - if (i == 1) + aa: + for (int i = 1; i <= 3; i++) { + if (i == 1) { continue; - bb: for (int j = 1; j <= 3; j++) { + } + bb: + for (int j = 1; j <= 3; j++) { if (i == 2 && j == 2) { break aa; } - System.out.println(i + " " + j); + LOGGER.debug(i + " " + j); } } } diff --git a/jta/src/test/resources/logback-test.xml b/jta/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/jta/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/kubernetes/k8s-admission-controller/src/test/resources/logback-test.xml b/kubernetes/k8s-admission-controller/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/kubernetes/k8s-admission-controller/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/libraries-3/src/test/resources/logback-test.xml b/libraries-3/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/libraries-3/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/libraries-security/src/test/resources/logback-test.xml b/libraries-security/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/libraries-security/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/logback-config.xml b/logback-config.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/logback-config.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/HibernateUtil.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/HibernateUtil.java index b84a512fd4..911e3f7540 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/HibernateUtil.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/HibernateUtil.java @@ -24,7 +24,7 @@ public class HibernateUtil { settings.put(Environment.USER, "sa"); settings.put(Environment.PASS, ""); settings.put(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect"); - settings.put(Environment.SHOW_SQL, "true"); + settings.put(Environment.SHOW_SQL, "false"); settings.put(Environment.HBM2DDL_AUTO, "update"); configuration.setProperties(settings); configuration.addAnnotatedClass(User.class); diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/HibernateUtil.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/HibernateUtil.java index a40279661f..ace9e57d84 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/HibernateUtil.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/HibernateUtil.java @@ -27,7 +27,7 @@ public class HibernateUtil { settings.put(Environment.USER, "sa"); settings.put(Environment.PASS, ""); settings.put(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect"); - settings.put(Environment.SHOW_SQL, "true"); + settings.put(Environment.SHOW_SQL, "false"); settings.put(Environment.USE_SQL_COMMENTS, "true"); settings.put(Environment.HBM2DDL_AUTO, "update"); configuration.setProperties(settings); diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/CustomInterceptor.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/CustomInterceptor.java index 1d60ccb6c0..24b06f9b65 100644 --- a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/CustomInterceptor.java +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/CustomInterceptor.java @@ -16,7 +16,7 @@ public class CustomInterceptor extends EmptyInterceptor { @Override public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { if (entity instanceof User) { - logger.info(((User) entity).toString()); + logger.debug(entity.toString()); } return super.onSave(entity, id, state, propertyNames, types); } @@ -25,7 +25,7 @@ public class CustomInterceptor extends EmptyInterceptor { public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object [] previousState, String[] propertyNames, Type[] types) { if (entity instanceof User) { ((User) entity).setLastModified(new Date()); - logger.info(((User) entity).toString()); + logger.debug(entity.toString()); } return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types); } diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/entity/User.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/entity/User.java index 2b1dbe702b..b627cefa33 100644 --- a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/entity/User.java +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/interceptors/entity/User.java @@ -1,7 +1,5 @@ package com.baeldung.hibernate.interceptors.entity; -import java.util.Date; - import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -9,6 +7,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import java.util.Date; @Entity(name = "hbi_user") public class User { diff --git a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/hilo/HibernateHiloUnitTest.java b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/hilo/HibernateHiloUnitTest.java index 9285c30af5..d0eab565df 100644 --- a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/hilo/HibernateHiloUnitTest.java +++ b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/hilo/HibernateHiloUnitTest.java @@ -42,9 +42,9 @@ public class HibernateHiloUnitTest { private void configureLogger() { BasicConfigurator.configure(); LogManager.getLogger("org.hibernate").setLevel(Level.ERROR); - LogManager.getLogger("org.hibernate.id.enhanced.SequenceStructure").setLevel(Level.DEBUG); - LogManager.getLogger("org.hibernate.event.internal.AbstractSaveEventListener").setLevel(Level.DEBUG); - LogManager.getLogger("org.hibernate.SQL").setLevel(Level.DEBUG); + LogManager.getLogger("org.hibernate.id.enhanced.SequenceStructure").setLevel(Level.INFO); + LogManager.getLogger("org.hibernate.event.internal.AbstractSaveEventListener").setLevel(Level.INFO); + LogManager.getLogger("org.hibernate.SQL").setLevel(Level.INFO); } diff --git a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/proxy/HibernateProxyUnitTest.java b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/proxy/HibernateProxyUnitTest.java index 0a4caf032b..217351cd75 100644 --- a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/proxy/HibernateProxyUnitTest.java +++ b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/proxy/HibernateProxyUnitTest.java @@ -1,5 +1,8 @@ package com.baeldung.hibernate.proxy; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; import org.hibernate.*; import org.hibernate.proxy.HibernateProxy; import org.junit.After; diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-hilo.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-hilo.properties index 60d487c1bd..94f3597f1f 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate-hilo.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-hilo.properties @@ -2,7 +2,7 @@ hibernate.connection.driver_class=org.h2.Driver hibernate.connection.url=jdbc:h2:mem:hilo_db;DB_CLOSE_DELAY=-1 hibernate.connection.username=sa hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.c3p0.min_size=5 hibernate.c3p0.max_size=20 diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-interceptors.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-interceptors.properties index 58b55d0a09..e5bb5a36a7 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate-interceptors.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-interceptors.properties @@ -5,6 +5,6 @@ hibernate.connection.autocommit=true jdbc.password= hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.current_session_context_class=org.hibernate.context.internal.ThreadLocalSessionContext \ No newline at end of file diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-lifecycle.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-lifecycle.properties index d043b624f2..1a5e6482bf 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate-lifecycle.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-lifecycle.properties @@ -5,5 +5,5 @@ hibernate.connection.password= hibernate.connection.autocommit=true hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=validate \ No newline at end of file diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties index f75a35bdfe..263033823c 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties @@ -3,7 +3,7 @@ hibernate.connection.url=jdbc:h2:mem:mydb1;DB_CLOSE_DELAY=-1 hibernate.connection.username=sa hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.physical_naming_strategy=com.baeldung.hibernate.namingstrategy.CustomPhysicalNamingStrategy diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-persistjson.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-persistjson.properties index 2cf8ac5b63..2481591fca 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate-persistjson.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-persistjson.properties @@ -3,5 +3,5 @@ hibernate.connection.url=jdbc:h2:mem:mydb1;DB_CLOSE_DELAY=-1 hibernate.connection.username=sa hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop \ No newline at end of file diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate.properties b/persistence-modules/hibernate5/src/test/resources/hibernate.properties index c14782ce0f..42d8e8564f 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate.properties @@ -5,7 +5,7 @@ hibernate.connection.autocommit=true jdbc.password= hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.c3p0.min_size=5 diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/resources/logback-test.xml b/persistence-modules/spring-boot-persistence-h2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java index eaccf4acba..67ce958c64 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java @@ -3,12 +3,14 @@ package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.boot.Application; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) +@TestPropertySource(properties = {"spring.jpa.show-sql=false "}) public class SpringContextTest { @Test diff --git a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java index 874e18c4ad..e217ef590e 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.partialupdate.model.Customer; @@ -16,6 +17,7 @@ import com.baeldung.partialupdate.service.CustomerService; @RunWith(SpringRunner.class) @SpringBootTest(classes = PartialUpdateApplication.class) +@TestPropertySource(properties = {"spring.jpa.show-sql=false "}) public class PartialUpdateUnitTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-enterprise/src/test/resources/logback-test.xml b/persistence-modules/spring-data-jpa-enterprise/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..1595326253 --- /dev/null +++ b/persistence-modules/spring-data-jpa-enterprise/src/test/resources/logback-test.xml @@ -0,0 +1,13 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-mybatis/src/test/resources/logback-test.xml b/persistence-modules/spring-mybatis/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-mybatis/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/test/resources/logback-test.xml b/persistence-modules/spring-persistence-simple/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 372bc5a9f3..8a853ca1d3 100644 --- a/pom.xml +++ b/pom.xml @@ -289,7 +289,6 @@ default-first - org.apache.maven.plugins maven-surefire-plugin @@ -309,6 +308,9 @@ **/JdbcTest.java **/*LiveTest.java + + ${tutorialsproject.basedir}/logback-config.xml + @@ -576,6 +578,9 @@ **/*JdbcTest.java **/*LiveTest.java + + ${tutorialsproject.basedir}/logback-config.xml + diff --git a/software-security/sql-injection-samples/src/test/resources/logback-test.xml b/software-security/sql-injection-samples/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/software-security/sql-injection-samples/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-5-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java index e7cb60dbf9..a12d762fe5 100644 --- a/spring-5-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java +++ b/spring-5-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java @@ -1,21 +1,25 @@ package com.baeldung.backpressure; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import reactor.core.publisher.BaseSubscriber; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; public class BackpressureUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(BackpressureUnitTest.class); + @Test public void whenLimitRateSet_thenSplitIntoChunks() throws InterruptedException { Flux limit = Flux.range(1, 25); limit.limitRate(10); limit.subscribe( - value -> System.out.println(value), + value -> LOGGER.debug(String.valueOf(value)), err -> err.printStackTrace(), - () -> System.out.println("Finished!!"), + () -> LOGGER.debug("Finished!!"), subscription -> subscription.request(15) ); @@ -34,12 +38,12 @@ public class BackpressureUnitTest { Flux request = Flux.range(1, 50); request.subscribe( - System.out::println, + integer -> LOGGER.debug(String.valueOf(integer)), err -> err.printStackTrace(), - () -> System.out.println("All 50 items have been successfully processed!!!"), + () -> LOGGER.debug("All 50 items have been successfully processed!!!"), subscription -> { for (int i = 0; i < 5; i++) { - System.out.println("Requesting the next 10 elements!!!"); + LOGGER.debug("Requesting the next 10 elements!!!"); subscription.request(10); } } @@ -68,7 +72,7 @@ public class BackpressureUnitTest { @Override protected void hookOnNext(Integer value) { request(3); - System.out.println(value); + LOGGER.debug(String.valueOf(value)); cancel(); } }); diff --git a/spring-aop/pom.xml b/spring-aop/pom.xml index da981987fe..cbec4ef35b 100644 --- a/spring-aop/pom.xml +++ b/spring-aop/pom.xml @@ -65,6 +65,15 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/main/resources/logback.xml + + + diff --git a/spring-boot-modules/spring-boot-1/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-1/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-1/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data-2/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-data-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-data-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-jersey/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-jersey/spring-boot-mvc/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-properties-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-properties/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-validation/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-validation/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-boot-modules/spring-boot-validation/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java b/spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java index caf1df2a1b..e653e84048 100644 --- a/spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java +++ b/spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java @@ -1,8 +1,12 @@ package com.baeldung.ehcache.calculator; import com.baeldung.ehcache.config.CacheHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SquaredCalculator { + + private static final Logger LOGGER = LoggerFactory.getLogger(SquaredCalculator.class); private CacheHelper cache; public int getSquareValueOfNumber(int input) { @@ -10,7 +14,7 @@ public class SquaredCalculator { return cache.getSquareNumberCache().get(input); } - System.out.println("Calculating square value of " + input + " and caching result."); + LOGGER.debug("Calculating square value of {} and caching result.", input); int squaredValue = (int) Math.pow(input, 2); cache.getSquareNumberCache().put(input, squaredValue); diff --git a/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java b/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java index 37df749bab..311b7c575e 100644 --- a/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java +++ b/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java @@ -4,13 +4,18 @@ import com.baeldung.ehcache.calculator.SquaredCalculator; import com.baeldung.ehcache.config.CacheHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class SquareCalculatorUnitTest { - private SquaredCalculator squaredCalculator = new SquaredCalculator(); - private CacheHelper cacheHelper = new CacheHelper(); + + private static final Logger LOGGER = LoggerFactory.getLogger(SquareCalculatorUnitTest.class); + + private final SquaredCalculator squaredCalculator = new SquaredCalculator(); + private final CacheHelper cacheHelper = new CacheHelper(); @Before public void setup() { @@ -20,21 +25,24 @@ public class SquareCalculatorUnitTest { @Test public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() { for (int i = 10; i < 15; i++) { - assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); - System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + assertFalse(cacheHelper.getSquareNumberCache() + .containsKey(i)); + LOGGER.debug("Square value of {} is: {}", i, squaredCalculator.getSquareValueOfNumber(i)); } } @Test public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() { for (int i = 10; i < 15; i++) { - assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); - System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + assertFalse(cacheHelper.getSquareNumberCache() + .containsKey(i)); + LOGGER.debug("Square value of {} is: {}", i, squaredCalculator.getSquareValueOfNumber(i)); } for (int i = 10; i < 15; i++) { - assertTrue(cacheHelper.getSquareNumberCache().containsKey(i)); - System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + assertTrue(cacheHelper.getSquareNumberCache() + .containsKey(i)); + LOGGER.debug("Square value of {} is: {}", i, squaredCalculator.getSquareValueOfNumber(i) + "\n"); } } } diff --git a/spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-archaius/basic-config/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-archaius/basic-config/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-archaius/basic-config/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-archaius/extra-configs/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-archaius/extra-configs/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-archaius/extra-configs/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-archaius/jdbc-config/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-archaius/jdbc-config/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-archaius/jdbc-config/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-functions/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-functions/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-functions/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/readiness-example/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/readiness-example/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/readiness-example/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-core-5/src/test/resources/logback-test.xml b/spring-core-5/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-core-5/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-di-2/src/test/resources/logback-test.xml b/spring-di-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-di-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-security-modules/spring-5-security/src/test/resources/logback-test.xml b/spring-security-modules/spring-5-security/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/test/resources/logback-test.xml b/spring-security-modules/spring-security-oidc/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-boot-3/src/test/resources/logback-test.xml b/spring-security-modules/spring-security-web-boot-3/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-security-modules/spring-security-web-boot-3/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-boot-jsp/src/test/resources/logback-test.xml b/spring-web-modules/spring-boot-jsp/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-web-modules/spring-boot-jsp/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-mvc-basics/src/test/resources/logback-test.xml b/spring-web-modules/spring-mvc-basics/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-web-modules/spring-mvc-basics/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-mvc-java-2/src/test/resources/logback-test.xml b/spring-web-modules/spring-mvc-java-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-web-modules/spring-mvc-java-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-rest-http/src/test/resources/logback-test.xml b/spring-web-modules/spring-rest-http/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-web-modules/spring-rest-http/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-2/src/test/resources/logback-test.xml b/spring-web-modules/spring-resttemplate-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-thymeleaf-2/src/test/resources/logback-test.xml b/spring-web-modules/spring-thymeleaf-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java index 6022de123f..3e09a3adbb 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java @@ -23,19 +23,19 @@ public class BeforeAndAfterAnnotationsUnitTest { @Before public void init() { - LOG.info("startup"); + LOG.debug("startup"); list = new ArrayList<>(Arrays.asList("test1", "test2")); } @After public void teardown() { - LOG.info("teardown"); + LOG.debug("teardown"); list.clear(); } @Test public void whenCheckingListSize_thenSizeEqualsToInit() { - LOG.info("executing test"); + LOG.debug("executing test"); assertEquals(2, list.size()); list.add("another test"); @@ -43,7 +43,7 @@ public class BeforeAndAfterAnnotationsUnitTest { @Test public void whenCheckingListSizeAgain_thenSizeEqualsToInit() { - LOG.info("executing another test"); + LOG.debug("executing another test"); assertEquals(2, list.size()); list.add("yet another test"); diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeClassAndAfterClassAnnotationsUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeClassAndAfterClassAnnotationsUnitTest.java index 8a82a75d3d..8b0ddd259f 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeClassAndAfterClassAnnotationsUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeClassAndAfterClassAnnotationsUnitTest.java @@ -12,24 +12,24 @@ import org.slf4j.LoggerFactory; public class BeforeClassAndAfterClassAnnotationsUnitTest { private static final Logger LOG = LoggerFactory.getLogger(BeforeClassAndAfterClassAnnotationsUnitTest.class); - + @BeforeClass public static void setup() { - LOG.info("startup - creating DB connection"); + LOG.debug("startup - creating DB connection"); } @AfterClass public static void tearDown() { - LOG.info("closing DB connection"); + LOG.debug("closing DB connection"); } @Test public void simpleTest() { - LOG.info("simple test"); + LOG.debug("simple test"); } @Test public void anotherSimpleTest() { - LOG.info("another simple test"); + LOG.debug("another simple test"); } } diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/RuleExampleUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/RuleExampleUnitTest.java index 969d1b370e..9cf6eafd7e 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/RuleExampleUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/RuleExampleUnitTest.java @@ -1,18 +1,21 @@ package com.baeldung.migration.junit4; +import com.baeldung.migration.junit4.rules.TraceUnitTestRule; import org.junit.Rule; import org.junit.Test; - -import com.baeldung.migration.junit4.rules.TraceUnitTestRule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RuleExampleUnitTest { - + + private static final Logger LOGGER = LoggerFactory.getLogger(RuleExampleUnitTest.class); + @Rule public final TraceUnitTestRule traceRuleTests = new TraceUnitTestRule(); @Test public void whenTracingTests() { - System.out.println("This is my test"); + LOGGER.debug("This is my test"); /*...*/ } } diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/rules/TraceUnitTestRule.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/rules/TraceUnitTestRule.java index 5c993f17fd..b17e0b07c8 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/rules/TraceUnitTestRule.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/rules/TraceUnitTestRule.java @@ -1,15 +1,19 @@ package com.baeldung.migration.junit4.rules; -import java.util.ArrayList; -import java.util.List; - import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.MultipleFailureException; import org.junit.runners.model.Statement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; public class TraceUnitTestRule implements TestRule { + private static final Logger LOGGER = LoggerFactory.getLogger(TraceUnitTestRule.class); + @Override public Statement apply(Statement base, Description description) { @@ -18,13 +22,13 @@ public class TraceUnitTestRule implements TestRule { public void evaluate() throws Throwable { List errors = new ArrayList(); - System.out.println("Starting test ... " + description.getMethodName()); + LOGGER.debug("Starting test ... {}", description.getMethodName()); try { base.evaluate(); } catch (Throwable e) { errors.add(e); } finally { - System.out.println("... test finished. " + description.getMethodName()); + LOGGER.debug("... test finished. {}", description.getMethodName()); } MultipleFailureException.assertEmpty(errors); diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeAllAndAfterAllAnnotationsUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeAllAndAfterAllAnnotationsUnitTest.java index b81e9b7b8e..5181d54a46 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeAllAndAfterAllAnnotationsUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeAllAndAfterAllAnnotationsUnitTest.java @@ -15,21 +15,21 @@ public class BeforeAllAndAfterAllAnnotationsUnitTest { @BeforeAll public static void setup() { - LOG.info("startup - creating DB connection"); + LOG.debug("startup - creating DB connection"); } @AfterAll public static void tearDown() { - LOG.info("closing DB connection"); + LOG.debug("closing DB connection"); } @Test public void simpleTest() { - LOG.info("simple test"); + LOG.debug("simple test"); } @Test public void anotherSimpleTest() { - LOG.info("another simple test"); + LOG.debug("another simple test"); } } diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java index f0093b3bf6..b2112ef2c3 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java @@ -23,19 +23,19 @@ public class BeforeEachAndAfterEachAnnotationsUnitTest { @BeforeEach public void init() { - LOG.info("startup"); + LOG.debug("startup"); list = new ArrayList<>(Arrays.asList("test1", "test2")); } @AfterEach public void teardown() { - LOG.info("teardown"); + LOG.debug("teardown"); list.clear(); } @Test public void whenCheckingListSize_ThenSizeEqualsToInit() { - LOG.info("executing test"); + LOG.debug("executing test"); assertEquals(2, list.size()); list.add("another test"); @@ -43,7 +43,7 @@ public class BeforeEachAndAfterEachAnnotationsUnitTest { @Test public void whenCheckingListSizeAgain_ThenSizeEqualsToInit() { - LOG.info("executing another test"); + LOG.debug("executing another test"); assertEquals(2, list.size()); list.add("yet another test"); diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/RuleExampleUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/RuleExampleUnitTest.java index 7b1bcda730..c67a57dcbd 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/RuleExampleUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/RuleExampleUnitTest.java @@ -1,19 +1,22 @@ package com.baeldung.migration.junit5; +import com.baeldung.migration.junit5.extensions.TraceUnitExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.platform.runner.JUnitPlatform; import org.junit.runner.RunWith; - -import com.baeldung.migration.junit5.extensions.TraceUnitExtension; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(JUnitPlatform.class) @ExtendWith(TraceUnitExtension.class) public class RuleExampleUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(RuleExampleUnitTest.class); + @Test public void whenTracingTests() { - System.out.println("This is my test"); + LOGGER.debug("This is my test"); /*...*/ } } diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java index db5d3e2573..165ca8741a 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java @@ -3,17 +3,21 @@ package com.baeldung.migration.junit5.extensions; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TraceUnitExtension implements AfterEachCallback, BeforeEachCallback { + private static final Logger LOGGER = LoggerFactory.getLogger(TraceUnitExtension.class); + @Override public void beforeEach(ExtensionContext context) throws Exception { - System.out.println("Starting test ... " + context.getDisplayName()); + LOGGER.debug("Starting test ... {}", context.getDisplayName()); } @Override public void afterEach(ExtensionContext context) throws Exception { - System.out.println("... test finished. " + context.getDisplayName()); + LOGGER.debug("... test finished. {}", context.getDisplayName()); } } diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java index eb8cab2462..b8358449c0 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java @@ -1,7 +1,10 @@ package com.baeldung.resourcedirectory; +import com.baeldung.migration.junit5.extensions.TraceUnitExtension; import org.junit.Assert; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.nio.file.Path; @@ -9,6 +12,8 @@ import java.nio.file.Paths; public class ReadResourceDirectoryUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(TraceUnitExtension.class); + @Test public void givenResourcePath_whenReadAbsolutePathWithFile_thenAbsolutePathEndsWithDirectory() { String path = "src/test/resources"; @@ -16,7 +21,7 @@ public class ReadResourceDirectoryUnitTest { File file = new File(path); String absolutePath = file.getAbsolutePath(); - System.out.println(absolutePath); + LOGGER.debug(absolutePath); Assert.assertTrue(absolutePath.endsWith("src" + File.separator + "test" + File.separator + "resources")); } @@ -26,7 +31,7 @@ public class ReadResourceDirectoryUnitTest { String absolutePath = resourceDirectory.toFile().getAbsolutePath(); - System.out.println(absolutePath); + LOGGER.debug(absolutePath); Assert.assertTrue(absolutePath.endsWith("src" + File.separator + "test" + File.separator + "resources")); } @@ -38,7 +43,7 @@ public class ReadResourceDirectoryUnitTest { File file = new File(classLoader.getResource(resourceName).getFile()); String absolutePath = file.getAbsolutePath(); - System.out.println(absolutePath); + LOGGER.debug(absolutePath); Assert.assertTrue(absolutePath.endsWith(File.separator + "example_resource.txt")); } diff --git a/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java index 5339f98875..31d45955ca 100644 --- a/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java @@ -20,12 +20,12 @@ public class RegisterExtensionSampleExtension implements BeforeAllCallback, Befo @Override public void beforeAll(ExtensionContext extensionContext) throws Exception { - logger.info("Type {} In beforeAll : {}", type, extensionContext.getDisplayName()); + logger.debug("Type {} In beforeAll : {}", type, extensionContext.getDisplayName()); } @Override public void beforeEach(ExtensionContext extensionContext) throws Exception { - logger.info("Type {} In beforeEach : {}", type, extensionContext.getDisplayName()); + logger.debug("Type {} In beforeEach : {}", type, extensionContext.getDisplayName()); } public String getType() { diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java index f9121d8790..c3e6d19568 100644 --- a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java @@ -1,41 +1,45 @@ package com.baeldung.junit5; -import static org.junit.jupiter.api.Assertions.assertEquals; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.RepetitionInfo; import org.junit.jupiter.api.TestInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class RepeatedTestAnnotationUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(RepeatedTestAnnotationUnitTest.class); + @BeforeEach void beforeEachTest() { - System.out.println("Before Each Test"); + LOGGER.debug("Before Each Test"); } @AfterEach void afterEachTest() { - System.out.println("After Each Test"); - System.out.println("====================="); + LOGGER.debug("After Each Test"); + LOGGER.debug("====================="); } @RepeatedTest(3) void repeatedTest(TestInfo testInfo) { - System.out.println("Executing repeated test"); + LOGGER.debug("Executing repeated test"); assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2"); } @RepeatedTest(value = 3, name = RepeatedTest.LONG_DISPLAY_NAME) void repeatedTestWithLongName() { - System.out.println("Executing repeated test with long name"); + LOGGER.debug("Executing repeated test with long name"); assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2"); } @RepeatedTest(value = 3, name = RepeatedTest.SHORT_DISPLAY_NAME) void repeatedTestWithShortName() { - System.out.println("Executing repeated test with long name"); + LOGGER.debug("Executing repeated test with long name"); assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2"); } @@ -46,7 +50,7 @@ public class RepeatedTestAnnotationUnitTest { @RepeatedTest(3) void repeatedTestWithRepetitionInfo(RepetitionInfo repetitionInfo) { - System.out.println("Repetition #" + repetitionInfo.getCurrentRepetition()); + LOGGER.debug("Repetition # {}", repetitionInfo.getCurrentRepetition()); assertEquals(3, repetitionInfo.getTotalRepetitions()); } } diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java index ba840a1c33..0d4013116f 100644 --- a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java @@ -2,7 +2,20 @@ package com.baeldung.junit5.conditional; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.*; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; +import org.junit.jupiter.api.condition.DisabledOnJre; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; +import org.junit.jupiter.api.condition.EnabledOnJre; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.JRE; +import org.junit.jupiter.api.condition.OS; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -11,64 +24,66 @@ import java.lang.annotation.Target; public class ConditionalAnnotationsUnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(ConditionalAnnotationsUnitTest.class); + @Test @EnabledOnOs({OS.WINDOWS, OS.MAC}) public void shouldRunBothWindowsAndMac() { - System.out.println("runs on Windows and Mac"); + LOGGER.debug("runs on Windows and Mac"); } @Test @DisabledOnOs(OS.LINUX) public void shouldNotRunAtLinux() { - System.out.println("will not run on Linux"); + LOGGER.debug("will not run on Linux"); } @Test @EnabledOnJre({JRE.JAVA_10, JRE.JAVA_11}) public void shouldOnlyRunOnJava10And11() { - System.out.println("runs with java 10 and 11"); + LOGGER.debug("runs with java 10 and 11"); } @Test @EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_13) public void shouldOnlyRunOnJava8UntilJava13() { - System.out.println("runs with Java 8, 9, 10, 11, 12 and 13!"); + LOGGER.debug("runs with Java 8, 9, 10, 11, 12 and 13!"); } @Test @DisabledForJreRange(min = JRE.JAVA_14, max = JRE.JAVA_15) public void shouldNotBeRunOnJava14AndJava15() { - System.out.println("Shouldn't be run on Java 14 and 15."); + LOGGER.debug("Shouldn't be run on Java 14 and 15."); } @Test @DisabledOnJre(JRE.OTHER) public void thisTestOnlyRunsWithUpToDateJREs() { - System.out.println("this test will only run on java8, 9, 10 and 11."); + LOGGER.debug("this test will only run on java8, 9, 10 and 11."); } @Test @EnabledIfSystemProperty(named = "java.vm.vendor", matches = "Oracle.*") public void onlyIfVendorNameStartsWithOracle() { - System.out.println("runs only if vendor name starts with Oracle"); + LOGGER.debug("runs only if vendor name starts with Oracle"); } @Test @DisabledIfSystemProperty(named = "file.separator", matches = "[/]") public void disabledIfFileSeperatorIsSlash() { - System.out.println("Will not run if file.sepeartor property is /"); + LOGGER.debug("Will not run if file.sepeartor property is /"); } @Test @EnabledIfEnvironmentVariable(named = "GDMSESSION", matches = "ubuntu") public void onlyRunOnUbuntuServer() { - System.out.println("only runs if GDMSESSION is ubuntu"); + LOGGER.debug("only runs if GDMSESSION is ubuntu"); } @Test @DisabledIfEnvironmentVariable(named = "LC_TIME", matches = ".*UTF-8.") public void shouldNotRunWhenTimeIsNotUTF8() { - System.out.println("will not run if environment variable LC_TIME is UTF-8"); + LOGGER.debug("will not run if environment variable LC_TIME is UTF-8"); } // Commented codes are going to work prior JUnit 5.5 @@ -76,13 +91,13 @@ public class ConditionalAnnotationsUnitTest { @Test // @EnabledIf("'FR' == systemProperty.get('user.country')") public void onlyFrenchPeopleWillRunThisMethod() { - System.out.println("will run only if user.country is FR"); + LOGGER.debug("will run only if user.country is FR"); } @Test // @DisabledIf("java.lang.System.getProperty('os.name').toLowerCase().contains('mac')") public void shouldNotRunOnMacOS() { - System.out.println("will not run if our os.name is mac"); + LOGGER.debug("will not run if our os.name is mac"); } @Test @@ -97,14 +112,14 @@ public class ConditionalAnnotationsUnitTest { engine = "nashorn", reason = "Self-fulfilling: {result}")*/ public void onlyRunsInFebruary() { - System.out.println("this test only runs in February"); + LOGGER.debug("this test only runs in February"); } @Test /*@DisabledIf("systemEnvironment.get('XPC_SERVICE_NAME') != null " + "&& systemEnvironment.get('XPC_SERVICE_NAME').contains('intellij')")*/ public void notValidForIntelliJ() { - System.out.println("this test will run if our ide is INTELLIJ"); + LOGGER.debug("this test will run if our ide is INTELLIJ"); } @Target(ElementType.METHOD) @@ -117,7 +132,7 @@ public class ConditionalAnnotationsUnitTest { @ThisTestWillOnlyRunAtLinuxAndMacWithJava9Or10Or11 public void someSuperTestMethodHere() { - System.out.println("this method will run with java9, 10, 11 and Linux or macOS."); + LOGGER.debug("this method will run with java9, 10, 11 and Linux or macOS."); } @Target(ElementType.METHOD) @@ -129,6 +144,6 @@ public class ConditionalAnnotationsUnitTest { @RepeatedTest(2) @CoinToss public void gamble() { - System.out.println("This tests run status is a gamble with %50 rate"); + LOGGER.debug("This tests run status is a gamble with %50 rate"); } } diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java index cd8b7b677d..fec2980b6f 100644 --- a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java @@ -3,11 +3,16 @@ package com.baeldung.junit5.templates; import org.junit.jupiter.api.extension.ConditionEvaluationResult; import org.junit.jupiter.api.extension.ExecutionCondition; import org.junit.jupiter.api.extension.ExtensionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Properties; public class DisabledOnQAEnvironmentExtension implements ExecutionCondition { + + private static final Logger LOGGER = LoggerFactory.getLogger(DisabledOnQAEnvironmentExtension.class); + @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { Properties properties = new Properties(); @@ -16,7 +21,7 @@ public class DisabledOnQAEnvironmentExtension implements ExecutionCondition { .getResourceAsStream("application.properties")); if ("qa".equalsIgnoreCase(properties.getProperty("env"))) { String reason = String.format("The test '%s' is disabled on QA environment", context.getDisplayName()); - System.out.println(reason); + LOGGER.debug(reason); return ConditionEvaluationResult.disabled(reason); } } catch (IOException e) { diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java index 277ec03f05..3e1aaaabd3 100644 --- a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java @@ -1,6 +1,15 @@ package com.baeldung.junit5.templates; -import org.junit.jupiter.api.extension.*; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.AfterTestExecutionCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.BeforeTestExecutionCallback; +import org.junit.jupiter.api.extension.Extension; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestTemplateInvocationContext; +import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; import java.util.stream.Stream; @@ -9,6 +18,8 @@ import static java.util.Arrays.asList; public class UserIdGeneratorTestInvocationContextProvider implements TestTemplateInvocationContextProvider { + private static final Logger LOGGER = LoggerFactory.getLogger(UserIdGeneratorTestInvocationContextProvider.class); + @Override public boolean supportsTestTemplate(ExtensionContext extensionContext) { return true; @@ -44,13 +55,13 @@ public class UserIdGeneratorTestInvocationContextProvider implements TestTemplat new BeforeTestExecutionCallback() { @Override public void beforeTestExecution(ExtensionContext extensionContext) { - System.out.println("BeforeTestExecutionCallback:Disabled context"); + LOGGER.debug("BeforeTestExecutionCallback:Disabled context"); } }, new AfterTestExecutionCallback() { @Override public void afterTestExecution(ExtensionContext extensionContext) { - System.out.println("AfterTestExecutionCallback:Disabled context"); + LOGGER.debug("AfterTestExecutionCallback:Disabled context"); } }); } @@ -72,13 +83,13 @@ public class UserIdGeneratorTestInvocationContextProvider implements TestTemplat new BeforeEachCallback() { @Override public void beforeEach(ExtensionContext extensionContext) { - System.out.println("BeforeEachCallback:Enabled context"); + LOGGER.debug("BeforeEachCallback:Enabled context"); } }, new AfterEachCallback() { @Override public void afterEach(ExtensionContext extensionContext) { - System.out.println("AfterEachCallback:Enabled context"); + LOGGER.debug("AfterEachCallback:Enabled context"); } }); } diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java index 86cd38824c..b95faa7874 100644 --- a/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java +++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java @@ -4,7 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BusinessWorker { - private static Logger LOGGER = LoggerFactory.getLogger(BusinessWorker.class); + private static final Logger LOGGER = LoggerFactory.getLogger(BusinessWorker.class); public void generateLogs(String msg) { LOGGER.trace(msg); From a257d47c6c96c101960fc1a920a4c1d3fd4a7390 Mon Sep 17 00:00:00 2001 From: Azhwani Date: Fri, 19 Nov 2021 12:48:29 +0100 Subject: [PATCH 210/551] + Remove junit versions to use those of the main pom --- testing-modules/junit-5/pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index 9b2518d10b..148abecb0f 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -137,10 +137,7 @@ - 5.8.1 2.23.0 - 1.8.1 - 5.8.1 2.8.2 2.0.0 2.22.0 From df330657088771c9dad8f07e5d917ae4e7ac0eeb Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 19 Nov 2021 21:25:17 +0800 Subject: [PATCH 211/551] Update README.md --- persistence-modules/java-mongodb/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/persistence-modules/java-mongodb/README.md b/persistence-modules/java-mongodb/README.md index b79cea6781..f632e7c662 100644 --- a/persistence-modules/java-mongodb/README.md +++ b/persistence-modules/java-mongodb/README.md @@ -10,5 +10,4 @@ This module contains articles about MongoDB in Java. - [Geospatial Support in MongoDB](https://www.baeldung.com/mongodb-geospatial-support) - [Introduction to Morphia – Java ODM for MongoDB](https://www.baeldung.com/mongodb-morphia) - [MongoDB Aggregations Using Java](https://www.baeldung.com/java-mongodb-aggregations) -- [MongoDB BSON to JSON](https://www.baeldung.com/bson-to-json) - [BSON to JSON Document Conversion in Java](https://www.baeldung.com/java-convert-bson-to-json) From 67887173601d011fc7ea729445653a8fc3565051 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Fri, 19 Nov 2021 17:11:47 +0200 Subject: [PATCH 212/551] BAEL-5112 delete moved code --- junit5/README.md | 6 --- junit5/pom.xml | 21 --------- .../java/com/baeldung/junit5/A_UnitTest.java | 21 --------- .../java/com/baeldung/junit5/B_UnitTest.java | 23 ---------- .../java/com/baeldung/junit5/C_UnitTest.java | 45 ------------------- .../test/resources/junit-platform.properties | 4 -- 6 files changed, 120 deletions(-) delete mode 100644 junit5/README.md delete mode 100644 junit5/pom.xml delete mode 100644 junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java delete mode 100644 junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java delete mode 100644 junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java delete mode 100644 junit5/src/test/resources/junit-platform.properties diff --git a/junit5/README.md b/junit5/README.md deleted file mode 100644 index ad16ad164d..0000000000 --- a/junit5/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## JUnit5 - -This module contains articles about the JUnit 5 - -### Relevant Articles: - diff --git a/junit5/pom.xml b/junit5/pom.xml deleted file mode 100644 index 00b04ea292..0000000000 --- a/junit5/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - 4.0.0 - junit5 - junit5 - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - 8 - 8 - - - \ No newline at end of file diff --git a/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java deleted file mode 100644 index e4ba59b22d..0000000000 --- a/junit5/src/test/java/com/baeldung/junit5/A_UnitTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.junit5; - -import org.junit.jupiter.api.Test; - -public class A_UnitTest { - - @Test - public void first() throws Exception{ - System.out.println("Test A first() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test A first() end => " + Thread.currentThread().getName()); - } - - @Test - public void second() throws Exception{ - System.out.println("Test A second() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test A second() end => " + Thread.currentThread().getName()); - } - -} diff --git a/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java deleted file mode 100644 index 2b195d2551..0000000000 --- a/junit5/src/test/java/com/baeldung/junit5/B_UnitTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.junit5; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; - -public class B_UnitTest { - - @Test - public void first() throws Exception{ - System.out.println("Test B first() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test B first() end => " + Thread.currentThread().getName()); - } - - @Test - public void second() throws Exception{ - System.out.println("Test B second() start => " + Thread.currentThread().getName()); - Thread.sleep(500); - System.out.println("Test B second() end => " + Thread.currentThread().getName()); - } - -} diff --git a/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java b/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java deleted file mode 100644 index ce545f6bee..0000000000 --- a/junit5/src/test/java/com/baeldung/junit5/C_UnitTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.baeldung.junit5; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.ResourceLock; - -import java.util.ArrayList; -import java.util.List; - -public class C_UnitTest { - - private List resources; - - @BeforeEach - void before() { - resources = new ArrayList<>(); - resources.add("test"); - } - - @AfterEach - void after() { - resources.clear(); - } - - @Test - @ResourceLock(value = "resources") - public void first() throws Exception { - System.out.println("Test C first() start => " + Thread.currentThread().getName()); - resources.add("first"); - System.out.println(resources); - Thread.sleep(500); - System.out.println("Test C first() end => " + Thread.currentThread().getName()); - } - - @Test - @ResourceLock(value = "resources") - public void second() throws Exception { - System.out.println("Test C second() start => " + Thread.currentThread().getName()); - resources.add("second"); - System.out.println(resources); - Thread.sleep(500); - System.out.println("Test C second() end => " + Thread.currentThread().getName()); - } -} diff --git a/junit5/src/test/resources/junit-platform.properties b/junit5/src/test/resources/junit-platform.properties deleted file mode 100644 index 42100f85da..0000000000 --- a/junit5/src/test/resources/junit-platform.properties +++ /dev/null @@ -1,4 +0,0 @@ -junit.jupiter.execution.parallel.enabled = true -junit.jupiter.execution.parallel.config.strategy=dynamic -junit.jupiter.execution.parallel.mode.default = concurrent -junit.jupiter.execution.parallel.mode.classes.default = concurrent From 3045e464ed0d69cbcbfcdc57483ff03b046f86c5 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Fri, 19 Nov 2021 17:13:36 +0200 Subject: [PATCH 213/551] BAEL-5112 delete moved code --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6d10dcb668..3bd5ba1180 100644 --- a/pom.xml +++ b/pom.xml @@ -473,7 +473,6 @@ json-path jsoup jta - junit5 kubernetes ksqldb From 848fa01e4723f7777914a4bdb07a00610f6286f4 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 19 Nov 2021 23:17:22 +0530 Subject: [PATCH 214/551] JAVA-3592: Upgrade h2 dependency in the main pom.xml --- libraries-data-db/pom.xml | 1 - pom.xml | 2 +- spring-boot-modules/spring-boot-angular/pom.xml | 1 - spring-boot-modules/spring-boot-data/pom.xml | 1 - .../spring-session/spring-session-jdbc/pom.xml | 1 - testing-modules/spring-testing-2/pom.xml | 1 - 6 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index 20119da8a2..c0f2848705 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -63,7 +63,6 @@ com.h2database h2 - ${h2.version} diff --git a/pom.xml b/pom.xml index 372bc5a9f3..6b1b29fb8e 100644 --- a/pom.xml +++ b/pom.xml @@ -1428,7 +1428,7 @@ 3.13.0 1.18.20 - 1.4.197 + 1.4.200 diff --git a/spring-boot-modules/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml index 89a8814d2f..443e7b2f88 100644 --- a/spring-boot-modules/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -32,7 +32,6 @@ com.h2database h2 - ${h2.version} runtime diff --git a/spring-boot-modules/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml index 447b730c02..46ca8639ed 100644 --- a/spring-boot-modules/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -36,7 +36,6 @@ com.h2database h2 - ${h2.version} org.springframework.boot diff --git a/spring-security-modules/spring-session/spring-session-jdbc/pom.xml b/spring-security-modules/spring-session/spring-session-jdbc/pom.xml index 64bbce44f2..3cc2b8d18e 100644 --- a/spring-security-modules/spring-session/spring-session-jdbc/pom.xml +++ b/spring-security-modules/spring-session/spring-session-jdbc/pom.xml @@ -28,7 +28,6 @@ com.h2database h2 - ${h2.version} runtime diff --git a/testing-modules/spring-testing-2/pom.xml b/testing-modules/spring-testing-2/pom.xml index f3e4f098b4..82a9ed9599 100644 --- a/testing-modules/spring-testing-2/pom.xml +++ b/testing-modules/spring-testing-2/pom.xml @@ -26,7 +26,6 @@ com.h2database h2 - ${h2.version} org.postgresql From 076727df8f76f3f0142c09507a877daba75f6917 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Fri, 19 Nov 2021 20:51:24 +0000 Subject: [PATCH 215/551] [JAVA-8335] Fix intermittent unit test failure --- .../java/com/baeldung/abaproblem/Account.java | 17 ++++---- .../baeldung/abaproblem/AccountUnitTest.java | 40 +++++++++++-------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/abaproblem/Account.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/abaproblem/Account.java index ee1bdcd55b..2af3113549 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/abaproblem/Account.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/abaproblem/Account.java @@ -3,17 +3,18 @@ package com.baeldung.abaproblem; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; + public class Account { - private AtomicInteger balance; - private AtomicInteger transactionCount; - private ThreadLocal currentThreadCASFailureCount; + private final AtomicInteger balance; + private final AtomicInteger transactionCount; + private final ThreadLocal currentThreadCASFailureCount; public Account() { this.balance = new AtomicInteger(0); this.transactionCount = new AtomicInteger(0); - this.currentThreadCASFailureCount = new ThreadLocal<>(); - this.currentThreadCASFailureCount.set(0); + this.currentThreadCASFailureCount = ThreadLocal.withInitial(() -> 0); } public int getBalance() { @@ -43,11 +44,7 @@ public class Account { private void maybeWait() { if ("thread1".equals(Thread.currentThread().getName())) { - try { - TimeUnit.SECONDS.sleep(2); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } + sleepUninterruptibly(2, TimeUnit.SECONDS); } } diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/abaproblem/AccountUnitTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/abaproblem/AccountUnitTest.java index aa5f0f7997..3e188d682e 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/abaproblem/AccountUnitTest.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/abaproblem/AccountUnitTest.java @@ -1,8 +1,13 @@ package com.baeldung.abaproblem; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -30,45 +35,39 @@ public class AccountUnitTest { assertTrue(account.deposit(moneyToDeposit)); assertEquals(moneyToDeposit, account.getBalance()); + assertEquals(1, account.getTransactionCount()); } @Test - public void withdrawTest() throws InterruptedException { + public void withdrawTest() { final int defaultBalance = 50; final int moneyToWithdraw = 20; account.deposit(defaultBalance); assertTrue(account.withdraw(moneyToWithdraw)); - assertEquals(defaultBalance - moneyToWithdraw, account.getBalance()); } @Test - public void abaProblemTest() throws InterruptedException { + public void abaProblemTest() throws Exception { final int defaultBalance = 50; final int amountToWithdrawByThread1 = 20; final int amountToWithdrawByThread2 = 10; final int amountToDepositByThread2 = 10; - assertEquals(0, account.getTransactionCount()); - assertEquals(0, account.getCurrentThreadCASFailureCount()); account.deposit(defaultBalance); - assertEquals(1, account.getTransactionCount()); - - Thread thread1 = new Thread(() -> { + Runnable thread1 = () -> { // this will take longer due to the name of the thread assertTrue(account.withdraw(amountToWithdrawByThread1)); // thread 1 fails to capture ABA problem assertNotEquals(1, account.getCurrentThreadCASFailureCount()); + }; - }, "thread1"); - - Thread thread2 = new Thread(() -> { - + Runnable thread2 = () -> { assertTrue(account.deposit(amountToDepositByThread2)); assertEquals(defaultBalance + amountToDepositByThread2, account.getBalance()); @@ -79,12 +78,13 @@ public class AccountUnitTest { assertEquals(defaultBalance, account.getBalance()); assertEquals(0, account.getCurrentThreadCASFailureCount()); - }, "thread2"); + }; - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); + Future future1 = getSingleThreadExecutorService("thread1").submit(thread1); + Future future2 = getSingleThreadExecutorService("thread2").submit(thread2); + + future1.get(); + future2.get(); // compareAndSet operation succeeds for thread 1 assertEquals(defaultBalance - amountToWithdrawByThread1, account.getBalance()); @@ -95,4 +95,10 @@ public class AccountUnitTest { // thread 2 did two modifications as well assertEquals(4, account.getTransactionCount()); } + + private static ExecutorService getSingleThreadExecutorService(String threadName) { + return Executors.newSingleThreadExecutor( + new ThreadFactoryBuilder().setNameFormat(threadName).build() + ); + } } From 686857c2518ddc7f59818a011c7a92161ff994e5 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Sat, 20 Nov 2021 09:45:50 +0530 Subject: [PATCH 216/551] JAVA-8435: reducing logging for tutorials-integration job --- .../r2dbc/src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../DatasourceProxyBeanPostProcessor.java | 5 +- .../src/main/resources/application.properties | 2 +- .../src/test/resources/logback-test.xml | 12 +++++ .../src/test/resources/logback-test.xml | 12 +++++ .../EnversFooBarAuditIntegrationTest.java | 37 +++++++++----- .../persistence/hibernate/FooFixtures.java | 39 +++++++++------ .../FooSortingPersistenceIntegrationTest.java | 49 ++++++++++++------- ...rentServicePersistenceIntegrationTest.java | 13 +++-- .../spring/config/PersistenceTestConfig.java | 2 +- .../query/UserRepositoryIntegrationTest.java | 25 ++++------ .../ArticleRepositoryIntegrationTest.java | 2 +- .../src/test/resources/fetching.cfg.xml | 2 +- .../src/test/resources/fetchingLazy.cfg.xml | 2 +- .../SpringDataAggregateIntegrationTest.java | 3 +- .../PassengerRepositoryIntegrationTest.java | 3 +- .../EntityGraphIntegrationTest.java | 2 +- .../exists/CarRepositoryIntegrationTest.java | 2 + .../joins/JpaJoinsIntegrationTest.java | 3 +- .../src/test/resources/logback-test.xml | 12 +++++ .../saveperformance/BookApplication.java | 10 ++-- .../src/test/resources/logback-test.xml | 12 +++++ .../InventoryRepositoryIntegrationTest.java | 2 +- .../daos/JpaRepositoriesIntegrationTest.java | 2 +- .../UserRepositoryIntegrationTest.java | 2 +- .../like/MovieRepositoryIntegrationTest.java | 2 +- .../FruitPopulatorIntegrationTest.java | 2 +- .../PassengerRepositoryIntegrationTest.java | 2 +- .../SongRepositoryIntegrationTest.java | 2 +- .../src/test/resources/logback-test.xml | 12 +++++ .../dynamicupdate/DynamicUpdateConfig.java | 2 +- .../immutable/util/HibernateUtil.java | 9 +++- .../manytomany/util/HibernateUtil.java | 16 +++--- .../manytomany/spring/PersistenceConfig.java | 2 +- .../baeldung/spring/PersistenceConfig.java | 2 +- .../src/main/resources/immutable.cfg.xml | 2 +- .../src/main/resources/manytomany.cfg.xml | 2 +- .../src/test/resources/manytomany.cfg.xml | 2 +- .../guide/EmployeeDAOIntegrationTest.java | 6 ++- .../src/test/resources/logback-test.xml | 12 +++++ .../main/resources/persistence-h2.properties | 2 +- .../src/test/resources/logback-test.xml | 12 +++++ .../test/resources/manytomany/test.properties | 2 +- .../main/resources/persistence-h2.properties | 2 +- .../persistence-student-h2.properties | 2 +- .../resources/persistence-student.properties | 2 +- .../src/test/java/META-INF/persistence.xml | 2 +- ...oPaginationPersistenceIntegrationTest.java | 6 ++- .../FooServiceSortingIntegrationTest.java | 22 +++++---- ...eSortingWitNullsManualIntegrationTest.java | 8 ++- .../resources/persistence-student.properties | 2 +- pom.xml | 6 +++ 53 files changed, 300 insertions(+), 122 deletions(-) create mode 100644 persistence-modules/r2dbc/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-boot-persistence-2/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-boot-persistence-mongodb/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-data-cassandra-reactive/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-data-jpa-query/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-data-jpa-repo-2/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-data-jpa-repo/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-jdbc/src/test/resources/logback-test.xml create mode 100644 persistence-modules/spring-jpa-2/src/test/resources/logback-test.xml diff --git a/persistence-modules/r2dbc/src/test/resources/logback-test.xml b/persistence-modules/r2dbc/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/r2dbc/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-2/src/test/resources/logback-test.xml b/persistence-modules/spring-boot-persistence-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java index c087427b65..1952a26f2f 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java @@ -1,10 +1,7 @@ package com.baeldung.h2db.lazy_load_no_trans.config; import net.ttddyy.dsproxy.listener.DataSourceQueryCountListener; -import net.ttddyy.dsproxy.listener.logging.CommonsQueryLoggingListener; -import net.ttddyy.dsproxy.listener.logging.DefaultQueryLogEntryCreator; import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; -import net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener; import net.ttddyy.dsproxy.support.ProxyDataSource; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.aopalliance.intercept.MethodInterceptor; @@ -49,7 +46,7 @@ public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor { this.dataSource = ProxyDataSourceBuilder.create(dataSource) .name("MyDS") .multiline() - .logQueryBySlf4j(SLF4JLogLevel.INFO) + .logQueryBySlf4j(SLF4JLogLevel.DEBUG) .listener(new DataSourceQueryCountListener()) .build(); } diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties index 134cda6628..2499d7cd06 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties @@ -4,7 +4,7 @@ spring.datasource.username=sa spring.datasource.password= spring.jpa.defer-datasource-initialization=true spring.jpa.hibernate.ddl-auto=create-drop -spring.jpa.show-sql=true +spring.jpa.show-sql=false spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.validator.apply_to_ddl=false #spring.jpa.properties.hibernate.check_nullability=true diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/test/resources/logback-test.xml b/persistence-modules/spring-boot-persistence-mongodb/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-cassandra-reactive/src/test/resources/logback-test.xml b/persistence-modules/spring-data-cassandra-reactive/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-data-cassandra-reactive/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java index 444324dafc..7397a61cac 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java @@ -123,24 +123,39 @@ public class EnversFooBarAuditIntegrationTest { assertNotNull(barRevisionList); assertEquals(4, barRevisionList.size()); - assertEquals("BAR", barRevisionList.get(0).getName()); - assertEquals("BAR", barRevisionList.get(1).getName()); - assertEquals("BAR1", barRevisionList.get(2).getName()); - assertEquals("BAR1", barRevisionList.get(3).getName()); + assertEquals("BAR", barRevisionList.get(0) + .getName()); + assertEquals("BAR", barRevisionList.get(1) + .getName()); + assertEquals("BAR1", barRevisionList.get(2) + .getName()); + assertEquals("BAR1", barRevisionList.get(3) + .getName()); - assertEquals(1, barRevisionList.get(0).getFooSet().size()); - assertEquals(2, barRevisionList.get(1).getFooSet().size()); - assertEquals(2, barRevisionList.get(2).getFooSet().size()); - assertEquals(3, barRevisionList.get(3).getFooSet().size()); + assertEquals(1, barRevisionList.get(0) + .getFooSet() + .size()); + assertEquals(2, barRevisionList.get(1) + .getFooSet() + .size()); + assertEquals(2, barRevisionList.get(2) + .getFooSet() + .size()); + assertEquals(3, barRevisionList.get(3) + .getFooSet() + .size()); // test Foo revisions fooRevisionList = fooService.getRevisions(); assertNotNull(fooRevisionList); assertEquals(3, fooRevisionList.size()); - assertEquals("FOO1", fooRevisionList.get(0).getName()); - assertEquals("FOO2", fooRevisionList.get(1).getName()); - assertEquals("FOO3", fooRevisionList.get(2).getName()); + assertEquals("FOO1", fooRevisionList.get(0) + .getName()); + assertEquals("FOO2", fooRevisionList.get(1) + .getName()); + assertEquals("FOO3", fooRevisionList.get(2) + .getName()); } } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java index da840dc027..e0bd8a4f98 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java @@ -10,8 +10,13 @@ import org.hibernate.SessionFactory; import org.hibernate.Transaction; import com.google.common.collect.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FooFixtures { + + private static final Logger LOGGER = LoggerFactory.getLogger(FooFixtures.class); + private SessionFactory sessionFactory; public FooFixtures(final SessionFactory sessionFactory) { @@ -36,26 +41,30 @@ public class FooFixtures { foo.setBar(bar); session.save(foo); final Foo foo2 = new Foo(null); - if (i % 2 == 0) + if (i % 2 == 0) { foo2.setName("LuckyFoo" + (i + 120)); + } foo2.setBar(bar); session.save(foo2); - bar.getFooSet().add(foo); - bar.getFooSet().add(foo2); + bar.getFooSet() + .add(foo); + bar.getFooSet() + .add(foo2); session.merge(bar); } tx.commit(); session.flush(); } catch (final HibernateException he) { - if (tx != null) + if (tx != null) { tx.rollback(); - System.out.println("Not able to open session"); - he.printStackTrace(); + } + LOGGER.error("Not able to open session", he); } catch (final Exception e) { - e.printStackTrace(); + LOGGER.error(e.getLocalizedMessage(), e); } finally { - if (session != null) + if (session != null) { session.close(); + } } } @@ -71,7 +80,8 @@ public class FooFixtures { final Foo foo = new Foo(); foo.setName("Foo_" + (i + 120)); final Bar bar = new Bar("bar_" + i); - bar.getFooSet().add(foo); + bar.getFooSet() + .add(foo); foo.setBar(bar); fooList.add(foo); @@ -86,15 +96,16 @@ public class FooFixtures { tx.commit(); session.flush(); } catch (final HibernateException he) { - if (tx != null) + if (tx != null) { tx.rollback(); - System.out.println("Not able to open session"); - he.printStackTrace(); + } + LOGGER.error("Not able to open session", he); } catch (final Exception e) { - e.printStackTrace(); + LOGGER.error(e.getLocalizedMessage(), e); } finally { - if (session != null) + if (session != null) { session.close(); + } } } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java index 8173088af0..fe73ddba3f 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java @@ -15,6 +15,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -29,6 +31,8 @@ import com.baeldung.spring.config.PersistenceTestConfig; @SuppressWarnings("unchecked") public class FooSortingPersistenceIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(FooSortingPersistenceIntegrationTest.class); + @Autowired private SessionFactory sessionFactory; @@ -46,7 +50,8 @@ public class FooSortingPersistenceIntegrationTest { @After public void after() { - session.getTransaction().commit(); + session.getTransaction() + .commit(); session.close(); } @@ -56,7 +61,7 @@ public class FooSortingPersistenceIntegrationTest { final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + LOGGER.debug("Name: {} , Id: {}", foo.getName(), foo.getId()); } } @@ -66,9 +71,10 @@ public class FooSortingPersistenceIntegrationTest { final Query query = session.createQuery(hql); final List fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); + assertNull(fooList.get(fooList.toArray().length - 1) + .getName()); for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + LOGGER.debug("Name: {}, Id: {}", foo.getName(), foo.getId()); } } @@ -77,9 +83,10 @@ public class FooSortingPersistenceIntegrationTest { final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; final Query query = session.createQuery(hql); final List fooList = query.list(); - assertNull(fooList.get(0).getName()); + assertNull(fooList.get(0) + .getName()); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); + LOGGER.debug("Name: {}", foo.getName()); } } @@ -90,7 +97,7 @@ public class FooSortingPersistenceIntegrationTest { final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + LOGGER.debug("Name: {}, Id: {}", foo.getName(), foo.getId()); } } @@ -100,7 +107,7 @@ public class FooSortingPersistenceIntegrationTest { final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + LOGGER.debug("Name: {}, Id: {}", foo.getName(), foo.getId()); } } @@ -110,7 +117,7 @@ public class FooSortingPersistenceIntegrationTest { final Query query = session.createQuery(hql); final List fooList = query.list(); for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + LOGGER.debug("Name: {}, Id: {}", foo.getName(), foo.getId()); } } @@ -120,7 +127,7 @@ public class FooSortingPersistenceIntegrationTest { criteria.addOrder(Order.asc("id")); final List fooList = criteria.list(); for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + LOGGER.debug("Id: {}, FirstName: {}", foo.getId(), foo.getName()); } } @@ -131,29 +138,33 @@ public class FooSortingPersistenceIntegrationTest { criteria.addOrder(Order.asc("id")); final List fooList = criteria.list(); for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + LOGGER.debug("Id: {}, FirstName: {}", foo.getId(), foo.getName()); } } @Test public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + criteria.addOrder(Order.asc("name") + .nulls(NullPrecedence.LAST)); final List fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); + assertNull(fooList.get(fooList.toArray().length - 1) + .getName()); for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + LOGGER.debug("Id: {}, FirstName: {}", foo.getId(), foo.getName()); } } @Test public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + criteria.addOrder(Order.desc("name") + .nulls(NullPrecedence.FIRST)); final List fooList = criteria.list(); - assertNull(fooList.get(0).getName()); + assertNull(fooList.get(0) + .getName()); for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + LOGGER.debug("Id: {}, FirstName: {}", foo.getId(), foo.getName()); } } @@ -164,9 +175,9 @@ public class FooSortingPersistenceIntegrationTest { final List barList = query.list(); for (final Bar bar : barList) { final Set fooSet = bar.getFooSet(); - System.out.println("Bar Id:" + bar.getId()); + LOGGER.debug("Bar Id:{}", bar.getId()); for (final Foo foo : fooSet) { - System.out.println("FooName:" + foo.getName()); + LOGGER.debug("FooName:{}", foo.getName()); } } } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java index 5a73e39ca2..8c766954ff 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -1,7 +1,10 @@ package com.baeldung.persistence.service; +import com.baeldung.persistence.hibernate.FooSortingPersistenceIntegrationTest; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; @@ -16,6 +19,8 @@ import com.baeldung.spring.config.PersistenceTestConfig; @ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) public class ParentServicePersistenceIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(ParentServicePersistenceIntegrationTest.class); + @Autowired private IParentService service; @@ -37,11 +42,11 @@ public class ParentServicePersistenceIntegrationTest { final Parent parentEntity = new Parent(childEntity); service.create(parentEntity); - System.out.println("Child = " + childService.findOne(childEntity.getId())); - System.out.println("Child - parent = " + childService.findOne(childEntity.getId()).getParent()); + LOGGER.debug("Child = {}", childService.findOne(childEntity.getId())); + LOGGER.debug("Child - parent = {}", childService.findOne(childEntity.getId()).getParent()); - System.out.println("Parent = " + service.findOne(parentEntity.getId())); - System.out.println("Parent - child = " + service.findOne(parentEntity.getId()).getChild()); + LOGGER.debug("Parent = {}", service.findOne(parentEntity.getId())); + LOGGER.debug("Parent - child = {}", service.findOne(parentEntity.getId()).getChild()); } @Test(expected = DataIntegrityViolationException.class) diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java index 34301741fe..c8f14c5563 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java @@ -166,7 +166,7 @@ public class PersistenceTestConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - hibernateProperties.setProperty("hibernate.show_sql", "true"); + hibernateProperties.setProperty("hibernate.show_sql", "false"); // hibernateProperties.setProperty("hibernate.format_sql", "true"); // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java index a9ab13feed..df07c74c5a 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java @@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @RunWith(SpringRunner.class) -@DataJpaTest(properties = "spring.sql.init.data-locations=classpath:insert_users.sql") +@DataJpaTest(properties = "spring.sql.init.data-locations=classpath:insert_users.sql", showSql = false) public class UserRepositoryIntegrationTest { @Autowired @@ -40,46 +40,42 @@ public class UserRepositoryIntegrationTest { @Test public void whenFindAllSortedByNameThenAllSorted() { List allUsersSortedByName = userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); - assertThat(allUsersSortedByName) - .extracting("name") + assertThat(allUsersSortedByName).extracting("name") .containsSequence("Bob", "Cindy", "John"); } @Test public void whenFindAllSortedByNameLengthThenException() { - assertThatThrownBy(() -> userRepository.findAll(Sort.by("LENGTH(name)"))) - .isInstanceOf(PropertyReferenceException.class); + assertThatThrownBy(() -> userRepository.findAll(Sort.by("LENGTH(name)"))).isInstanceOf(PropertyReferenceException.class); } @Test public void whenFindAllUsersSortedByNameThenAllSorted() { List allUsersSortedByName = userRepository.findAllUsers(Sort.by(Sort.Direction.ASC, "name")); - assertThat(allUsersSortedByName) - .extracting("name") + assertThat(allUsersSortedByName).extracting("name") .containsSequence("Bob", "Cindy", "John"); } @Test public void whenFindAllUsersSortedByNameLengthThenAllSorted() { List allUsersSortedByName = userRepository.findAllUsers(JpaSort.unsafe("LENGTH(name)")); - assertThat(allUsersSortedByName) - .extracting("name") + assertThat(allUsersSortedByName).extracting("name") .containsSequence("Bob", "John", "Cindy"); } @Test public void whenFindAllUsersWithPaginationThenPaginated() { Page page = userRepository.findAllUsersWithPagination(PageRequest.of(0, 1)); - assertThat(page.stream().map(User::getId)) - .hasSize(1) + assertThat(page.stream() + .map(User::getId)).hasSize(1) .containsOnly(1); } @Test public void whenFindAllUsersWithPaginationNativeThenPaginated() { Page page = userRepository.findAllUsersWithPaginationNative(PageRequest.of(1, 1)); - assertThat(page.stream().map(User::getId)) - .hasSize(1) + assertThat(page.stream() + .map(User::getId)).hasSize(1) .containsOnly(2); } @@ -126,8 +122,7 @@ public class UserRepositoryIntegrationTest { @Test public void whenFindUserByNameListThenAllFound() { List users = userRepository.findUserByNameList(Arrays.asList("Bob", "Cindy")); - assertThat(users) - .extracting("name") + assertThat(users).extracting("name") .containsOnly("Bob", "Cindy"); } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java index e00a340615..b97fbc5275 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) -@DataJpaTest(properties="spring.sql.init.data-locations=classpath:import_entities.sql") +@DataJpaTest(properties="spring.sql.init.data-locations=classpath:import_entities.sql", showSql = false) public class ArticleRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml index 55a3aeb51c..4d3ff2ae63 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml @@ -11,7 +11,7 @@ org.hibernate.dialect.H2Dialect update - true + false diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml index 8fcf578660..8a2bf593cb 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml @@ -11,7 +11,7 @@ org.hibernate.dialect.H2Dialect update - true + false diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/aggregation/SpringDataAggregateIntegrationTest.java b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/aggregation/SpringDataAggregateIntegrationTest.java index 779ade7a3f..a73ad949db 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/aggregation/SpringDataAggregateIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/aggregation/SpringDataAggregateIntegrationTest.java @@ -16,8 +16,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @RunWith(SpringRunner.class) -@DataJpaTest - +@DataJpaTest(showSql = false) @Sql(scripts = "/test-aggregation-data.sql") public class SpringDataAggregateIntegrationTest { diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java index f082350019..d80380854d 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java @@ -26,8 +26,7 @@ import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - -@DataJpaTest +@DataJpaTest(showSql = false) @RunWith(SpringRunner.class) public class PassengerRepositoryIntegrationTest { diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/entitygraph/EntityGraphIntegrationTest.java b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/entitygraph/EntityGraphIntegrationTest.java index 24880a5dff..b6bf51ac65 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/entitygraph/EntityGraphIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/entitygraph/EntityGraphIntegrationTest.java @@ -14,7 +14,7 @@ import com.baeldung.entitygraph.model.Item; import com.baeldung.entitygraph.repository.CharacteristicsRepository; import com.baeldung.entitygraph.repository.ItemRepository; -@DataJpaTest +@DataJpaTest(showSql = false) @RunWith(SpringRunner.class) @Sql(scripts = "/entitygraph-data.sql") public class EntityGraphIntegrationTest { diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java index d99f6671a3..c740fd7abd 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import java.util.Arrays; @@ -19,6 +20,7 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc @RunWith(SpringRunner.class) @SpringBootTest(classes = {Application.class}) +@TestPropertySource(properties = {"spring.jpa.show-sql=false"}) public class CarRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java index 9b0d23f3e4..e24b2ae4b7 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java @@ -13,10 +13,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@DataJpaTest +@DataJpaTest(showSql = false) @ActiveProfiles("joins") public class JpaJoinsIntegrationTest { diff --git a/persistence-modules/spring-data-jpa-query/src/test/resources/logback-test.xml b/persistence-modules/spring-data-jpa-query/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/saveperformance/BookApplication.java b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/saveperformance/BookApplication.java index 56ad918be3..46cb8d3453 100644 --- a/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/saveperformance/BookApplication.java +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/saveperformance/BookApplication.java @@ -1,5 +1,7 @@ package com.baeldung.spring.data.persistence.saveperformance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -12,6 +14,8 @@ import java.util.List; @SpringBootApplication public class BookApplication { + private static final Logger LOGGER = LoggerFactory.getLogger(BookApplication.class); + @Autowired private BookRepository bookRepository; @@ -25,13 +29,13 @@ public class BookApplication { int bookCount = 10000; long start = System.currentTimeMillis(); - for(int i = 0; i < bookCount; i++) { + for (int i = 0; i < bookCount; i++) { bookRepository.save(new Book("Book " + i, "Author " + i)); } long end = System.currentTimeMillis(); bookRepository.deleteAll(); - System.out.println("It took " + (end - start) + "ms to execute save() for " + bookCount + " books"); + LOGGER.debug("It took {}ms to execute save() for {} books.", (end - start), bookCount); List bookList = new ArrayList<>(); for (int i = 0; i < bookCount; i++) { @@ -42,7 +46,7 @@ public class BookApplication { bookRepository.saveAll(bookList); end = System.currentTimeMillis(); - System.out.println("It took " + (end - start) + "ms to execute saveAll() with " + bookCount + " books\n"); + LOGGER.debug("It took {}ms to execute saveAll() with {}} books.", (end - start), bookCount); } } diff --git a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/logback-test.xml b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java index e4bd3dabff..9201df8990 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java @@ -19,7 +19,7 @@ import com.baeldung.Application; import com.baeldung.boot.domain.MerchandiseEntity; @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) +@SpringBootTest(classes = Application.class, properties = {"spring.jpa.show-sql=false"}) public class InventoryRepositoryIntegrationTest { private static final String ORIGINAL_TITLE = "Pair of Pants"; diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java index fe02f79a56..34de77a2b3 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java @@ -21,7 +21,7 @@ import com.baeldung.boot.domain.Location; import com.baeldung.boot.domain.Store; @RunWith(SpringRunner.class) -@DataJpaTest(properties="spring.sql.init.data-locations=classpath:import_entities.sql") +@DataJpaTest(properties="spring.sql.init.data-locations=classpath:import_entities.sql", showSql = false) public class JpaRepositoriesIntegrationTest { @Autowired private LocationRepository locationRepository; diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java index 2a6e166b88..41c171e449 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java @@ -17,7 +17,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = QueryApplication.class) +@SpringBootTest(classes = QueryApplication.class, properties = {"spring.jpa.show-sql=false"}) public class UserRepositoryIntegrationTest { private static final String USER_NAME_ADAM = "Adam"; diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java index cc96b638ab..a4a1982df8 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java @@ -16,7 +16,7 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TES @RunWith(SpringRunner.class) @Sql(scripts = { "/test-movie-data.sql" }) -@SpringBootTest(classes = LikeApplication.class) +@SpringBootTest(classes = LikeApplication.class, properties = {"spring.jpa.show-sql=false"}) @Sql(scripts = "/test-movie-cleanup.sql", executionPhase = AFTER_TEST_METHOD) public class MovieRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java index 4d3661e717..d0b2ab8dd7 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java @@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.entity.Fruit; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(properties = {"spring.jpa.show-sql=false"}) public class FruitPopulatorIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/PassengerRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/PassengerRepositoryIntegrationTest.java index 37fcef7dab..fd06710084 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/PassengerRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/PassengerRepositoryIntegrationTest.java @@ -18,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.entity.Passenger; -@DataJpaTest +@DataJpaTest(showSql = false) @RunWith(SpringRunner.class) public class PassengerRepositoryIntegrationTest { diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java index 19362acd44..619b410f0d 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java @@ -16,7 +16,7 @@ import com.baeldung.entity.Song; import com.baeldung.repository.SongRepository; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(properties = {"spring.jpa.show-sql=false"}) @Sql(scripts = { "/test-song-data.sql" }) public class SongRepositoryIntegrationTest { diff --git a/persistence-modules/spring-data-jpa-repo/src/test/resources/logback-test.xml b/persistence-modules/spring-data-jpa-repo/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java index 4871a3d1e2..23e28a9e3b 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java +++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java @@ -74,7 +74,7 @@ public class DynamicUpdateConfig { Properties properties = new Properties(); properties.setProperty("hibernate.hbm2ddl.auto", Preconditions.checkNotNull(env.getProperty("hibernate.hbm2ddl.auto"))); properties.setProperty("hibernate.dialect", Preconditions.checkNotNull(env.getProperty("hibernate.dialect"))); - properties.setProperty("hibernate.show_sql", "true"); + properties.setProperty("hibernate.show_sql", "false"); return properties; } } \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java index 722f0251d1..25d7de4b07 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java +++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java @@ -6,8 +6,12 @@ import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HibernateUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class); private static final SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { @@ -17,10 +21,11 @@ public class HibernateUtil { configuration.addAnnotatedClass(Event.class); configuration.addAnnotatedClass(EventGeneratedId.class); configuration.configure("immutable.cfg.xml"); - ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); + ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) + .build(); return configuration.buildSessionFactory(serviceRegistry); } catch (Throwable ex) { - System.out.println("Initial SessionFactory creation failed." + ex); + LOGGER.debug("Initial SessionFactory creation failed.", ex); throw new ExceptionInInitializerError(ex); } } diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java index 5f489dd027..29e8d7515a 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java +++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/manytomany/util/HibernateUtil.java @@ -6,8 +6,12 @@ import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import com.baeldung.hibernate.manytomany.model.Employee; import com.baeldung.hibernate.manytomany.model.Project; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HibernateUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class); private static SessionFactory sessionFactory; private static SessionFactory buildSessionFactory() { @@ -17,25 +21,25 @@ public class HibernateUtil { configuration.addAnnotatedClass(Employee.class); configuration.addAnnotatedClass(Project.class); configuration.configure("manytomany.cfg.xml"); - System.out.println("Hibernate Annotation Configuration loaded"); + LOGGER.debug("Hibernate Annotation Configuration loaded"); ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) - .build(); - System.out.println("Hibernate Annotation serviceRegistry created"); + .build(); + LOGGER.debug("Hibernate Annotation serviceRegistry created"); SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; } catch (Throwable ex) { - System.err.println("Initial SessionFactory creation failed." + ex); - ex.printStackTrace(); + LOGGER.error("Initial SessionFactory creation failed.", ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { - if (sessionFactory == null) + if (sessionFactory == null) { sessionFactory = buildSessionFactory(); + } return sessionFactory; } } diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java index 44cbfadb25..b8e7e1b2fd 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java +++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/manytomany/spring/PersistenceConfig.java @@ -63,7 +63,7 @@ public class PersistenceConfig { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - hibernateProperties.setProperty("hibernate.show_sql", "true"); + hibernateProperties.setProperty("hibernate.show_sql", "false"); return hibernateProperties; } diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceConfig.java index 74ac0a269e..159d6e2e8e 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -71,7 +71,7 @@ public class PersistenceConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - hibernateProperties.setProperty("hibernate.show_sql", "true"); + hibernateProperties.setProperty("hibernate.show_sql", "false"); // Envers properties hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); diff --git a/persistence-modules/spring-hibernate-5/src/main/resources/immutable.cfg.xml b/persistence-modules/spring-hibernate-5/src/main/resources/immutable.cfg.xml index a572ebeac2..4e55b4632f 100644 --- a/persistence-modules/spring-hibernate-5/src/main/resources/immutable.cfg.xml +++ b/persistence-modules/spring-hibernate-5/src/main/resources/immutable.cfg.xml @@ -23,7 +23,7 @@ thread - true + false update diff --git a/persistence-modules/spring-hibernate-5/src/main/resources/manytomany.cfg.xml b/persistence-modules/spring-hibernate-5/src/main/resources/manytomany.cfg.xml index 3c753a89af..315e2e3118 100644 --- a/persistence-modules/spring-hibernate-5/src/main/resources/manytomany.cfg.xml +++ b/persistence-modules/spring-hibernate-5/src/main/resources/manytomany.cfg.xml @@ -10,6 +10,6 @@ tutorialuser org.hibernate.dialect.MySQLDialect thread - true + false diff --git a/persistence-modules/spring-hibernate-5/src/test/resources/manytomany.cfg.xml b/persistence-modules/spring-hibernate-5/src/test/resources/manytomany.cfg.xml index a7a23ec70d..2ca23d57d3 100644 --- a/persistence-modules/spring-hibernate-5/src/test/resources/manytomany.cfg.xml +++ b/persistence-modules/spring-hibernate-5/src/test/resources/manytomany.cfg.xml @@ -10,7 +10,7 @@ sa org.hibernate.dialect.H2Dialect thread - true + false create-drop diff --git a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java index c29d5c4534..b382895143 100644 --- a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java @@ -9,6 +9,8 @@ import com.baeldung.spring.jdbc.template.guide.config.SpringJdbcConfig; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.test.context.ContextConfiguration; @@ -19,6 +21,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @ContextConfiguration(classes = { SpringJdbcConfig.class }, loader = AnnotationConfigContextLoader.class) public class EmployeeDAOIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeDAOIntegrationTest.class); + @Autowired private EmployeeDAO employeeDao; @@ -70,7 +74,7 @@ public class EmployeeDAOIntegrationTest { try { employeeDao.addEmplyee(7); } catch (final DuplicateKeyException e) { - System.out.println(e.getMessage()); + LOGGER.error(e.getMessage(), e); Assert.assertTrue(e.getMessage().contains("Custome Exception translator - Integrity contraint voilation.")); } } diff --git a/persistence-modules/spring-jdbc/src/test/resources/logback-test.xml b/persistence-modules/spring-jdbc/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/src/main/resources/persistence-h2.properties b/persistence-modules/spring-jpa-2/src/main/resources/persistence-h2.properties index 716a96fde3..b429ce3a16 100644 --- a/persistence-modules/spring-jpa-2/src/main/resources/persistence-h2.properties +++ b/persistence-modules/spring-jpa-2/src/main/resources/persistence-h2.properties @@ -6,7 +6,7 @@ jdbc.pass= # hibernate.X hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=true diff --git a/persistence-modules/spring-jpa-2/src/test/resources/logback-test.xml b/persistence-modules/spring-jpa-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8d4771e308 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/src/test/resources/manytomany/test.properties b/persistence-modules/spring-jpa-2/src/test/resources/manytomany/test.properties index 9e4236a6c2..db92a1b8c1 100644 --- a/persistence-modules/spring-jpa-2/src/test/resources/manytomany/test.properties +++ b/persistence-modules/spring-jpa-2/src/test/resources/manytomany/test.properties @@ -2,5 +2,5 @@ jdbc.driverClassName=org.h2.Driver jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1 hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=validate diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties b/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties index a3060cc796..72b51f02b7 100644 --- a/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties +++ b/persistence-modules/spring-jpa/src/main/resources/persistence-h2.properties @@ -6,5 +6,5 @@ jdbc.pass= # hibernate.X hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop \ No newline at end of file diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence-student-h2.properties b/persistence-modules/spring-jpa/src/main/resources/persistence-student-h2.properties index 405e6ff109..a5d2bec189 100644 --- a/persistence-modules/spring-jpa/src/main/resources/persistence-student-h2.properties +++ b/persistence-modules/spring-jpa/src/main/resources/persistence-student-h2.properties @@ -6,7 +6,7 @@ jdbc.pass= # hibernate.X hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.cache.use_second_level_cache=false hibernate.cache.use_query_cache=false \ No newline at end of file diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence-student.properties b/persistence-modules/spring-jpa/src/main/resources/persistence-student.properties index d4c82420de..9a06518238 100644 --- a/persistence-modules/spring-jpa/src/main/resources/persistence-student.properties +++ b/persistence-modules/spring-jpa/src/main/resources/persistence-student.properties @@ -4,7 +4,7 @@ jdbc.user=tutorialuser jdbc.pass=tutorialpass hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop hibernate.cache.use_second_level_cache=false diff --git a/persistence-modules/spring-jpa/src/test/java/META-INF/persistence.xml b/persistence-modules/spring-jpa/src/test/java/META-INF/persistence.xml index 495f076fef..76a3b61399 100644 --- a/persistence-modules/spring-jpa/src/test/java/META-INF/persistence.xml +++ b/persistence-modules/spring-jpa/src/test/java/META-INF/persistence.xml @@ -11,7 +11,7 @@ - + diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java index fbda459d65..66f20a6724 100644 --- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java +++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java @@ -20,6 +20,8 @@ import com.baeldung.persistence.model.Foo; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -31,6 +33,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @DirtiesContext public class FooPaginationPersistenceIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(FooPaginationPersistenceIntegrationTest.class); + @PersistenceContext private EntityManager entityManager; @@ -137,7 +141,7 @@ public class FooPaginationPersistenceIntegrationTest { typedQuery = entityManager.createQuery(select); typedQuery.setFirstResult(pageNumber - 1); typedQuery.setMaxResults(pageSize); - System.out.println("Current page: " + typedQuery.getResultList()); + LOGGER.debug("Current page: {}", typedQuery.getResultList()); pageNumber += pageSize; } diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java index c3db45ab41..8d1f94edf8 100644 --- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java +++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java @@ -15,6 +15,8 @@ import com.baeldung.persistence.model.Bar; import com.baeldung.persistence.model.Foo; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -26,6 +28,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @SuppressWarnings("unchecked") public class FooServiceSortingIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(FooServiceSortingIntegrationTest.class); + @PersistenceContext private EntityManager entityManager; @@ -37,7 +41,7 @@ public class FooServiceSortingIntegrationTest { final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + LOGGER.debug("Name:{}-------Id:{}", foo.getName(), foo.getId()); } } @@ -47,7 +51,7 @@ public class FooServiceSortingIntegrationTest { final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + LOGGER.debug("Name:{}-------Id:{}", foo.getName(), foo.getId()); } } @@ -57,7 +61,7 @@ public class FooServiceSortingIntegrationTest { final Query sortQuery = entityManager.createQuery(jql); final List fooList = sortQuery.getResultList(); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + LOGGER.debug("Name:{}-------Id:{}", foo.getName(), foo.getId()); } } @@ -67,9 +71,9 @@ public class FooServiceSortingIntegrationTest { final Query barJoinQuery = entityManager.createQuery(jql); final List fooList = barJoinQuery.getResultList(); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); + LOGGER.debug("Name:{}", foo.getName()); if (foo.getBar() != null) { - System.out.print("-------BarId:" + foo.getBar().getId()); + LOGGER.debug("-------BarId:{}", foo.getBar().getId()); } } } @@ -80,9 +84,9 @@ public class FooServiceSortingIntegrationTest { final Query barQuery = entityManager.createQuery(jql); final List barList = barQuery.getResultList(); for (final Bar bar : barList) { - System.out.println("Bar Id:" + bar.getId()); + LOGGER.debug("Bar Id:{}", bar.getId()); for (final Foo foo : bar.getFooList()) { - System.out.println("FooName:" + foo.getName()); + LOGGER.debug("FooName:{}", foo.getName()); } } } @@ -97,7 +101,7 @@ public class FooServiceSortingIntegrationTest { final TypedQuery typedQuery = entityManager.createQuery(select); final List fooList = typedQuery.getResultList(); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "--------Id:" + foo.getId()); + LOGGER.debug("Name:{}-------Id:{}", foo.getName(), foo.getId()); } } @@ -111,7 +115,7 @@ public class FooServiceSortingIntegrationTest { final TypedQuery typedQuery = entityManager.createQuery(select); final List fooList = typedQuery.getResultList(); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + LOGGER.debug("Name:{}-------Id:{}", foo.getName(), foo.getId()); } } diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java index 103321fc64..b19259d9df 100644 --- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java +++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java @@ -13,6 +13,8 @@ import com.baeldung.config.PersistenceJPAConfig; import com.baeldung.persistence.model.Foo; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -24,6 +26,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @DirtiesContext public class FooServiceSortingWitNullsManualIntegrationTest { + private static final Logger LOGGER = LoggerFactory.getLogger(FooServiceSortingWitNullsManualIntegrationTest.class); + @PersistenceContext private EntityManager entityManager; @@ -43,7 +47,7 @@ public class FooServiceSortingWitNullsManualIntegrationTest { final List fooList = sortQuery.getResultList(); assertNull(fooList.get(fooList.toArray().length - 1).getName()); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); + LOGGER.debug("Name:{}", foo.getName()); } } @@ -57,7 +61,7 @@ public class FooServiceSortingWitNullsManualIntegrationTest { final List fooList = sortQuery.getResultList(); assertNull(fooList.get(0).getName()); for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); + LOGGER.debug("Name:{}", foo.getName()); } } diff --git a/persistence-modules/spring-jpa/src/test/resources/persistence-student.properties b/persistence-modules/spring-jpa/src/test/resources/persistence-student.properties index 3b6b580630..9ca389d6ab 100644 --- a/persistence-modules/spring-jpa/src/test/resources/persistence-student.properties +++ b/persistence-modules/spring-jpa/src/test/resources/persistence-student.properties @@ -2,7 +2,7 @@ jdbc.driverClassName=org.h2.Driver jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1 hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true +hibernate.show_sql=false hibernate.hbm2ddl.auto=create hibernate.cache.use_second_level_cache=false diff --git a/pom.xml b/pom.xml index 6d10dcb668..e18e571372 100644 --- a/pom.xml +++ b/pom.xml @@ -790,6 +790,9 @@ **/*IntegrationTest.java **/*IntTest.java + + ${tutorialsproject.basedir}/logback-config.xml + @@ -1047,6 +1050,9 @@ **/*IntegrationTest.java **/*IntTest.java + + ${tutorialsproject.basedir}/logback-config.xml + From ef2f20f277982a146d38c354ada8c31ecb4f736e Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 20 Nov 2021 13:17:25 +0530 Subject: [PATCH 217/551] explicit h2 version for hibernate-mapping --- persistence-modules/hibernate-mapping/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index 805402951e..e837f57d8f 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -75,6 +75,7 @@ + 1.4.197 5.4.12.Final 2.10.4 3.8.0 From 51a8facd75cade0d1c0ae1960c1d31fe727cf5df Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 20 Nov 2021 14:00:47 +0530 Subject: [PATCH 218/551] JAVA-8398: Align module names, folder names and artifact id --- persistence-modules/spring-data-cassandra-2/pom.xml | 4 ++-- .../custom-validations-opeanpi-codegen/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-data-cassandra-2/pom.xml b/persistence-modules/spring-data-cassandra-2/pom.xml index 8202471d19..1e6412dc17 100644 --- a/persistence-modules/spring-data-cassandra-2/pom.xml +++ b/persistence-modules/spring-data-cassandra-2/pom.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.baeldung - spring-cassandra + spring-data-cassandra-2 0.0.1-SNAPSHOT - spring-cassandra + spring-data-cassandra-2 Demo project for Spring Data Cassandra diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml b/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml index 53e5006bf4..70b9e2acd5 100644 --- a/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml @@ -9,9 +9,9 @@ com.example - petstore + custom-validations-opeanpi-codegen 0.0.1-SNAPSHOT - petstore + custom-validations-opeanpi-codegen Demo project for Swagger Custom Validations Codegen 11 From ae26c0c61a583f01c899ab8eeeda3e368bca585f Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Sat, 20 Nov 2021 17:23:33 +0530 Subject: [PATCH 219/551] JAVA-7832: spring-cloud-config bootstrap.properties need to change to application.properties/yml --- .../client/src/main/resources/application.properties | 3 +++ .../client/src/main/resources/bootstrap.properties | 6 ------ .../server/src/main/resources/application.properties | 5 +++++ .../server/src/main/resources/bootstrap.properties | 4 ---- 4 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 spring-cloud/spring-cloud-config/client/src/main/resources/application.properties delete mode 100644 spring-cloud/spring-cloud-config/client/src/main/resources/bootstrap.properties delete mode 100644 spring-cloud/spring-cloud-config/server/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties b/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties new file mode 100644 index 0000000000..6366bc515c --- /dev/null +++ b/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.application.name=config-client +spring.profiles.active=development +spring.config.import=optional:configserver:http://root:s3cr3t@localhost:8888 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-config/client/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-config/client/src/main/resources/bootstrap.properties deleted file mode 100644 index 5dde8baa28..0000000000 --- a/spring-cloud/spring-cloud-config/client/src/main/resources/bootstrap.properties +++ /dev/null @@ -1,6 +0,0 @@ -spring.application.name=config-client -spring.profiles.active=development -spring.cloud.config.uri=http://localhost:8888 -spring.cloud.config.username=root -spring.cloud.config.password=s3cr3t -spring.cloud.config.fail-fast=true diff --git a/spring-cloud/spring-cloud-config/server/src/main/resources/application.properties b/spring-cloud/spring-cloud-config/server/src/main/resources/application.properties index 18d4b3596a..366ecddf86 100644 --- a/spring-cloud/spring-cloud-config/server/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-config/server/src/main/resources/application.properties @@ -3,3 +3,8 @@ spring.cloud.config.server.git.uri= spring.cloud.config.server.git.clone-on-start=true spring.security.user.name=root spring.security.user.password=s3cr3t + +encrypt.keyStore.location=classpath:/config-server.jks +encrypt.keyStore.password=my-s70r3-s3cr3t +encrypt.keyStore.alias=config-server-key +encrypt.keyStore.secret=my-k34-s3cr3t diff --git a/spring-cloud/spring-cloud-config/server/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-config/server/src/main/resources/bootstrap.properties deleted file mode 100644 index f2d75f5846..0000000000 --- a/spring-cloud/spring-cloud-config/server/src/main/resources/bootstrap.properties +++ /dev/null @@ -1,4 +0,0 @@ -encrypt.keyStore.location=classpath:/config-server.jks -encrypt.keyStore.password=my-s70r3-s3cr3t -encrypt.keyStore.alias=config-server-key -encrypt.keyStore.secret=my-k34-s3cr3t From 13348bab48d74ab9926003dd228c5f700577384c Mon Sep 17 00:00:00 2001 From: makapszenna <66560584+makapszenna@users.noreply.github.com> Date: Sat, 20 Nov 2021 16:57:51 +0100 Subject: [PATCH 220/551] BAEL-5135 ommiting one setter/getter in Lombok (#11386) Co-authored-by: Adrianna Zychewicz --- .../baeldung/lombok/exclusions/Employee.java | 18 ++++++++++++++++++ .../com/baeldung/lombok/exclusions/User.java | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 lombok/src/main/java/com/baeldung/lombok/exclusions/Employee.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/exclusions/User.java diff --git a/lombok/src/main/java/com/baeldung/lombok/exclusions/Employee.java b/lombok/src/main/java/com/baeldung/lombok/exclusions/Employee.java new file mode 100644 index 0000000000..60625747a5 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/exclusions/Employee.java @@ -0,0 +1,18 @@ +package com.baeldung.lombok.exclusions; + +import lombok.AccessLevel; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +@Data +public class Employee { + + @Setter(AccessLevel.NONE) + private String name; + + private String workplace; + + @Getter(AccessLevel.NONE) + private int workLength; +} diff --git a/lombok/src/main/java/com/baeldung/lombok/exclusions/User.java b/lombok/src/main/java/com/baeldung/lombok/exclusions/User.java new file mode 100644 index 0000000000..52ebeab532 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/exclusions/User.java @@ -0,0 +1,16 @@ +package com.baeldung.lombok.exclusions; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; + +public class User { + + @Setter(AccessLevel.NONE) + private long id; + + private String login; + + @Getter(AccessLevel.NONE) + private int age; +} From 388d2124d8cb9faedf8db81652c29e688b66a520 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Sat, 20 Nov 2021 22:30:23 +0000 Subject: [PATCH 221/551] [JAVA-8592] Fix email service live test --- .../MailWithAttachmentService.java | 56 ++++++------ .../src/main/resources/attachment2.txt | 1 + .../MailWithAttachmentServiceLiveTest.java | 87 ++++++++++++------- 3 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 core-java-modules/core-java-networking-2/src/main/resources/attachment2.txt diff --git a/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java index 7d4dc57f10..fbe8a54bbe 100644 --- a/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java +++ b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java @@ -1,8 +1,5 @@ package com.baeldung.mail.mailwithattachment; -import java.io.File; -import java.io.IOException; -import java.util.Properties; import javax.mail.BodyPart; import javax.mail.Message; import javax.mail.MessagingException; @@ -10,23 +7,23 @@ import javax.mail.Multipart; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; -import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.Properties; public class MailWithAttachmentService { - private String username = ""; - private String password = ""; - private String host = ""; - private String port = ""; + private final String username; + private final String password; + private final String host; + private final int port; - MailWithAttachmentService() { - } - - MailWithAttachmentService(String username, String password, String host, String port) { + MailWithAttachmentService(String username, String password, String host, int port) { this.username = username; this.password = password; this.host = host; @@ -40,15 +37,14 @@ public class MailWithAttachmentService { props.put("mail.smtp.host", this.host); props.put("mail.smtp.port", this.port); - Session session = Session.getInstance(props, new javax.mail.Authenticator() { + return Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); - return session; } - public Message createMail(Session session) throws AddressException, MessagingException, IOException { + public void sendMail(Session session) throws MessagingException, IOException { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("mail@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("mail@gmail.com")); @@ -61,23 +57,27 @@ public class MailWithAttachmentService { multipart.addBodyPart(messageBodyPart); MimeBodyPart attachmentPart = new MimeBodyPart(); - MimeBodyPart attachmentPart2 = new MimeBodyPart(); - - attachmentPart.attachFile(new File("C:\\Document1.txt")); - attachmentPart2.attachFile(new File("C:\\Document2.txt")); - + attachmentPart.attachFile(getFile("attachment.txt")); multipart.addBodyPart(attachmentPart); + + MimeBodyPart attachmentPart2 = new MimeBodyPart(); + attachmentPart2.attachFile(getFile("attachment2.txt")); multipart.addBodyPart(attachmentPart2); message.setContent(multipart); - - return message; - } - - public void sendMail(Session session) throws MessagingException, IOException { - - Message message = createMail(session); Transport.send(message); } -} \ No newline at end of file + private File getFile(String filename) { + try { + URI uri = this.getClass() + .getClassLoader() + .getResource(filename) + .toURI(); + return new File(uri); + } catch (Exception e) { + throw new IllegalArgumentException("Unable to find file from resources: " + filename); + } + } + +} diff --git a/core-java-modules/core-java-networking-2/src/main/resources/attachment2.txt b/core-java-modules/core-java-networking-2/src/main/resources/attachment2.txt new file mode 100644 index 0000000000..14c8ea9ff9 --- /dev/null +++ b/core-java-modules/core-java-networking-2/src/main/resources/attachment2.txt @@ -0,0 +1 @@ +sample attachment content 2 \ No newline at end of file diff --git a/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java b/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java index ef82657ab5..04ad47875f 100644 --- a/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java +++ b/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java @@ -1,48 +1,77 @@ package com.baeldung.mail.mailwithattachment; -import static org.junit.Assert.*; -import javax.annotation.Resource; -import javax.mail.Session; - -import org.junit.After; +import com.icegreen.greenmail.configuration.GreenMailConfiguration; +import com.icegreen.greenmail.junit.GreenMailRule; +import com.icegreen.greenmail.util.GreenMailUtil; +import com.icegreen.greenmail.util.ServerSetupTest; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -import com.baeldung.mail.mailwithattachment.MailWithAttachmentService; -import com.icegreen.greenmail.util.GreenMail; -import com.icegreen.greenmail.util.ServerSetupTest; +import javax.annotation.Resource; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + +import static org.junit.Assert.assertEquals; public class MailWithAttachmentServiceLiveTest { + private static final String USERNAME = "testUser"; + private static final String PASSWORD = "password"; + private static final String HOSTNAME = "localhost"; + + @Rule + public final GreenMailRule greenMail = new GreenMailRule(ServerSetupTest.SMTP) + .withConfiguration( + GreenMailConfiguration.aConfig() + .withUser(USERNAME, PASSWORD) + ); + @Resource private MailWithAttachmentService emailService; - private GreenMail greenMail; @Before - public void startMailServer() { - emailService = new MailWithAttachmentService(); - greenMail = new GreenMail(ServerSetupTest.SMTP); - greenMail.start(); - } - - @After - public void stopMailServer() { - greenMail.stop(); - emailService = null; + public void setup() { + emailService = new MailWithAttachmentService( + USERNAME, PASSWORD, HOSTNAME, greenMail.getSmtp().getPort() + ); } @Test - public void canSendMail() { - try { - Session testSession = greenMail.getSmtp() - .createSession(); - emailService.sendMail(testSession); - assertEquals(1, greenMail.getReceivedMessages().length); - - } catch (Exception e) { - e.printStackTrace(); - } + public void givenEmailService_whenMessageSentWithAttachments_thenMessageIsReceived() throws Exception { + Session tlsSession = emailService.getSession(); + emailService.sendMail(tlsSession); + + MimeMessage[] receivedMessages = greenMail.getReceivedMessages(); + assertEquals(1, receivedMessages.length); + + MimeMessage receivedMessage = receivedMessages[0]; + assertEquals("Testing Subject", subjectFrom(receivedMessage)); + assertEquals("This is message body", emailTextFrom(receivedMessage)); + assertEquals("sample attachment content", attachment1ContentsFrom(receivedMessage)); + assertEquals("sample attachment content 2", attachment2ContentsFrom(receivedMessage)); + } + + private static String subjectFrom(MimeMessage receivedMessage) throws MessagingException { + return receivedMessage.getSubject(); + } + + private static String emailTextFrom(MimeMessage receivedMessage) throws Exception { + return GreenMailUtil.getBody(((MimeMultipart) receivedMessage.getContent()) + .getBodyPart(0)); + } + + private static String attachment1ContentsFrom(MimeMessage receivedMessage) throws Exception { + return GreenMailUtil.getBody(((MimeMultipart) receivedMessage.getContent()) + .getBodyPart(1)); + } + + private static String attachment2ContentsFrom(MimeMessage receivedMessage) throws Exception { + return GreenMailUtil.getBody(((MimeMultipart) receivedMessage.getContent()) + .getBodyPart(2)); } } From 156dc8cb2cc24c3837ad4dfe14d0ccd9081c8c1a Mon Sep 17 00:00:00 2001 From: Carlos Cavero Date: Sun, 21 Nov 2021 05:19:03 +0100 Subject: [PATCH 222/551] Add val and var examples, unit tests and include flagUsage in lombok.config (#11419) --- .../baeldung/lombok/valvar/ValExample.java | 45 ++++++++++++++++++ .../baeldung/lombok/valvar/VarExample.java | 47 +++++++++++++++++++ .../com/baeldung/lombok/valvar/lombok.config | 2 + .../lombok/valvar/ValExampleUnitTest.java | 24 ++++++++++ .../lombok/valvar/VarExampleUnitTest.java | 20 ++++++++ 5 files changed, 138 insertions(+) create mode 100644 lombok/src/main/java/com/baeldung/lombok/valvar/ValExample.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/valvar/VarExample.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/valvar/lombok.config create mode 100644 lombok/src/test/java/com/baeldung/lombok/valvar/ValExampleUnitTest.java create mode 100644 lombok/src/test/java/com/baeldung/lombok/valvar/VarExampleUnitTest.java diff --git a/lombok/src/main/java/com/baeldung/lombok/valvar/ValExample.java b/lombok/src/main/java/com/baeldung/lombok/valvar/ValExample.java new file mode 100644 index 0000000000..b7ecd95fa8 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/valvar/ValExample.java @@ -0,0 +1,45 @@ +package com.baeldung.lombok.valvar; + +import lombok.val; +import lombok.var; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +public class ValExample { + public Class name() { + val name = "name"; + System.out.println("Name: " + name); + return name.getClass(); + } + + public Class age() { + val age = Integer.valueOf(30); + System.out.println("Age: " + age); + return age.getClass(); + } + + public Class listOf() { + val agenda = new ArrayList(); + agenda.add("Day 1"); + System.out.println("Agenda: " + agenda); + return agenda.getClass(); + } + + public Class mapOf() { + val books = new HashMap(); + books.put(1, "Book 1"); + books.put(2, "Book 2"); + System.out.println("Books:"); + for (val entry : books.entrySet()) { + System.out.printf("- %d. %s\n", entry.getKey(), entry.getValue()); + } + return books.getClass(); + } + + public Class compoundTypes(boolean isArray) { + val compound = isArray ? new ArrayList() : new HashSet(); + return compound.getClass(); + } +} diff --git a/lombok/src/main/java/com/baeldung/lombok/valvar/VarExample.java b/lombok/src/main/java/com/baeldung/lombok/valvar/VarExample.java new file mode 100644 index 0000000000..6fabf66590 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/valvar/VarExample.java @@ -0,0 +1,47 @@ +package com.baeldung.lombok.valvar; + +import lombok.var; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class VarExample { + public String name() { + var name = "name"; + name = "newName"; + System.out.println("Name: " + name); + return name; + } + + public Integer age() { + var age = Integer.valueOf(30); + age = 35; + System.out.println("Age: " + age); + return age; + } + + public ArrayList listOf() { + var agenda = new ArrayList(); + agenda.add("Day 1"); + agenda = new ArrayList(Arrays.asList("Day 2")); + System.out.println("Agenda: " + agenda); + return agenda; + } + + public Map mapOf() { + var books = new HashMap(); + books.put(1, "Book 1"); + books.put(2, "Book 2"); + books = new HashMap(); + books.put(3, "Book 3"); + books.put(4, "Book 4"); + + System.out.println("Books:"); + for (var entry : books.entrySet()) { + System.out.printf("- %d. %s\n", entry.getKey(), entry.getValue()); + } + return books; + } +} diff --git a/lombok/src/main/java/com/baeldung/lombok/valvar/lombok.config b/lombok/src/main/java/com/baeldung/lombok/valvar/lombok.config new file mode 100644 index 0000000000..be6d5d3694 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/valvar/lombok.config @@ -0,0 +1,2 @@ +lombok.var.flagUsage = warning +lombok.val.flagUsage = warning \ No newline at end of file diff --git a/lombok/src/test/java/com/baeldung/lombok/valvar/ValExampleUnitTest.java b/lombok/src/test/java/com/baeldung/lombok/valvar/ValExampleUnitTest.java new file mode 100644 index 0000000000..b8e1102e18 --- /dev/null +++ b/lombok/src/test/java/com/baeldung/lombok/valvar/ValExampleUnitTest.java @@ -0,0 +1,24 @@ +package com.baeldung.lombok.valvar; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; + +class ValExampleUnitTest { + + @Test + void whenUsingValWithString_thenTheAssignedClassIsCorrect() { + ValExample val = new ValExample(); + assertThat(val.name()).isEqualTo(String.class); + assertThat(val.age()).isEqualTo(Integer.class); + assertThat(val.listOf()).isEqualTo(ArrayList.class); + assertThat(val.mapOf()).isEqualTo(HashMap.class); + assertThat(val.compoundTypes(true)).isEqualTo(ArrayList.class); + assertThat(val.compoundTypes(false)).isEqualTo(HashSet.class); + } + +} \ No newline at end of file diff --git a/lombok/src/test/java/com/baeldung/lombok/valvar/VarExampleUnitTest.java b/lombok/src/test/java/com/baeldung/lombok/valvar/VarExampleUnitTest.java new file mode 100644 index 0000000000..de6f76f8bb --- /dev/null +++ b/lombok/src/test/java/com/baeldung/lombok/valvar/VarExampleUnitTest.java @@ -0,0 +1,20 @@ +package com.baeldung.lombok.valvar; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; + +import static org.assertj.core.api.Assertions.assertThat; + +class VarExampleUnitTest { + + @Test + void whenUsingVarWithString_thenTheAssignedClassIsCorrect() { + VarExample varExample = new VarExample(); + assertThat(varExample.name()).isEqualTo("newName"); + assertThat(varExample.age()).isEqualTo(35); + assertThat("Day 2").isIn(varExample.listOf()); + assertThat(varExample.mapOf()).containsValue("Book 3"); + } + +} \ No newline at end of file From e502fdcbf1854001b111f9a501c45c3684ba2a30 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 21 Nov 2021 13:32:09 +0530 Subject: [PATCH 223/551] explicit h2 version for spring-data-eclipselink and core-java-lang-oop-modifiers --- core-java-modules/core-java-lang-oop-modifiers/pom.xml | 1 + persistence-modules/spring-data-eclipselink/pom.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/core-java-modules/core-java-lang-oop-modifiers/pom.xml b/core-java-modules/core-java-lang-oop-modifiers/pom.xml index 70c70608eb..3cdcc3a481 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/pom.xml +++ b/core-java-modules/core-java-lang-oop-modifiers/pom.xml @@ -30,6 +30,7 @@ 3.10.0 + 1.4.197 \ No newline at end of file diff --git a/persistence-modules/spring-data-eclipselink/pom.xml b/persistence-modules/spring-data-eclipselink/pom.xml index a344d64864..561d144fe3 100644 --- a/persistence-modules/spring-data-eclipselink/pom.xml +++ b/persistence-modules/spring-data-eclipselink/pom.xml @@ -66,6 +66,7 @@ 1.5.9.RELEASE 2.7.0 + 1.4.197 \ No newline at end of file From d9b23200d1f073a2c67e68abd26e6a044e272297 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 21 Nov 2021 17:58:26 +0530 Subject: [PATCH 224/551] removed explicit h2.version as parent now is at the required 1.4.200 --- libraries-testing/pom.xml | 1 - persistence-modules/core-java-persistence-2/pom.xml | 1 - persistence-modules/core-java-persistence/pom.xml | 1 - persistence-modules/hibernate-annotations/pom.xml | 1 - persistence-modules/jooq/pom.xml | 1 - persistence-modules/r2dbc/pom.xml | 1 - persistence-modules/spring-data-mongodb-reactive/pom.xml | 2 -- persistence-modules/spring-persistence-simple/pom.xml | 1 - spring-5-data-reactive/pom.xml | 2 -- spring-boot-modules/spring-boot-libraries/pom.xml | 2 -- spring-boot-modules/spring-boot-react/pom.xml | 2 -- 11 files changed, 15 deletions(-) diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index d7b4a88369..7df5750134 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -208,7 +208,6 @@ 4.1.1 3.14.0 2.0.0.0 - 1.4.200 2.7.0 3.14.0 1.8 diff --git a/persistence-modules/core-java-persistence-2/pom.xml b/persistence-modules/core-java-persistence-2/pom.xml index 15676bf03e..780c1fcfca 100644 --- a/persistence-modules/core-java-persistence-2/pom.xml +++ b/persistence-modules/core-java-persistence-2/pom.xml @@ -44,7 +44,6 @@ - 1.4.200 8.4.1.jre11 10.2.0.4.0 8.0.22 diff --git a/persistence-modules/core-java-persistence/pom.xml b/persistence-modules/core-java-persistence/pom.xml index 96f8cef310..17d7db28d9 100644 --- a/persistence-modules/core-java-persistence/pom.xml +++ b/persistence-modules/core-java-persistence/pom.xml @@ -61,7 +61,6 @@ - 1.4.200 3.10.0 2.4.0 3.2.0 diff --git a/persistence-modules/hibernate-annotations/pom.xml b/persistence-modules/hibernate-annotations/pom.xml index e5c19915a4..634cd64cca 100644 --- a/persistence-modules/hibernate-annotations/pom.xml +++ b/persistence-modules/hibernate-annotations/pom.xml @@ -45,7 +45,6 @@ 5.4.7.Final - 1.4.200 true 2.1.7.RELEASE 5.4.7.Final diff --git a/persistence-modules/jooq/pom.xml b/persistence-modules/jooq/pom.xml index c66be9db77..b9229377ab 100644 --- a/persistence-modules/jooq/pom.xml +++ b/persistence-modules/jooq/pom.xml @@ -45,7 +45,6 @@ 3.13.4 - 1.4.200 \ No newline at end of file diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index ae4ca4d91d..1ce5eb3e96 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -63,7 +63,6 @@ 0.8.1.RELEASE - 1.4.200 \ No newline at end of file diff --git a/persistence-modules/spring-data-mongodb-reactive/pom.xml b/persistence-modules/spring-data-mongodb-reactive/pom.xml index c1398ca80d..2220418ac3 100644 --- a/persistence-modules/spring-data-mongodb-reactive/pom.xml +++ b/persistence-modules/spring-data-mongodb-reactive/pom.xml @@ -71,7 +71,6 @@ com.h2database h2 - ${h2.version} org.apache.httpcomponents @@ -126,7 +125,6 @@ 5.2.2.RELEASE 4.5.2 - 1.4.200 3.3.1.RELEASE diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml index 437a439b99..ec7c8bd3a0 100644 --- a/persistence-modules/spring-persistence-simple/pom.xml +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -92,7 +92,6 @@ 2.2 1.3 2.2.7.RELEASE - 1.4.200 0.23.0 diff --git a/spring-5-data-reactive/pom.xml b/spring-5-data-reactive/pom.xml index 3a9651de39..c145992737 100644 --- a/spring-5-data-reactive/pom.xml +++ b/spring-5-data-reactive/pom.xml @@ -72,7 +72,6 @@ com.h2database h2 - ${h2.version} org.apache.httpcomponents @@ -135,7 +134,6 @@ 1.0.0.RELEASE 0.8.1.RELEASE 4.5.2 - 1.4.200 1.5.23 3.3.1.RELEASE diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index ad00629e14..8d1fb57997 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -83,7 +83,6 @@ com.h2database h2 - ${h2.version} @@ -240,7 +239,6 @@ 2.2.4 2.3.2 0.23.0 - 1.4.200 2.1.0 1.5-beta1 2.1 diff --git a/spring-boot-modules/spring-boot-react/pom.xml b/spring-boot-modules/spring-boot-react/pom.xml index 3e8a9a7bd1..d515aed6ce 100644 --- a/spring-boot-modules/spring-boot-react/pom.xml +++ b/spring-boot-modules/spring-boot-react/pom.xml @@ -25,7 +25,6 @@ com.h2database h2 - ${h2.version} runtime @@ -128,7 +127,6 @@ v14.18.0 v1.12.1 2.4.4 - 1.4.200 1.0.2 From 4ae595210c7c507501c97ca2d0ac8df073d8be00 Mon Sep 17 00:00:00 2001 From: priya-soni Date: Sun, 21 Nov 2021 21:56:38 +0530 Subject: [PATCH 225/551] Bael 5191 json node get all keys (#11486) * BAEL-5191-JsonNode-Get-All-Keys-From-A-Json-Structure * Added test cases for GetAllKeysFromJSON class methods * Updated test class name * BAEL - 5191 - Updated exception handling --- .../jackson/jsonnode/GetAllKeysFromJSON.java | 109 ++++++------------ .../jsonnode/GetAllKeysFromJSONUnitTest.java | 53 +++++++-- 2 files changed, 77 insertions(+), 85 deletions(-) diff --git a/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java index d740b457af..bb8e9a8646 100644 --- a/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java +++ b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSON.java @@ -8,33 +8,27 @@ import java.util.Map; import java.util.Map.Entry; import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; public class GetAllKeysFromJSON { - public static List getKeysInJsonUsingMaps(String json, ObjectMapper mapper) { + public List getKeysInJsonUsingMaps(String json, ObjectMapper mapper) throws JsonMappingException, JsonProcessingException { List keys = new ArrayList<>(); - - try { - Map jsonElements = mapper.readValue(json, new TypeReference>() { - }); - getAllKeys(jsonElements, keys); - return keys; - - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - + Map jsonElements = mapper.readValue(json, new TypeReference>() { + }); + getAllKeys(jsonElements, keys); return keys; } - public static void getAllKeys(Map jsonElements, List keys) { + private void getAllKeys(Map jsonElements, List keys) { jsonElements.entrySet() .forEach(entry -> { @@ -54,51 +48,35 @@ public class GetAllKeysFromJSON { }); } - public static List getKeysInJsonUsingJsonNodeFieldNames(String json, ObjectMapper mapper) { + public List getKeysInJsonUsingJsonNodeFieldNames(String json, ObjectMapper mapper) throws JsonMappingException, JsonProcessingException { + List keys = new ArrayList<>(); - - try { - JsonNode jsonNode = mapper.readTree(json); - Iterator iterator = jsonNode.fieldNames(); - iterator.forEachRemaining(e -> keys.add(e)); - - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + JsonNode jsonNode = mapper.readTree(json); + Iterator iterator = jsonNode.fieldNames(); + iterator.forEachRemaining(e -> keys.add(e)); return keys; } - public static List getAllKeysInJsonUsingJsonNodeFieldNames(String json, ObjectMapper mapper) { + public List getAllKeysInJsonUsingJsonNodeFieldNames(String json, ObjectMapper mapper) throws JsonMappingException, JsonProcessingException { + List keys = new ArrayList<>(); - - try { - JsonNode jsonNode = mapper.readTree(json); - getAllKeysUsingJsonNodeFieldNames(jsonNode, keys); - - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + JsonNode jsonNode = mapper.readTree(json); + getAllKeysUsingJsonNodeFieldNames(jsonNode, keys); return keys; } - public static List getAllKeysInJsonUsingJsonNodeFields(String json, ObjectMapper mapper) { + public List getAllKeysInJsonUsingJsonNodeFields(String json, ObjectMapper mapper) throws JsonMappingException, JsonProcessingException { + List keys = new ArrayList<>(); - - try { - JsonNode jsonNode = mapper.readTree(json); - getAllKeysUsingJsonNodeFields(jsonNode, keys); - - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + JsonNode jsonNode = mapper.readTree(json); + getAllKeysUsingJsonNodeFields(jsonNode, keys); return keys; } - public static void getAllKeysUsingJsonNodeFields(JsonNode jsonNode, List keys) { + private void getAllKeysUsingJsonNodeFields(JsonNode jsonNode, List keys) { if (jsonNode.isObject()) { Iterator> fields = jsonNode.fields(); - fields.forEachRemaining(field -> { keys.add(field.getKey()); getAllKeysUsingJsonNodeFieldNames((JsonNode) field.getValue(), keys); @@ -112,11 +90,10 @@ public class GetAllKeysFromJSON { } - public static void getAllKeysUsingJsonNodeFieldNames(JsonNode jsonNode, List keys) { + private void getAllKeysUsingJsonNodeFieldNames(JsonNode jsonNode, List keys) { if (jsonNode.isObject()) { Iterator fieldNames = jsonNode.fieldNames(); - fieldNames.forEachRemaining(fieldName -> { keys.add(fieldName); getAllKeysUsingJsonNodeFieldNames(jsonNode.get(fieldName), keys); @@ -130,43 +107,29 @@ public class GetAllKeysFromJSON { } - public static List getKeysInJsonUsingJsonParser(String json, ObjectMapper mapper) { + public List getKeysInJsonUsingJsonParser(String json, ObjectMapper mapper) throws IOException { + List keys = new ArrayList<>(); - - try { - JsonNode jsonNode = mapper.readTree(json); - JsonParser jsonParser = jsonNode.traverse(); - while (!jsonParser.isClosed()) { - if (jsonParser.nextToken() == JsonToken.FIELD_NAME) { - keys.add((jsonParser.getCurrentName())); - } + JsonNode jsonNode = mapper.readTree(json); + JsonParser jsonParser = jsonNode.traverse(); + while (!jsonParser.isClosed()) { + if (jsonParser.nextToken() == JsonToken.FIELD_NAME) { + keys.add((jsonParser.getCurrentName())); } - } catch (JsonProcessingException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); } - return keys; } - public static List getKeysInJsonUsingJsonParser(String json) { + public List getKeysInJsonUsingJsonParser(String json) throws JsonParseException, IOException { + List keys = new ArrayList<>(); - - try { - JsonFactory factory = new JsonFactory(); - JsonParser jsonParser = factory.createParser(json); - while (!jsonParser.isClosed()) { - if (jsonParser.nextToken() == JsonToken.FIELD_NAME) { - keys.add((jsonParser.getCurrentName())); - } + JsonFactory factory = new JsonFactory(); + JsonParser jsonParser = factory.createParser(json); + while (!jsonParser.isClosed()) { + if (jsonParser.nextToken() == JsonToken.FIELD_NAME) { + keys.add((jsonParser.getCurrentName())); } - } catch (JsonProcessingException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); } - return keys; } } diff --git a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java index b547422aad..5d0558ca63 100644 --- a/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java +++ b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsonnode/GetAllKeysFromJSONUnitTest.java @@ -2,10 +2,12 @@ package com.baeldung.jackson.jsonnode; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.IOException; import java.util.List; import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class GetAllKeysFromJSONUnitTest { @@ -16,41 +18,68 @@ public class GetAllKeysFromJSONUnitTest { + " }\r\n" + " ]\r\n" + " }\r\n" + "}"; private static ObjectMapper mapper = new ObjectMapper(); + private static GetAllKeysFromJSON getAllKeysFromJSONUtil = new GetAllKeysFromJSON(); // Top level keys : [Name, Age, BookInterests, FoodInterests] // All keys: [Name, Age, BookInterests, Book, Author, Book, Author, FoodInterests, Breakfast, Bread, Beverage, Sandwich, Beverage] @Test public void givenAJsonNode_whenUsingFieldNamesMethod_thenWeGetTopFieldNames() { - List keys = GetAllKeysFromJSON.getKeysInJsonUsingJsonNodeFieldNames(json, mapper); - assertEquals(4, keys.size()); + List keys; + try { + keys = getAllKeysFromJSONUtil.getKeysInJsonUsingJsonNodeFieldNames(json, mapper); + assertEquals(4, keys.size()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } @Test public void givenAJsonNode_whenUsingFieldNamesMethodForAllNodes_thenWeGetAllFieldNames() { - List keys = GetAllKeysFromJSON.getAllKeysInJsonUsingJsonNodeFieldNames(json, mapper); - assertEquals(13, keys.size()); + List keys; + try { + keys = getAllKeysFromJSONUtil.getAllKeysInJsonUsingJsonNodeFieldNames(json, mapper); + assertEquals(13, keys.size()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } @Test public void givenAJsonNode_whenUsingFieldsMethod_thenWeGetAllFieldNames() { - List keys = GetAllKeysFromJSON.getAllKeysInJsonUsingJsonNodeFields(json, mapper); - assertEquals(13, keys.size()); + List keys; + try { + keys = getAllKeysFromJSONUtil.getAllKeysInJsonUsingJsonNodeFields(json, mapper); + assertEquals(13, keys.size()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } @Test public void givenAJsonNode_whenUsingJsonParserMethod_thenWeGetAllFieldNames() { - List keys = GetAllKeysFromJSON.getKeysInJsonUsingJsonParser(json, mapper); - assertEquals(13, keys.size()); + List keys; + try { + keys = getAllKeysFromJSONUtil.getKeysInJsonUsingJsonParser(json, mapper); + assertEquals(13, keys.size()); + + keys = getAllKeysFromJSONUtil.getKeysInJsonUsingJsonParser(json); + assertEquals(13, keys.size()); + } catch (IOException e) { + e.printStackTrace(); + } - keys = GetAllKeysFromJSON.getKeysInJsonUsingJsonParser(json); - assertEquals(13, keys.size()); } @Test public void givenAJsonNode_whenUsingMaps_thenWeGetAllFieldNames() { - List keys = GetAllKeysFromJSON.getKeysInJsonUsingMaps(json, mapper); - assertEquals(13, keys.size()); + List keys; + try { + keys = getAllKeysFromJSONUtil.getKeysInJsonUsingMaps(json, mapper); + assertEquals(13, keys.size()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } } From 871b044ea5c53a2db6ea2d1994e879fe0bbefe74 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Sun, 21 Nov 2021 20:25:21 +0100 Subject: [PATCH 226/551] add invoking static methods (#11439) --- .../access/staticmethods/GreetingAndBye.java | 12 ++++++++ .../GreetingAndByeClassUnitTest.java | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/staticmethods/GreetingAndBye.java create mode 100644 core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/GreetingAndByeClassUnitTest.java diff --git a/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/staticmethods/GreetingAndBye.java b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/staticmethods/GreetingAndBye.java new file mode 100644 index 0000000000..471ed1ee5b --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/staticmethods/GreetingAndBye.java @@ -0,0 +1,12 @@ +package com.baeldung.reflection.access.staticmethods; + +public class GreetingAndBye { + + public static String greeting(String name) { + return String.format("Hey %s, nice to meet you!", name); + } + + private static String goodBye(String name) { + return String.format("Bye %s, see you next time.", name); + } +} diff --git a/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/GreetingAndByeClassUnitTest.java b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/GreetingAndByeClassUnitTest.java new file mode 100644 index 0000000000..da82d2370c --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/GreetingAndByeClassUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.reflection.check.abstractclass; + +import com.baeldung.reflection.access.staticmethods.GreetingAndBye; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +class GreetingAndByeUnitTest { + + @Test + void givenPublicStaticMethod_whenCallWithReflection_thenReturnExpectedResult() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class clazz = GreetingAndBye.class; + Method method = clazz.getMethod("greeting", String.class); + Object result = method.invoke(null, "Eric"); + Assertions.assertEquals("Hey Eric, nice to meet you!", result); + } + + @Test + void givenPrivateStaticMethod_whenCallWithReflection_thenReturnExpectedResult() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class clazz = GreetingAndBye.class; + Method method = clazz.getDeclaredMethod("goodBye", String.class); + method.setAccessible(true); + Object result = method.invoke(null, "Eric"); + Assertions.assertEquals("Bye Eric, see you next time.", result); + } +} From 48a1cc56243eb2539e268c74c1ddbaa0cfb3dd41 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Sun, 21 Nov 2021 21:18:55 +0000 Subject: [PATCH 227/551] [JAVA-8353] Update the test to wait for assertion with timeout --- .../illegalmonitorstate/SynchronizedReceiver.java | 8 +++++--- .../illegalmonitorstate/SynchronizedSender.java | 8 +++++--- .../illegalmonitorstate/UnsynchronizedReceiver.java | 7 ++++--- .../illegalmonitorstate/UnsynchronizedSender.java | 7 ++++--- .../IllegalMonitorStateExceptionUnitTest.java | 8 +++++--- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java index ff6b926cdc..8b0aa95153 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java @@ -4,7 +4,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SynchronizedReceiver implements Runnable { - private static Logger log = LoggerFactory.getLogger(SynchronizedReceiver.class); + + private static final Logger LOG = LoggerFactory.getLogger(SynchronizedReceiver.class); + private final Data data; private String message; private boolean illegalMonitorStateExceptionOccurred; @@ -20,10 +22,10 @@ public class SynchronizedReceiver implements Runnable { data.wait(); this.message = data.receive(); } catch (InterruptedException e) { - log.error("thread was interrupted", e); + LOG.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - log.error("illegal monitor state exception occurred", e); + LOG.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java index 1618bc8efa..8317b5ade7 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java @@ -4,7 +4,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SynchronizedSender implements Runnable { - private static Logger log = LoggerFactory.getLogger(SynchronizedSender.class); + + private static final Logger LOG = LoggerFactory.getLogger(SynchronizedSender.class); + private final Data data; private boolean illegalMonitorStateExceptionOccurred; @@ -22,10 +24,10 @@ public class SynchronizedSender implements Runnable { data.notifyAll(); } catch (InterruptedException e) { - log.error("thread was interrupted", e); + LOG.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - log.error("illegal monitor state exception occurred", e); + LOG.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java index 3a0b72e6cd..69fb363731 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java @@ -4,7 +4,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UnsynchronizedReceiver implements Runnable { - private static Logger log = LoggerFactory.getLogger(UnsynchronizedReceiver.class); + private static final Logger LOG = LoggerFactory.getLogger(UnsynchronizedReceiver.class); + private final Data data; private String message; private boolean illegalMonitorStateExceptionOccurred; @@ -19,10 +20,10 @@ public class UnsynchronizedReceiver implements Runnable { data.wait(); this.message = data.receive(); } catch (InterruptedException e) { - log.error("thread was interrupted", e); + LOG.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - log.error("illegal monitor state exception occurred", e); + LOG.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java index 7f15418bfa..b97453f655 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java @@ -4,7 +4,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UnsynchronizedSender implements Runnable { - private static Logger log = LoggerFactory.getLogger(UnsynchronizedSender.class); + private static final Logger LOG = LoggerFactory.getLogger(UnsynchronizedSender.class); + private final Data data; private boolean illegalMonitorStateExceptionOccurred; @@ -21,10 +22,10 @@ public class UnsynchronizedSender implements Runnable { data.notifyAll(); } catch (InterruptedException e) { - log.error("thread was interrupted", e); + LOG.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - log.error("illegal monitor state exception occurred", e); + LOG.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java index 82c00bc72f..d19c75b2fa 100644 --- a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -1,7 +1,10 @@ package com.baeldung.exceptions.illegalmonitorstate; +import com.google.common.util.concurrent.Uninterruptibles; import org.junit.jupiter.api.Test; +import java.time.Duration; + import static org.junit.jupiter.api.Assertions.*; public class IllegalMonitorStateExceptionUnitTest { @@ -20,10 +23,9 @@ public class IllegalMonitorStateExceptionUnitTest { senderThread.join(1000); receiverThread.join(1000); - - Thread.sleep(2000); - assertEquals("test", receiver.getMessage()); + // we need to wait for enough time so that sender has had a chance to send the data + assertTimeout(Duration.ofSeconds(5), () -> assertEquals("test", receiver.getMessage())); assertFalse(sender.hasIllegalMonitorStateExceptionOccurred()); assertFalse(receiver.hasIllegalMonitorStateExceptionOccurred()); } From afcc730a6646102bc4742c13545e3871b8bef7e5 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Sun, 21 Nov 2021 21:24:02 +0000 Subject: [PATCH 228/551] [JAVA-8353] Increase timeout to 10s --- .../IllegalMonitorStateExceptionUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java index d19c75b2fa..28c317a1c9 100644 --- a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -25,7 +25,7 @@ public class IllegalMonitorStateExceptionUnitTest { receiverThread.join(1000); // we need to wait for enough time so that sender has had a chance to send the data - assertTimeout(Duration.ofSeconds(5), () -> assertEquals("test", receiver.getMessage())); + assertTimeout(Duration.ofSeconds(10), () -> assertEquals("test", receiver.getMessage())); assertFalse(sender.hasIllegalMonitorStateExceptionOccurred()); assertFalse(receiver.hasIllegalMonitorStateExceptionOccurred()); } From ca3fc370fab06d91387e2658af7a1b81f50f8027 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Mon, 22 Nov 2021 08:05:55 +0000 Subject: [PATCH 229/551] [JAVA-8353] Code clean up --- .../IllegalMonitorStateExceptionUnitTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java index 28c317a1c9..bef90e671f 100644 --- a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -1,6 +1,5 @@ package com.baeldung.exceptions.illegalmonitorstate; -import com.google.common.util.concurrent.Uninterruptibles; import org.junit.jupiter.api.Test; import java.time.Duration; From 8f5a0fa94ea2171288eff5ee01be05d04d9e352b Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 22 Nov 2021 10:35:16 +0100 Subject: [PATCH 230/551] JAVA-8021: Use AssertJ 1.6.0 in the restx module --- restx/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/restx/pom.xml b/restx/pom.xml index 57736f60cd..953b56e2f3 100644 --- a/restx/pom.xml +++ b/restx/pom.xml @@ -147,6 +147,7 @@ 0.35-rc4 + 1.6.0 \ No newline at end of file From 0f1a1b5cf2478076dba070c7e601bf83b6deb461 Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Sun, 14 Nov 2021 11:47:06 +0100 Subject: [PATCH 231/551] initial jbang example --- jbang/hello.java | 11 +++++++++++ jbang/hellocli.java | 27 +++++++++++++++++++++++++++ jbang/index.html | 18 ++++++++++++++++++ jbang/jbang-catalog.json | 15 +++++++++++++++ jbang/jbangquarkus.java | 21 +++++++++++++++++++++ 5 files changed, 92 insertions(+) create mode 100755 jbang/hello.java create mode 100755 jbang/hellocli.java create mode 100644 jbang/index.html create mode 100644 jbang/jbang-catalog.json create mode 100755 jbang/jbangquarkus.java diff --git a/jbang/hello.java b/jbang/hello.java new file mode 100755 index 0000000000..4a457b153b --- /dev/null +++ b/jbang/hello.java @@ -0,0 +1,11 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +// //DEPS + +import static java.lang.System.*; + +public class hello { + + public static void main(String... args) { + out.println("Hello World"); + } +} diff --git a/jbang/hellocli.java b/jbang/hellocli.java new file mode 100755 index 0000000000..8722cb27b8 --- /dev/null +++ b/jbang/hellocli.java @@ -0,0 +1,27 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +//DEPS info.picocli:picocli:4.5.0 + +import picocli.CommandLine; +import picocli.CommandLine.Command; +import picocli.CommandLine.Parameters; + +import java.util.concurrent.Callable; + +@Command(name = "hellocli", mixinStandardHelpOptions = true, version = "hellocli 0.1", + description = "hellocli made with jbang") +class hellocli implements Callable { + + @Parameters(index = "0", description = "The greeting to print", defaultValue = "World!") + private String greeting; + + public static void main(String... args) { + int exitCode = new CommandLine(new hellocli()).execute(args); + System.exit(exitCode); + } + + @Override + public Integer call() throws Exception { // your business logic goes here... + System.out.println("Hello " + greeting); + return 0; + } +} diff --git a/jbang/index.html b/jbang/index.html new file mode 100644 index 0000000000..bd34d026a3 --- /dev/null +++ b/jbang/index.html @@ -0,0 +1,18 @@ + + + + + + + JBang meets Quarkus + + + + + Go Say Hello! +

+ Powered by: + +

+ + \ No newline at end of file diff --git a/jbang/jbang-catalog.json b/jbang/jbang-catalog.json new file mode 100644 index 0000000000..2e30f0eb4a --- /dev/null +++ b/jbang/jbang-catalog.json @@ -0,0 +1,15 @@ +{ + "catalogs": {}, + "aliases": { + "hello": { + "script-ref": "hello.java" + }, + "hellocli": { + "script-ref": "hellocli.java" + }, + "jbangquarkus": { + "script-ref": "jbangquarkus.java" + } + }, + "templates": {} +} \ No newline at end of file diff --git a/jbang/jbangquarkus.java b/jbang/jbangquarkus.java new file mode 100755 index 0000000000..9e3cb5f69a --- /dev/null +++ b/jbang/jbangquarkus.java @@ -0,0 +1,21 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +// Update the Quarkus version to what you want here or run jbang with +// `-Dquarkus.version=` to override it. +//DEPS io.quarkus:quarkus-bom:${quarkus.version:2.4.0.Final}@pom +//DEPS io.quarkus:quarkus-resteasy +//JAVAC_OPTIONS -parameters + +//FILES META-INF/resources/index.html=index.html + +import javax.enterprise.context.ApplicationScoped; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +@Path("/hello") +@ApplicationScoped +public class jbangquarkus { + @GET + public String sayHello() { + return "Hello from Quarkus with jbang.dev"; + } +} From 10526d1a31e2554b030d65cd660bda6a235c3b25 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 22 Nov 2021 11:34:09 +0100 Subject: [PATCH 232/551] JAVA-8320: Upgrade Spring version to 5.3.13 --- parent-spring-5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index 1263a56e2b..a062084a81 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -24,7 +24,7 @@ - 5.3.9 + 5.3.13 5.2.3.RELEASE 1.5.10.RELEASE From 769c713eceea797d612d0a975e0f44e2136d2fc5 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 22 Nov 2021 16:23:15 +0100 Subject: [PATCH 233/551] JAVA-8320: Upgrade Spring Security to 5.6.0 --- parent-spring-5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index a062084a81..175e8d58f9 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -25,7 +25,7 @@ 5.3.13 - 5.2.3.RELEASE + 5.6.0 1.5.10.RELEASE From 2ca72c534f02e3c082bbc82bf27dd6428c108a2e Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 22 Nov 2021 21:17:12 +0100 Subject: [PATCH 234/551] JAVA-8320: Use spring.version property in the spring-di module --- spring-di/pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-di/pom.xml b/spring-di/pom.xml index 20207663cf..a7fa65067b 100644 --- a/spring-di/pom.xml +++ b/spring-di/pom.xml @@ -20,14 +20,14 @@ org.springframework spring-framework-bom - ${org.springframework.version} + ${spring.version} pom import org.springframework spring-core - ${org.springframework.version} + ${spring.version} @@ -143,7 +143,6 @@ org.baeldung.org.baeldung.sample.App - 5.0.6.RELEASE 1.3.2 1.4.4.RELEASE 1 From 6ae07978cdaca658551917da5479f7cbad6d53c0 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Tue, 23 Nov 2021 09:14:57 +0530 Subject: [PATCH 235/551] JAVA-8637: addressing PR review comments. --- .../java8/lambda/exceptions/LambdaExceptionWrappers.java | 6 +++--- .../src/main/resources/application.properties | 2 +- .../src/test/java/com/baeldung/SpringContextTest.java | 1 - .../baeldung/partialupdate/PartialUpdateUnitTest.java | 1 - .../com/baeldung/ehcache/SquareCalculatorUnitTest.java | 9 +++------ 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java b/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java index ce33aaf237..db710589e7 100644 --- a/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java +++ b/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java @@ -14,7 +14,7 @@ public class LambdaExceptionWrappers { try { consumer.accept(i); } catch (ArithmeticException e) { - LOGGER.error("Arithmetic Exception occured : {}", e.getMessage()); + LOGGER.error("Arithmetic Exception occurred.", e); } }; } @@ -26,7 +26,7 @@ public class LambdaExceptionWrappers { } catch (Exception ex) { try { E exCast = clazz.cast(ex); - LOGGER.error("Exception occured : {}", exCast.getMessage()); + LOGGER.error("Exception occurred.", exCast); } catch (ClassCastException ccEx) { throw ex; } @@ -51,7 +51,7 @@ public class LambdaExceptionWrappers { } catch (Exception ex) { try { E exCast = exceptionClass.cast(ex); - LOGGER.error("Exception occured : {}", exCast.getMessage()); + LOGGER.error("Exception occurred.", exCast); } catch (ClassCastException ccEx) { throw new RuntimeException(ex); } diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-enterprise/src/main/resources/application.properties index 32d3e640f9..0ca1872207 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/resources/application.properties @@ -9,7 +9,7 @@ spring.datasource.url=jdbc:h2:mem:baeldung #spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata #spring.jpa.properties.hibernate.format_sql=true -spring.jpa.show-sql=true +spring.jpa.show-sql=false #hibernate.dialect=org.hibernate.dialect.H2Dialect spring.jpa.properties.hibernate.id.new_generator_mappings=false \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java index 67ce958c64..0c735d3599 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/SpringContextTest.java @@ -10,7 +10,6 @@ import com.baeldung.boot.Application; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -@TestPropertySource(properties = {"spring.jpa.show-sql=false "}) public class SpringContextTest { @Test diff --git a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java index e217ef590e..4a70d409df 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/partialupdate/PartialUpdateUnitTest.java @@ -17,7 +17,6 @@ import com.baeldung.partialupdate.service.CustomerService; @RunWith(SpringRunner.class) @SpringBootTest(classes = PartialUpdateApplication.class) -@TestPropertySource(properties = {"spring.jpa.show-sql=false "}) public class PartialUpdateUnitTest { @Autowired diff --git a/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java b/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java index 311b7c575e..6a6c51bd9e 100644 --- a/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java +++ b/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java @@ -25,8 +25,7 @@ public class SquareCalculatorUnitTest { @Test public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() { for (int i = 10; i < 15; i++) { - assertFalse(cacheHelper.getSquareNumberCache() - .containsKey(i)); + assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); LOGGER.debug("Square value of {} is: {}", i, squaredCalculator.getSquareValueOfNumber(i)); } } @@ -34,14 +33,12 @@ public class SquareCalculatorUnitTest { @Test public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() { for (int i = 10; i < 15; i++) { - assertFalse(cacheHelper.getSquareNumberCache() - .containsKey(i)); + assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); LOGGER.debug("Square value of {} is: {}", i, squaredCalculator.getSquareValueOfNumber(i)); } for (int i = 10; i < 15; i++) { - assertTrue(cacheHelper.getSquareNumberCache() - .containsKey(i)); + assertTrue(cacheHelper.getSquareNumberCache().containsKey(i)); LOGGER.debug("Square value of {} is: {}", i, squaredCalculator.getSquareValueOfNumber(i) + "\n"); } } From fdeab133a55135e718372cefc1ea9a308f4b7a4a Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Tue, 23 Nov 2021 09:38:47 +0530 Subject: [PATCH 236/551] JAVA-8638: addressing PR review comments. --- .../EnversFooBarAuditIntegrationTest.java | 37 ++++++------------- .../persistence/hibernate/FooFixtures.java | 9 ++--- .../FooSortingPersistenceIntegrationTest.java | 21 ++++------- .../query/UserRepositoryIntegrationTest.java | 23 +++++++----- .../immutable/util/HibernateUtil.java | 3 +- 5 files changed, 36 insertions(+), 57 deletions(-) diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java index 7397a61cac..444324dafc 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java @@ -123,39 +123,24 @@ public class EnversFooBarAuditIntegrationTest { assertNotNull(barRevisionList); assertEquals(4, barRevisionList.size()); - assertEquals("BAR", barRevisionList.get(0) - .getName()); - assertEquals("BAR", barRevisionList.get(1) - .getName()); - assertEquals("BAR1", barRevisionList.get(2) - .getName()); - assertEquals("BAR1", barRevisionList.get(3) - .getName()); + assertEquals("BAR", barRevisionList.get(0).getName()); + assertEquals("BAR", barRevisionList.get(1).getName()); + assertEquals("BAR1", barRevisionList.get(2).getName()); + assertEquals("BAR1", barRevisionList.get(3).getName()); - assertEquals(1, barRevisionList.get(0) - .getFooSet() - .size()); - assertEquals(2, barRevisionList.get(1) - .getFooSet() - .size()); - assertEquals(2, barRevisionList.get(2) - .getFooSet() - .size()); - assertEquals(3, barRevisionList.get(3) - .getFooSet() - .size()); + assertEquals(1, barRevisionList.get(0).getFooSet().size()); + assertEquals(2, barRevisionList.get(1).getFooSet().size()); + assertEquals(2, barRevisionList.get(2).getFooSet().size()); + assertEquals(3, barRevisionList.get(3).getFooSet().size()); // test Foo revisions fooRevisionList = fooService.getRevisions(); assertNotNull(fooRevisionList); assertEquals(3, fooRevisionList.size()); - assertEquals("FOO1", fooRevisionList.get(0) - .getName()); - assertEquals("FOO2", fooRevisionList.get(1) - .getName()); - assertEquals("FOO3", fooRevisionList.get(2) - .getName()); + assertEquals("FOO1", fooRevisionList.get(0).getName()); + assertEquals("FOO2", fooRevisionList.get(1).getName()); + assertEquals("FOO3", fooRevisionList.get(2).getName()); } } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java index e0bd8a4f98..a7763bb0f8 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java @@ -46,10 +46,8 @@ public class FooFixtures { } foo2.setBar(bar); session.save(foo2); - bar.getFooSet() - .add(foo); - bar.getFooSet() - .add(foo2); + bar.getFooSet().add(foo); + bar.getFooSet().add(foo2); session.merge(bar); } tx.commit(); @@ -80,8 +78,7 @@ public class FooFixtures { final Foo foo = new Foo(); foo.setName("Foo_" + (i + 120)); final Bar bar = new Bar("bar_" + i); - bar.getFooSet() - .add(foo); + bar.getFooSet().add(foo); foo.setBar(bar); fooList.add(foo); diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java index fe73ddba3f..6078eb3af0 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java @@ -50,8 +50,7 @@ public class FooSortingPersistenceIntegrationTest { @After public void after() { - session.getTransaction() - .commit(); + session.getTransaction().commit(); session.close(); } @@ -71,8 +70,7 @@ public class FooSortingPersistenceIntegrationTest { final Query query = session.createQuery(hql); final List fooList = query.list(); - assertNull(fooList.get(fooList.toArray().length - 1) - .getName()); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); for (final Foo foo : fooList) { LOGGER.debug("Name: {}, Id: {}", foo.getName(), foo.getId()); } @@ -83,8 +81,7 @@ public class FooSortingPersistenceIntegrationTest { final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; final Query query = session.createQuery(hql); final List fooList = query.list(); - assertNull(fooList.get(0) - .getName()); + assertNull(fooList.get(0).getName()); for (final Foo foo : fooList) { LOGGER.debug("Name: {}", foo.getName()); @@ -145,11 +142,9 @@ public class FooSortingPersistenceIntegrationTest { @Test public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name") - .nulls(NullPrecedence.LAST)); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); final List fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length - 1) - .getName()); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); for (final Foo foo : fooList) { LOGGER.debug("Id: {}, FirstName: {}", foo.getId(), foo.getName()); } @@ -158,11 +153,9 @@ public class FooSortingPersistenceIntegrationTest { @Test public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name") - .nulls(NullPrecedence.FIRST)); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); final List fooList = criteria.list(); - assertNull(fooList.get(0) - .getName()); + assertNull(fooList.get(0).getName()); for (final Foo foo : fooList) { LOGGER.debug("Id: {}, FirstName: {}", foo.getId(), foo.getName()); } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java index df07c74c5a..19760f2bfe 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java @@ -40,42 +40,46 @@ public class UserRepositoryIntegrationTest { @Test public void whenFindAllSortedByNameThenAllSorted() { List allUsersSortedByName = userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); - assertThat(allUsersSortedByName).extracting("name") + assertThat(allUsersSortedByName) + .extracting("name") .containsSequence("Bob", "Cindy", "John"); } @Test public void whenFindAllSortedByNameLengthThenException() { - assertThatThrownBy(() -> userRepository.findAll(Sort.by("LENGTH(name)"))).isInstanceOf(PropertyReferenceException.class); + assertThatThrownBy(() -> userRepository.findAll(Sort.by("LENGTH(name)"))) + .isInstanceOf(PropertyReferenceException.class); } @Test public void whenFindAllUsersSortedByNameThenAllSorted() { List allUsersSortedByName = userRepository.findAllUsers(Sort.by(Sort.Direction.ASC, "name")); - assertThat(allUsersSortedByName).extracting("name") + assertThat(allUsersSortedByName) + .extracting("name") .containsSequence("Bob", "Cindy", "John"); } @Test public void whenFindAllUsersSortedByNameLengthThenAllSorted() { List allUsersSortedByName = userRepository.findAllUsers(JpaSort.unsafe("LENGTH(name)")); - assertThat(allUsersSortedByName).extracting("name") + assertThat(allUsersSortedByName) + .extracting("name") .containsSequence("Bob", "John", "Cindy"); } @Test public void whenFindAllUsersWithPaginationThenPaginated() { Page page = userRepository.findAllUsersWithPagination(PageRequest.of(0, 1)); - assertThat(page.stream() - .map(User::getId)).hasSize(1) + assertThat(page.stream().map(User::getId)) + .hasSize(1) .containsOnly(1); } @Test public void whenFindAllUsersWithPaginationNativeThenPaginated() { Page page = userRepository.findAllUsersWithPaginationNative(PageRequest.of(1, 1)); - assertThat(page.stream() - .map(User::getId)).hasSize(1) + assertThat(page.stream().map(User::getId)) + .hasSize(1) .containsOnly(2); } @@ -122,7 +126,8 @@ public class UserRepositoryIntegrationTest { @Test public void whenFindUserByNameListThenAllFound() { List users = userRepository.findUserByNameList(Arrays.asList("Bob", "Cindy")); - assertThat(users).extracting("name") + assertThat(users) + .extracting("name") .containsOnly("Bob", "Cindy"); } diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java index 25d7de4b07..aee4206e53 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java +++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/immutable/util/HibernateUtil.java @@ -21,8 +21,7 @@ public class HibernateUtil { configuration.addAnnotatedClass(Event.class); configuration.addAnnotatedClass(EventGeneratedId.class); configuration.configure("immutable.cfg.xml"); - ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) - .build(); + ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); return configuration.buildSessionFactory(serviceRegistry); } catch (Throwable ex) { LOGGER.debug("Initial SessionFactory creation failed.", ex); From 1ee2327ab362903763c239d05fb0009885d8aea6 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 23 Nov 2021 06:26:31 +0100 Subject: [PATCH 237/551] BAEL-5242: Add surefire config for TestNG (#11471) * BAEL-5242: Add surefire config for TestNG * BAEL-5242: Configure surefire to run unit and integration tests --- testing-modules/testng/pom.xml | 45 +++++++++++++++++-- .../testng/src/test/resources/test_int.xml | 10 +++++ .../testng/src/test/resources/test_unit.xml | 9 ++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 testing-modules/testng/src/test/resources/test_int.xml create mode 100644 testing-modules/testng/src/test/resources/test_unit.xml diff --git a/testing-modules/testng/pom.xml b/testing-modules/testng/pom.xml index 99af6be5b4..5d3bf6b560 100644 --- a/testing-modules/testng/pom.xml +++ b/testing-modules/testng/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 testng 0.1.0-SNAPSHOT @@ -16,7 +16,6 @@ - org.testng testng @@ -41,8 +40,46 @@
+ + + default-second + + + + org.apache.maven.plugins + maven-surefire-plugin + + + src\test\resources\parametrized_testng.xml + src\test\resources\test_suite.xml + src\test\resources\test_unit.xml + + + + + + + + integration-lite-second + + + + org.apache.maven.plugins + maven-surefire-plugin + + + src\test\resources\test_group.xml + src\test\resources\test_setup.xml + src\test\resources\test_int.xml + + + + + + + + - 7.1.0 diff --git a/testing-modules/testng/src/test/resources/test_int.xml b/testing-modules/testng/src/test/resources/test_int.xml new file mode 100644 index 0000000000..9eb86739b6 --- /dev/null +++ b/testing-modules/testng/src/test/resources/test_int.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/testing-modules/testng/src/test/resources/test_unit.xml b/testing-modules/testng/src/test/resources/test_unit.xml new file mode 100644 index 0000000000..76c97db735 --- /dev/null +++ b/testing-modules/testng/src/test/resources/test_unit.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file From 952b06b20bda49166981d8c9ceaa07cd2e1047d7 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Tue, 23 Nov 2021 19:12:32 +0530 Subject: [PATCH 238/551] JAVA-8638: addressing PR review comments. --- .../src/main/resources/application.properties | 2 +- .../java/com/baeldung/exists/CarRepositoryIntegrationTest.java | 1 - .../src/main/resources/application.properties | 2 +- .../baeldung/boot/daos/InventoryRepositoryIntegrationTest.java | 2 +- .../derivedquery/repository/UserRepositoryIntegrationTest.java | 2 +- .../java/com/baeldung/like/MovieRepositoryIntegrationTest.java | 2 +- .../com/baeldung/repository/FruitPopulatorIntegrationTest.java | 2 +- .../com/baeldung/repository/SongRepositoryIntegrationTest.java | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) diff --git a/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties index 9bb870895d..eb0e519ef0 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties @@ -1,2 +1,2 @@ -spring.jpa.show-sql=true +spring.jpa.show-sql=false spring.jpa.defer-datasource-initialization=true \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java index c740fd7abd..53f22ed0d1 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/exists/CarRepositoryIntegrationTest.java @@ -20,7 +20,6 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc @RunWith(SpringRunner.class) @SpringBootTest(classes = {Application.class}) -@TestPropertySource(properties = {"spring.jpa.show-sql=false"}) public class CarRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-repo/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-repo/src/main/resources/application.properties index ae1afe6e98..1a370121c5 100644 --- a/persistence-modules/spring-data-jpa-repo/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-repo/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.jpa.show-sql=true +spring.jpa.show-sql=false spring.jpa.defer-datasource-initialization=true #MySql #spring.datasource.url=jdbc:mysql://localhost:3306/baeldung diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java index 9201df8990..e4bd3dabff 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java @@ -19,7 +19,7 @@ import com.baeldung.Application; import com.baeldung.boot.domain.MerchandiseEntity; @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, properties = {"spring.jpa.show-sql=false"}) +@SpringBootTest(classes = Application.class) public class InventoryRepositoryIntegrationTest { private static final String ORIGINAL_TITLE = "Pair of Pants"; diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java index 41c171e449..2a6e166b88 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java @@ -17,7 +17,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = QueryApplication.class, properties = {"spring.jpa.show-sql=false"}) +@SpringBootTest(classes = QueryApplication.class) public class UserRepositoryIntegrationTest { private static final String USER_NAME_ADAM = "Adam"; diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java index a4a1982df8..cc96b638ab 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/like/MovieRepositoryIntegrationTest.java @@ -16,7 +16,7 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TES @RunWith(SpringRunner.class) @Sql(scripts = { "/test-movie-data.sql" }) -@SpringBootTest(classes = LikeApplication.class, properties = {"spring.jpa.show-sql=false"}) +@SpringBootTest(classes = LikeApplication.class) @Sql(scripts = "/test-movie-cleanup.sql", executionPhase = AFTER_TEST_METHOD) public class MovieRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java index d0b2ab8dd7..4d3661e717 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/FruitPopulatorIntegrationTest.java @@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.entity.Fruit; @RunWith(SpringRunner.class) -@SpringBootTest(properties = {"spring.jpa.show-sql=false"}) +@SpringBootTest public class FruitPopulatorIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java index 619b410f0d..19362acd44 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/repository/SongRepositoryIntegrationTest.java @@ -16,7 +16,7 @@ import com.baeldung.entity.Song; import com.baeldung.repository.SongRepository; @RunWith(SpringRunner.class) -@SpringBootTest(properties = {"spring.jpa.show-sql=false"}) +@SpringBootTest @Sql(scripts = { "/test-song-data.sql" }) public class SongRepositoryIntegrationTest { From 2d142da80949c03fe63975d15023118218da02cd Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 24 Nov 2021 09:06:52 +0530 Subject: [PATCH 239/551] Fix integration build --- .../src/test/resources/hibernate-pessimistic-locking.properties | 2 +- testing-modules/junit-5-basics/pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/hibernate-jpa/src/test/resources/hibernate-pessimistic-locking.properties b/persistence-modules/hibernate-jpa/src/test/resources/hibernate-pessimistic-locking.properties index 4f1ff5e93a..342f7b0bf5 100644 --- a/persistence-modules/hibernate-jpa/src/test/resources/hibernate-pessimistic-locking.properties +++ b/persistence-modules/hibernate-jpa/src/test/resources/hibernate-pessimistic-locking.properties @@ -1,5 +1,5 @@ hibernate.connection.driver_class=org.h2.Driver -hibernate.connection.url=jdbc:h2:mem:mydb3;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=100;MVCC=FALSE +hibernate.connection.url=jdbc:h2:mem:mydb3;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=100 hibernate.connection.username=sa hibernate.connection.autocommit=true hibernate.dialect=org.hibernate.dialect.H2Dialect diff --git a/testing-modules/junit-5-basics/pom.xml b/testing-modules/junit-5-basics/pom.xml index 62dc4321a8..4dcba2db96 100644 --- a/testing-modules/junit-5-basics/pom.xml +++ b/testing-modules/junit-5-basics/pom.xml @@ -124,6 +124,7 @@ 5.0.6.RELEASE + 1.4.197 \ No newline at end of file From bb55c3b88aa1babcabcd44fb12459032f951e890 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 13:56:24 +0800 Subject: [PATCH 240/551] Update README.md --- core-java-modules/core-java-string-operations-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-4/README.md b/core-java-modules/core-java-string-operations-4/README.md index 304f604c5e..be4c9ae05f 100644 --- a/core-java-modules/core-java-string-operations-4/README.md +++ b/core-java-modules/core-java-string-operations-4/README.md @@ -1,4 +1,5 @@ ### Relevant Articles: - [Ignoring Commas in Quotes When Splitting a Comma-separated String](https://www.baeldung.com/java-split-string-commas) +- [Compare Strings While Ignoring Whitespace in Java](https://www.baeldung.com/java-compare-string-whitespace) From ab9d07a0e1348cdbc5ddf53bc06d9a80c3b7fb6d Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 13:57:47 +0800 Subject: [PATCH 241/551] Update README.md --- core-java-modules/core-java-security-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-security-3/README.md b/core-java-modules/core-java-security-3/README.md index 10e9773f9b..30cfd8a947 100644 --- a/core-java-modules/core-java-security-3/README.md +++ b/core-java-modules/core-java-security-3/README.md @@ -7,4 +7,5 @@ This module contains articles about core Java Security - [Secret Key and String Conversion in Java](https://www.baeldung.com/java-secret-key-to-string) - [Enabling Unlimited Strength Cryptography in Java](https://www.baeldung.com/jce-enable-unlimited-strength) - [Initialization Vector for Encryption](https://www.baeldung.com/java-encryption-iv) +- [HMAC in Java](https://www.baeldung.com/java-hmac) - More articles: [[<-- prev]](/core-java-modules/core-java-security-2) From 02f6e75078dfd590c1f33a66f26adb288e4246f4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 13:59:36 +0800 Subject: [PATCH 242/551] Update README.md --- lombok/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lombok/README.md b/lombok/README.md index bda960a28a..e1dd58abf2 100644 --- a/lombok/README.md +++ b/lombok/README.md @@ -12,3 +12,4 @@ This module contains articles about Project Lombok. - [Setting up Lombok with Eclipse and Intellij](https://www.baeldung.com/lombok-ide) - [Using the @Singular Annotation with Lombok Builders](https://www.baeldung.com/lombok-builder-singular) - [Using Lombok’s @Accessors Annotation](https://www.baeldung.com/lombok-accessors) +- [Omitting Getter or Setter in Lombok](https://www.baeldung.com/lombok-omit-getter-setter) From fe13e24e1b92a5565e09b6d725a94e91cc656f4f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:01:23 +0800 Subject: [PATCH 243/551] Update README.md --- lombok/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lombok/README.md b/lombok/README.md index e1dd58abf2..b8073ff621 100644 --- a/lombok/README.md +++ b/lombok/README.md @@ -3,6 +3,7 @@ This module contains articles about Project Lombok. ### Relevant Articles: + - [Introduction to Project Lombok](https://www.baeldung.com/intro-to-project-lombok) - [Using Lombok’s @Builder Annotation](https://www.baeldung.com/lombok-builder) - [Using Lombok’s @Getter for Boolean Fields](https://www.baeldung.com/lombok-getter-boolean) @@ -13,3 +14,4 @@ This module contains articles about Project Lombok. - [Using the @Singular Annotation with Lombok Builders](https://www.baeldung.com/lombok-builder-singular) - [Using Lombok’s @Accessors Annotation](https://www.baeldung.com/lombok-accessors) - [Omitting Getter or Setter in Lombok](https://www.baeldung.com/lombok-omit-getter-setter) +- [Declaring Val and Var Variables in Lombok](https://www.baeldung.com/java-lombok-val-var) From afb8a8fb9c0f281a3f101de64fa05d9d20d9bf4f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:15:26 +0800 Subject: [PATCH 244/551] Update README.md --- core-java-modules/core-java-reflection-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-reflection-2/README.md b/core-java-modules/core-java-reflection-2/README.md index 4c888bdf58..c1966dd63d 100644 --- a/core-java-modules/core-java-reflection-2/README.md +++ b/core-java-modules/core-java-reflection-2/README.md @@ -6,3 +6,4 @@ - [Checking if a Java Class is ‘abstract’ Using Reflection](https://www.baeldung.com/java-reflection-is-class-abstract) - [Invoking a Private Method in Java](https://www.baeldung.com/java-call-private-method) - [Finding All Classes in a Java Package](https://www.baeldung.com/java-find-all-classes-in-package) +- [Invoke a Static Method Using Java Reflection API](https://www.baeldung.com/java-invoke-static-method-reflection) From 27b6f9b7fde60811abecae65e78a18bacc0af898 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:17:59 +0800 Subject: [PATCH 245/551] Update README.md --- apache-poi/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apache-poi/README.md b/apache-poi/README.md index 13d62eeba0..d3d60358c5 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -14,3 +14,4 @@ This module contains articles about Apache POI - [Insert a Row in Excel Using Apache POI](https://www.baeldung.com/apache-poi-insert-excel-row) - [Multiline Text in Excel Cell Using Apache POI](https://www.baeldung.com/apache-poi-write-multiline-text) - [Set Background Color of a Cell with Apache POI](https://www.baeldung.com/apache-poi-background-color) +- [Add Borders to Excel Cells With Apache POI](https://www.baeldung.com/apache-poi-add-borders) From 0d3a018616134f26dfe5ce626e8bc3b67b376967 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:20:24 +0800 Subject: [PATCH 246/551] Update README.md --- jackson-modules/jackson/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jackson-modules/jackson/README.md b/jackson-modules/jackson/README.md index 50e13a5b75..0aa3dc5aef 100644 --- a/jackson-modules/jackson/README.md +++ b/jackson-modules/jackson/README.md @@ -6,9 +6,11 @@ This module contains articles about Jackson. The "REST With Spring" Classes: http://bit.ly/restwithspring -### Relevant Articles: +### Relevant Articles: + - [Using Optional with Jackson](https://www.baeldung.com/jackson-optional) - [Compare Two JSON Objects with Jackson](https://www.baeldung.com/jackson-compare-two-json-objects) - [Jackson vs Gson](https://www.baeldung.com/jackson-vs-gson) - [Inheritance with Jackson](https://www.baeldung.com/jackson-inheritance) - [Working with Tree Model Nodes in Jackson](https://www.baeldung.com/jackson-json-node-tree-model) +- [Get all the Keys in a JSON String Using JsonNode](https://www.baeldung.com/java-jsonnode-get-keys) From cadb1a1cd0f00c353616c1e8c192929dd63c2802 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:23:37 +0800 Subject: [PATCH 247/551] Update README.md --- testing-modules/testing-assertions/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/testing-assertions/README.md b/testing-modules/testing-assertions/README.md index bf35505211..2349834fa3 100644 --- a/testing-modules/testing-assertions/README.md +++ b/testing-modules/testing-assertions/README.md @@ -3,3 +3,4 @@ - [Asserting Log Messages With JUnit](https://www.baeldung.com/junit-asserting-logs) - [Assert Two Lists for Equality Ignoring Order in Java](https://www.baeldung.com/java-assert-lists-equality-ignore-order) - [Assert That a Java Optional Has a Certain Value](https://www.baeldung.com/java-optional-assert-value) +- [Assert that an Object is from a Specific Type](https://www.baeldung.com/java-assert-object-of-type) From 2f9ce6cf36dc71bf3d7f5253bf365dd68e670f24 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 24 Nov 2021 09:47:43 +0100 Subject: [PATCH 248/551] JAVA-8664: Change ports numbers and cleanup the code --- .../java/com/baeldung/ctx1/Ctx1Controller.java | 14 +++++--------- .../java/com/baeldung/ctx2/Ctx2Controller.java | 7 +++---- .../src/main/resources/ctx1.properties | 2 +- .../src/main/resources/ctx2.properties | 2 +- .../test/java/com/baeldung/SpringContextTest.java | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java index 9c7667db35..2de42251e4 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java @@ -1,22 +1,18 @@ package com.baeldung.ctx1; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; - import com.baeldung.parent.IHomeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class Ctx1Controller { @Autowired - IHomeService homeService; + private IHomeService homeService; @GetMapping("/home") - @ResponseBody public String greeting() { - return homeService.getGreeting(); } } diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java index 850fd8021c..65790141bb 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java @@ -1,18 +1,17 @@ package com.baeldung.ctx2; +import com.baeldung.parent.IHomeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import com.baeldung.parent.IHomeService; - @RestController public class Ctx2Controller { @Autowired - IHomeService homeService; + private IHomeService homeService; - @GetMapping(value = "/greeting", produces = "application/json") + @GetMapping(value = "/greeting") public String getGreeting() { return homeService.getGreeting(); } diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx1.properties b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx1.properties index 2b618d4177..d0af43abdd 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx1.properties +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx1.properties @@ -1,4 +1,4 @@ -server.port=8081 +server.port=8074 server.servlet.context-path=/ctx1 #logging.level=debug spring.application.admin.enabled=false diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx2.properties b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx2.properties index f3599e17e0..7cd48d2f07 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx2.properties +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx2.properties @@ -1,4 +1,4 @@ -server.port=8082 +server.port=8075 server.servlet.context-path=/ctx2 spring.application.admin.enabled=false diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/com/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/com/baeldung/SpringContextTest.java index ca8989724b..07242452bf 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/com/baeldung/SpringContextTest.java @@ -7,7 +7,7 @@ import com.baeldung.parent.App; public class SpringContextTest { @Test - public final void testMain() throws Exception { + public final void testMain() { App.main(new String[] {}); } } From b04d57541ad7e37afe9178676c8607e4d559c363 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 24 Nov 2021 09:51:22 +0100 Subject: [PATCH 249/551] JAVA-8664: Cleanup --- .../src/main/java/com/baeldung/ctx2/Ctx2Controller.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java index 65790141bb..1b7edf6710 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java @@ -11,7 +11,7 @@ public class Ctx2Controller { @Autowired private IHomeService homeService; - @GetMapping(value = "/greeting") + @GetMapping("/greeting") public String getGreeting() { return homeService.getGreeting(); } From edd11dead5f765b0dea20272033d5c514973a8d6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 19:40:29 +0800 Subject: [PATCH 250/551] Update README.md --- linux-bash/text/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/linux-bash/text/README.md b/linux-bash/text/README.md index 1c27abc8c6..5423ddf916 100644 --- a/linux-bash/text/README.md +++ b/linux-bash/text/README.md @@ -1,4 +1,3 @@ ### Relevant Articles: -- [Linux Commands – Remove All Text After X](https://www.baeldung.com/linux/remove-text-after-x-in-file) - [Linux Commands for Appending Multiple Lines to a File](https://www.baeldung.com/linux/appending-multiple-lines-to-file2) From 2881fe39072ae91d36ce1565fc5671ef3d7d2219 Mon Sep 17 00:00:00 2001 From: Ralf Ueberfuhr Date: Wed, 24 Nov 2021 12:56:12 +0100 Subject: [PATCH 251/551] BAEL-5036: Deactivate JDK8 build for Quarkus 2.x project --- pom.xml | 2 +- quarkus-jandex/README.md | 3 --- quarkus-jandex/pom.xml | 28 +++++++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-) delete mode 100644 quarkus-jandex/README.md diff --git a/pom.xml b/pom.xml index f51491137e..cdad7ed8ea 100644 --- a/pom.xml +++ b/pom.xml @@ -534,7 +534,6 @@ quarkus quarkus-extension - quarkus-jandex rabbitmq @@ -1310,6 +1309,7 @@ core-java-modules/multimodulemavenproject persistence-modules/sirix quarkus-vs-springboot + quarkus-jandex spring-boot-modules/spring-boot-cassandre diff --git a/quarkus-jandex/README.md b/quarkus-jandex/README.md deleted file mode 100644 index a03cdc708f..0000000000 --- a/quarkus-jandex/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Create a Jandex index in Quarkus for classes in a external module](https://www.baeldung.com/quarkus-jandex) diff --git a/quarkus-jandex/pom.xml b/quarkus-jandex/pom.xml index e8e66b44b1..eb7f308599 100644 --- a/quarkus-jandex/pom.xml +++ b/quarkus-jandex/pom.xml @@ -15,20 +15,8 @@ hello-sender-undetected hello-app - - - 3.8.1 - true - 11 - 11 - UTF-8 - UTF-8 - quarkus-bom - io.quarkus.platform - 2.3.0.Final - 3.0.0-M5 - + ${quarkus.platform.group-id} @@ -39,4 +27,18 @@ + + + 3.8.1 + true + 11 + 11 + UTF-8 + UTF-8 + quarkus-bom + io.quarkus.platform + 2.4.2.Final + 3.0.0-M5 + + From 09d420d593148e0fc795e068321e70eb61575de0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 19:56:47 +0800 Subject: [PATCH 252/551] Delete README.md --- guest/core-kotlin/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 guest/core-kotlin/README.md diff --git a/guest/core-kotlin/README.md b/guest/core-kotlin/README.md deleted file mode 100644 index fad62ebea6..0000000000 --- a/guest/core-kotlin/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Kotlin vs Java](https://www.baeldung.com/kotlin/vs-java) From c8a546edc7a277cbe251bd49a81811b4a8778984 Mon Sep 17 00:00:00 2001 From: Ralf Ueberfuhr Date: Wed, 24 Nov 2021 12:57:12 +0100 Subject: [PATCH 253/551] BAEL-5036: Deactivate JDK8 build for Quarkus 2.x project --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index cdad7ed8ea..f001dfd357 100644 --- a/pom.xml +++ b/pom.xml @@ -1004,7 +1004,6 @@ quarkus quarkus-extension - quarkus-jandex rabbitmq From 97f88d52580cb2d0e434b349636b35ed3b505926 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 20:03:28 +0800 Subject: [PATCH 254/551] Update README.md --- .../src/test/java/com/baeldung/applicationcontext/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/test/java/com/baeldung/applicationcontext/README.md b/spring-core/src/test/java/com/baeldung/applicationcontext/README.md index 211007e0cf..a626417d47 100644 --- a/spring-core/src/test/java/com/baeldung/applicationcontext/README.md +++ b/spring-core/src/test/java/com/baeldung/applicationcontext/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Introduction to Java Servlets](http://www.baeldung.com/intro-to-servlets) + - [Intro to the Spring ClassPathXmlApplicationContext](http://www.baeldung.com/spring-classpathxmlapplicationcontext) From 63dd727933ebe2b83325c8feb7fd6d1de36ab65c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 24 Nov 2021 20:06:53 +0800 Subject: [PATCH 255/551] Update README.md --- core-java-modules/core-java-string-operations-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-string-operations-2/README.md b/core-java-modules/core-java-string-operations-2/README.md index d66515d372..f95b002906 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -12,5 +12,5 @@ This module contains articles about string operations. - [L-Trim and R-Trim Alternatives in Java](https://www.baeldung.com/java-trim-alternatives) - [Encode a String to UTF-8 in Java](https://www.baeldung.com/java-string-encode-utf-8) - [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding) -- [Convert Hex to ASCII in Java](https://www.baeldung.com/java-convert-hex-to-ascii) #remove additional readme file +- [Convert Hex to ASCII in Java](https://www.baeldung.com/java-convert-hex-to-ascii) - More articles: [[<-- prev]](../core-java-string-operations) From 8b280e689aa514345b88e05b032999060e7da233 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 24 Nov 2021 13:20:20 +0100 Subject: [PATCH 256/551] JAVA-8667: Remove hamcrest dependency declarations from the child modules --- core-java-modules/core-java-collections-maps-4/pom.xml | 6 ------ .../core-java-string-conversions-2/pom.xml | 6 ------ core-java-modules/core-java-string-conversions/pom.xml | 6 ------ .../core-java-string-operations-2/pom.xml | 6 ------ ethereum/pom.xml | 6 ------ java-collections-conversions-2/pom.xml | 6 ------ libraries-testing/pom.xml | 1 - libraries/pom.xml | 7 ------- parent-java/pom.xml | 1 - spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml | 10 ---------- spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml | 5 ----- spring-core-2/pom.xml | 5 ----- .../spring-security-web-boot-1/pom.xml | 5 ----- .../spring-security-web-boot-2/pom.xml | 5 ----- .../spring-security-web-rest-custom/pom.xml | 5 ----- spring-web-modules/spring-rest-query-language/pom.xml | 5 ----- spring-web-modules/spring-rest-simple/pom.xml | 5 ----- spring-web-modules/spring-rest-testing/pom.xml | 5 ----- spring-web-modules/spring-resttemplate/pom.xml | 5 ----- testing-modules/selenium-junit-testng/pom.xml | 5 ----- testing-modules/testing-assertions/pom.xml | 6 ------ 21 files changed, 111 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-4/pom.xml b/core-java-modules/core-java-collections-maps-4/pom.xml index 2109804ff0..c5296e9a43 100644 --- a/core-java-modules/core-java-collections-maps-4/pom.xml +++ b/core-java-modules/core-java-collections-maps-4/pom.xml @@ -28,12 +28,6 @@ ${junit.version} test - - org.hamcrest - hamcrest-all - ${hamcrest-all.version} - test - diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index f97443d9ca..45eb0dc2e2 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -20,12 +20,6 @@ guava ${guava.version} - - org.hamcrest - hamcrest - ${hamcrest.version} - test - com.ibm.icu icu4j diff --git a/core-java-modules/core-java-string-conversions/pom.xml b/core-java-modules/core-java-string-conversions/pom.xml index 148f04101f..8ed3e1d628 100644 --- a/core-java-modules/core-java-string-conversions/pom.xml +++ b/core-java-modules/core-java-string-conversions/pom.xml @@ -35,12 +35,6 @@ guava ${guava.version} - - org.hamcrest - hamcrest - ${hamcrest.version} - test - diff --git a/core-java-modules/core-java-string-operations-2/pom.xml b/core-java-modules/core-java-string-operations-2/pom.xml index 0d31486759..848a358aa2 100644 --- a/core-java-modules/core-java-string-operations-2/pom.xml +++ b/core-java-modules/core-java-string-operations-2/pom.xml @@ -45,12 +45,6 @@ javax.el ${javax.el.version} - - org.hamcrest - hamcrest - ${hamcrest.version} - test - org.openjdk.jmh jmh-core diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 95dd1c0955..d2b05222c3 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -144,12 +144,6 @@ test - - org.hamcrest - hamcrest - ${hamcrest.version} - test - com.jayway.jsonpath json-path diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index 694b416169..9f8ef7addc 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -26,12 +26,6 @@ modelmapper ${modelmapper.version} - - org.hamcrest - hamcrest - ${hamcrest.version} - test - io.vavr vavr diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index d62d094f08..0815c94dbf 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -118,7 +118,6 @@ ${spring-mock-mvc.version} test - org.hamcrest java-hamcrest diff --git a/libraries/pom.xml b/libraries/pom.xml index b0a0aa22ea..7bef56deb0 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -167,12 +167,6 @@ google-oauth-client-jetty ${google-api.version} - - org.hamcrest - hamcrest-all - ${hamcrest-all.version} - test - @@ -279,7 +273,6 @@ 1.15 1.23.0 0.9.4.0006L - 1.3 3.2.0-m7 5.1.1 5.0.2 diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 4e5081393c..808eed1c44 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -43,7 +43,6 @@ 31.0.1-jre 2.3.7 - 2.2 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml b/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml index 8e7b87c220..8248884632 100644 --- a/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml +++ b/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml @@ -68,16 +68,6 @@ spring-boot-starter-test ${spring-boot.version} - - org.hamcrest - hamcrest-core - ${hamcrest-core.version} - test - - - 1.3 - - \ No newline at end of file diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml b/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml index 7c3f668473..c071b8863a 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml @@ -27,11 +27,6 @@ spring-test test - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index dda23c4ea4..19e7fb5f28 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -129,11 +129,6 @@ spring-test test - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/spring-security-modules/spring-security-web-boot-1/pom.xml b/spring-security-modules/spring-security-web-boot-1/pom.xml index a376a49b4c..3f6001686d 100644 --- a/spring-security-modules/spring-security-web-boot-1/pom.xml +++ b/spring-security-modules/spring-security-web-boot-1/pom.xml @@ -59,11 +59,6 @@ postgresql runtime - - org.hamcrest - hamcrest - test - org.springframework spring-test diff --git a/spring-security-modules/spring-security-web-boot-2/pom.xml b/spring-security-modules/spring-security-web-boot-2/pom.xml index ade644741d..91b6ff8724 100644 --- a/spring-security-modules/spring-security-web-boot-2/pom.xml +++ b/spring-security-modules/spring-security-web-boot-2/pom.xml @@ -59,11 +59,6 @@ postgresql runtime - - org.hamcrest - hamcrest - test - org.springframework spring-test diff --git a/spring-security-modules/spring-security-web-rest-custom/pom.xml b/spring-security-modules/spring-security-web-rest-custom/pom.xml index 85e50412ad..1403154767 100644 --- a/spring-security-modules/spring-security-web-rest-custom/pom.xml +++ b/spring-security-modules/spring-security-web-rest-custom/pom.xml @@ -116,11 +116,6 @@ ${commons-lang3.version} - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/spring-web-modules/spring-rest-query-language/pom.xml b/spring-web-modules/spring-rest-query-language/pom.xml index c5a8c172f3..65f28f5be0 100644 --- a/spring-web-modules/spring-rest-query-language/pom.xml +++ b/spring-web-modules/spring-rest-query-language/pom.xml @@ -181,11 +181,6 @@ spring-test test - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/spring-web-modules/spring-rest-simple/pom.xml b/spring-web-modules/spring-rest-simple/pom.xml index 69d88d6456..2f8d6eac27 100644 --- a/spring-web-modules/spring-rest-simple/pom.xml +++ b/spring-web-modules/spring-rest-simple/pom.xml @@ -120,11 +120,6 @@ ${com.squareup.okhttp3.version} - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/spring-web-modules/spring-rest-testing/pom.xml b/spring-web-modules/spring-rest-testing/pom.xml index dc5fdcd323..93942e97b6 100644 --- a/spring-web-modules/spring-rest-testing/pom.xml +++ b/spring-web-modules/spring-rest-testing/pom.xml @@ -165,11 +165,6 @@ spring-test test - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/spring-web-modules/spring-resttemplate/pom.xml b/spring-web-modules/spring-resttemplate/pom.xml index 3066a82242..5cac186fad 100644 --- a/spring-web-modules/spring-resttemplate/pom.xml +++ b/spring-web-modules/spring-resttemplate/pom.xml @@ -108,11 +108,6 @@ ${com.squareup.okhttp3.version} - - org.hamcrest - hamcrest - test - org.mockito mockito-core diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index 0bf6f0726d..dfa19c48d4 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -31,11 +31,6 @@ testng ${testng.version} - - org.hamcrest - hamcrest-all - ${hamcrest-all.version} - ru.yandex.qatools.ashot ashot diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml index 12af95b575..689ca35733 100644 --- a/testing-modules/testing-assertions/pom.xml +++ b/testing-modules/testing-assertions/pom.xml @@ -18,12 +18,6 @@ logback-classic ${logback.version} - - org.hamcrest - hamcrest-all - ${hamcrest-all.version} - test - org.apache.commons commons-collections4 From 5c59f43bc901a144a967ef4e5bcd0dd7f826c474 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Wed, 24 Nov 2021 13:07:45 +0000 Subject: [PATCH 257/551] [BAEL-44334] Enhance the process test to shutdown ExecutorService --- .../shell/JavaProcessUnitIntegrationTest.java | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/shell/JavaProcessUnitIntegrationTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/shell/JavaProcessUnitIntegrationTest.java index 53e9364207..9d24dd1578 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/shell/JavaProcessUnitIntegrationTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/shell/JavaProcessUnitIntegrationTest.java @@ -1,12 +1,23 @@ -package com.baeldung.java.shell; +package com.baeldung.shell; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + public class JavaProcessUnitIntegrationTest { private static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().startsWith("windows"); @@ -29,6 +40,18 @@ public class JavaProcessUnitIntegrationTest { private String homeDirectory = System.getProperty("user.home"); + private ExecutorService executorService; + + @Before + public void setUp() { + executorService = Executors.newSingleThreadExecutor(); + } + + @After + public void tearDown() { + executorService.shutdown(); + } + @Test public void givenProcess_whenCreatingViaRuntime_shouldSucceed() throws Exception { Process process; @@ -38,9 +61,13 @@ public class JavaProcessUnitIntegrationTest { process = Runtime.getRuntime().exec(String.format("sh -c ls %s", homeDirectory)); } StreamGobbler streamGobbler = new StreamGobbler(process.getInputStream(), consumer); - Executors.newSingleThreadExecutor().submit(streamGobbler); + + Future future = executorService.submit(streamGobbler); int exitCode = process.waitFor(); - Assert.assertEquals(0, exitCode); + + // verify the stream output from the process + assertDoesNotThrow(() -> future.get(10, TimeUnit.SECONDS)); + assertEquals(0, exitCode); } @Test @@ -54,8 +81,12 @@ public class JavaProcessUnitIntegrationTest { builder.directory(new File(homeDirectory)); Process process = builder.start(); StreamGobbler streamGobbler = new StreamGobbler(process.getInputStream(), consumer); - Executors.newSingleThreadExecutor().submit(streamGobbler); + + Future future = executorService.submit(streamGobbler); int exitCode = process.waitFor(); - Assert.assertEquals(0, exitCode); + + // verify the stream output from the process + assertDoesNotThrow(() -> future.get(10, TimeUnit.SECONDS)); + assertEquals(0, exitCode); } } From 203f7a16bb0c50cb2359e4703153d780cd3a25b9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 24 Nov 2021 22:52:41 +0100 Subject: [PATCH 258/551] JAVA-8362: Copy batchscheduler code to spring-batch-2 --- spring-batch-2/pom.xml | 9 +- .../batchscheduler/SpringBatchScheduler.java | 190 ++++++++++++++++++ .../SpringBatchSchedulerApplication.java | 14 ++ .../baeldung/batchscheduler/model/Book.java | 35 ++++ .../src/main/resources/application.properties | 7 + spring-batch-2/src/main/resources/books.csv | 4 + .../SpringBatchSchedulerIntegrationTest.java | 69 +++++++ spring-batch/repository.sqlite | Bin 73728 -> 73728 bytes 8 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java create mode 100644 spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java create mode 100644 spring-batch-2/src/main/java/com/baeldung/batchscheduler/model/Book.java create mode 100644 spring-batch-2/src/main/resources/books.csv create mode 100644 spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java diff --git a/spring-batch-2/pom.xml b/spring-batch-2/pom.xml index c429c272bd..77779a0fcf 100644 --- a/spring-batch-2/pom.xml +++ b/spring-batch-2/pom.xml @@ -24,7 +24,6 @@ org.hsqldb hsqldb - ${hsqldb.version} runtime @@ -44,11 +43,17 @@ ${spring.batch.version} test + + org.awaitility + awaitility + ${awaitility.version} + test + 4.3.0 - 2.5.1 + 3.1.1 \ No newline at end of file diff --git a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java new file mode 100644 index 0000000000..bfaa044376 --- /dev/null +++ b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java @@ -0,0 +1,190 @@ +package com.baeldung.batchscheduler; + +import com.baeldung.batchscheduler.model.Book; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; +import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.item.file.FlatFileItemReader; +import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder; +import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; +import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.scheduling.TaskScheduler; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.scheduling.support.ScheduledMethodRunnable; + +import javax.sql.DataSource; +import java.util.Date; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +@Configuration +@EnableBatchProcessing +@EnableScheduling +public class SpringBatchScheduler { + + private final Logger logger = LoggerFactory.getLogger(SpringBatchScheduler.class); + + private AtomicBoolean enabled = new AtomicBoolean(true); + + private AtomicInteger batchRunCounter = new AtomicInteger(0); + + private final Map> scheduledTasks = new IdentityHashMap<>(); + + @Autowired + private JobBuilderFactory jobBuilderFactory; + + @Autowired + private StepBuilderFactory stepBuilderFactory; + + @Autowired + private JobLauncher jobLauncher; + + @Scheduled(fixedRate = 2000) + public void launchJob() throws Exception { + Date date = new Date(); + logger.debug("scheduler starts at " + date); + if (enabled.get()) { + JobExecution jobExecution = jobLauncher.run(job(), new JobParametersBuilder().addDate("launchDate", date) + .toJobParameters()); + batchRunCounter.incrementAndGet(); + logger.debug("Batch job ends with status as " + jobExecution.getStatus()); + } + logger.debug("scheduler ends "); + } + + public void stop() { + enabled.set(false); + } + + public void start() { + enabled.set(true); + } + + @Bean + public TaskScheduler poolScheduler() { + return new CustomTaskScheduler(); + } + + private class CustomTaskScheduler extends ThreadPoolTaskScheduler { + + private static final long serialVersionUID = -7142624085505040603L; + + @Override + public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) { + ScheduledFuture future = super.scheduleAtFixedRate(task, period); + + ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task; + scheduledTasks.put(runnable.getTarget(), future); + + return future; + } + + } + + public void cancelFutureSchedulerTasks() { + scheduledTasks.forEach((k, v) -> { + if (k instanceof SpringBatchScheduler) { + v.cancel(false); + } + }); + } + + @Bean + public Job job() { + return jobBuilderFactory.get("job") + .start(readBooks()) + .build(); + } + +// @Bean +// public JobLauncher jobLauncher() throws Exception { +// SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); +// jobLauncher.setJobRepository(jobRepository()); +// jobLauncher.afterPropertiesSet(); +// return jobLauncher; +// } + +// @Bean +// public JobRepository jobRepository() throws Exception { +// JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); +// factory.setDataSource(dataSource()); +// factory.setDatabaseType("HSQL"); +// factory.setTransactionManager(new ResourcelessTransactionManager()); +// return factory.getObject(); +// } + +// @Bean +// public DataSource dataSource() { +// DriverManagerDataSource dataSource = new DriverManagerDataSource(); +// dataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver"); +// dataSource.setUrl("jdbc:hsqldb:mem:testdb"); +// dataSource.setUsername("sa"); +// dataSource.setPassword(""); +// return dataSource; +// } + + @Bean + protected Step readBooks() { + return stepBuilderFactory.get("readBooks") + . chunk(2) + .reader(reader()) + .writer(writer()) + .build(); + } + + @Bean + public FlatFileItemReader reader() { + return new FlatFileItemReaderBuilder().name("bookItemReader") + .resource(new ClassPathResource("books.csv")) + .delimited() + .names(new String[] { "id", "name" }) + .fieldSetMapper(new BeanWrapperFieldSetMapper() { + { + setTargetType(Book.class); + } + }) + .build(); + } + + @Bean + public ItemWriter writer() { + return new ItemWriter() { + + @Override + public void write(List items) throws Exception { + logger.debug("writer..." + items.size()); + for (Book item : items) { + logger.debug(item.toString()); + } + + } + }; + } + + public AtomicInteger getBatchRunCounter() { + return batchRunCounter; + } + +} diff --git a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java new file mode 100644 index 0000000000..5b89163777 --- /dev/null +++ b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java @@ -0,0 +1,14 @@ +package com.baeldung.batchscheduler; + +import com.baeldung.batch.SpringBootBatchProcessingApplication; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBatchSchedulerApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBatchSchedulerApplication.class, args); + } + +} diff --git a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/model/Book.java b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/model/Book.java new file mode 100644 index 0000000000..7deedeb63e --- /dev/null +++ b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/model/Book.java @@ -0,0 +1,35 @@ +package com.baeldung.batchscheduler.model; + +public class Book { + private int id; + private String name; + + public Book() {} + + public Book(int id, String name) { + super(); + this.id = id; + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String toString() { + return "Book [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/spring-batch-2/src/main/resources/application.properties b/spring-batch-2/src/main/resources/application.properties index 0b8c56d3f8..5b34d9e93b 100644 --- a/spring-batch-2/src/main/resources/application.properties +++ b/spring-batch-2/src/main/resources/application.properties @@ -1 +1,8 @@ +spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver +spring.datasource.url=jdbc:hsqldb:mem:testdb;DB_CLOSE_DELAY=-1;hsqldb.tx=mvcc +spring.datasource.username=sa +spring.datasource.password= + +spring.batch.jdbc.initialize-schema=always + file.input=coffee-list.csv \ No newline at end of file diff --git a/spring-batch-2/src/main/resources/books.csv b/spring-batch-2/src/main/resources/books.csv new file mode 100644 index 0000000000..af68e986a2 --- /dev/null +++ b/spring-batch-2/src/main/resources/books.csv @@ -0,0 +1,4 @@ +1,SHARP OBJECTS (MOVIE TIE-IN): A NOVEL +2,ARTEMIS: A NOVEL +3,HER PRETTY FACE +4,ALL WE EVER WANTED \ No newline at end of file diff --git a/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java b/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java new file mode 100644 index 0000000000..64a414fdbf --- /dev/null +++ b/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java @@ -0,0 +1,69 @@ +package com.baeldung.batchscheduler; + +import com.baeldung.batchscheduler.SpringBatchScheduler; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.batch.test.context.SpringBatchTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.PropertySource; +import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.awaitility.Awaitility.await; +import static java.util.concurrent.TimeUnit.*; + +@SpringBatchTest +@SpringBootTest +@DirtiesContext +@PropertySource("classpath:application.properties") +@RunWith(SpringRunner.class) +public class SpringBatchSchedulerIntegrationTest { + + @Autowired + private ApplicationContext context; + + @Test + public void stopJobsWhenSchedulerDisabled() throws Exception { + SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); + await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() + .get())); + schedulerBean.stop(); + await().atLeast(3, SECONDS); + + Assert.assertEquals(2, schedulerBean.getBatchRunCounter() + .get()); + } + + @Test + public void stopJobSchedulerWhenSchedulerDestroyed() throws Exception { + ScheduledAnnotationBeanPostProcessor bean = context.getBean(ScheduledAnnotationBeanPostProcessor.class); + SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); + await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() + .get())); + bean.postProcessBeforeDestruction(schedulerBean, "SpringBatchScheduler"); + await().atLeast(3, SECONDS); + + Assert.assertEquals(2, schedulerBean.getBatchRunCounter() + .get()); + } + + @Test + public void stopJobSchedulerWhenFutureTasksCancelled() throws Exception { + SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); + await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() + .get())); + schedulerBean.cancelFutureSchedulerTasks(); + await().atLeast(3, SECONDS); + + Assert.assertEquals(2, schedulerBean.getBatchRunCounter() + .get()); + } + + +} diff --git a/spring-batch/repository.sqlite b/spring-batch/repository.sqlite index a2b87ffa00f315b4084437ce2f5f639d47469027..b6a954554c9659b0f486c8af45bd69b710e61a0f 100644 GIT binary patch delta 852 zcma)3O-NKx6n;PVzBlvkyZ0)Z|IOq`F%XLL{~|P<@r9W)n$1E>{F&hm{hGm4WLT4% zHZIgx=qjb8MG%y4Aw-mdixwh6n-&HMErihAr4rG56Ana++I;8ZeBU|eo^vw`AhQ6* z%GurViU_;=s&AH-A-u)VW%`JAQ#aWmD`b|WNtl%2Eu%7T6`yw_$k+;^m#!rOAzyze zl=S%gwf;oHn@DMj=2tYYrumMgf&sr<+IM~tgEfw&Gd?}xzq`X0o zlBl(t&Z?+>rsk-Tc8swE;XQ^7lb>{jRN*~?9NNGgZcq?q|6?rLH~wp?WVF^)=L@Jr z-~+6_Di#X30`hfPs%HQYa53P0tiH|{2&kOrk6X036cus2hYdHzBh9@nZQV>rYym|++sE-`e6Zqp6= znZBV@G)>!WvbZ5Gncbd=oD1o1r(K*&vVtK`Z5E5NS&cbnZU*E%1q%%&5yo83WU}{|$?DKd zsB`l+!2UpmHZaHt0$hd@uoF7K7w{Ymngcq)Jq5`O%R&g9P7KYxtPUrSWHD-C%WkAC u+TNY4L5N~4 z(N#zzO0cxhn}alh+F8gV1i`|>gK%6Uq&e_Je<3E zh9$TJZ*U)Hu@j!bhhxZrs}jAPVD(ByL`TN^+|#9U@uH!_X#(r;hCbZE33lTGmLRRe z{h-o4-A!D!aC6Y`ZmkfvW6T_VmtKKVZbzs&V0b^xW-i-IbL78_L}fT&_8IQ@Olop| z`lCBPmHjd^o=r{2?@1ceIG^AHR&W=WF{^P7Jb|xqKS23&LrtwVD-*bG+;P6y9Sw6b zFG^O`it<@jR*B#ivo?lpMmATxtHZcAw&p6iT8}0~fCOZKG!jCja0otQ9e?8^o?{7f z_(?dr`^$2+Gy46(2a<13E-I(=6!HFE*oq$gLH53&-Y$4DB&Z Date: Wed, 24 Nov 2021 23:18:00 +0100 Subject: [PATCH 259/551] JAVA-8362: Switch to H2 db --- spring-batch-2/pom.xml | 5 ++- .../batchscheduler/SpringBatchScheduler.java | 36 ++----------------- .../src/main/resources/application.properties | 7 +--- .../SpringBatchSchedulerIntegrationTest.java | 2 +- 4 files changed, 6 insertions(+), 44 deletions(-) diff --git a/spring-batch-2/pom.xml b/spring-batch-2/pom.xml index 77779a0fcf..12d31aca14 100644 --- a/spring-batch-2/pom.xml +++ b/spring-batch-2/pom.xml @@ -22,9 +22,8 @@ spring-boot-starter-batch - org.hsqldb - hsqldb - runtime + com.h2database + h2 org.springframework.boot diff --git a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java index bfaa044376..c830a41855 100644 --- a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java +++ b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java @@ -11,26 +11,20 @@ import org.springframework.batch.core.configuration.annotation.EnableBatchProces import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; -import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.file.FlatFileItemReader; import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder; import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.support.ScheduledMethodRunnable; -import javax.sql.DataSource; import java.util.Date; import java.util.IdentityHashMap; import java.util.List; @@ -113,38 +107,12 @@ public class SpringBatchScheduler { @Bean public Job job() { - return jobBuilderFactory.get("job") + return jobBuilderFactory + .get("job") .start(readBooks()) .build(); } -// @Bean -// public JobLauncher jobLauncher() throws Exception { -// SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); -// jobLauncher.setJobRepository(jobRepository()); -// jobLauncher.afterPropertiesSet(); -// return jobLauncher; -// } - -// @Bean -// public JobRepository jobRepository() throws Exception { -// JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); -// factory.setDataSource(dataSource()); -// factory.setDatabaseType("HSQL"); -// factory.setTransactionManager(new ResourcelessTransactionManager()); -// return factory.getObject(); -// } - -// @Bean -// public DataSource dataSource() { -// DriverManagerDataSource dataSource = new DriverManagerDataSource(); -// dataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver"); -// dataSource.setUrl("jdbc:hsqldb:mem:testdb"); -// dataSource.setUsername("sa"); -// dataSource.setPassword(""); -// return dataSource; -// } - @Bean protected Step readBooks() { return stepBuilderFactory.get("readBooks") diff --git a/spring-batch-2/src/main/resources/application.properties b/spring-batch-2/src/main/resources/application.properties index 5b34d9e93b..8d21bbe1c0 100644 --- a/spring-batch-2/src/main/resources/application.properties +++ b/spring-batch-2/src/main/resources/application.properties @@ -1,8 +1,3 @@ -spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver -spring.datasource.url=jdbc:hsqldb:mem:testdb;DB_CLOSE_DELAY=-1;hsqldb.tx=mvcc -spring.datasource.username=sa -spring.datasource.password= - -spring.batch.jdbc.initialize-schema=always +#spring.batch.jdbc.initialize-schema=embedded file.input=coffee-list.csv \ No newline at end of file diff --git a/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java b/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java index 64a414fdbf..61e5a1dd74 100644 --- a/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java +++ b/spring-batch-2/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java @@ -29,7 +29,7 @@ public class SpringBatchSchedulerIntegrationTest { private ApplicationContext context; @Test - public void stopJobsWhenSchedulerDisabled() throws Exception { + public void stopJobsWhenSchedulerDisabled() { SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() .get())); From 4dc3a8b83ab37e38355d412689773d7ca5f4c6d9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 24 Nov 2021 23:20:22 +0100 Subject: [PATCH 260/551] JAVA-8362: Cleanup --- .../batchscheduler/SpringBatchSchedulerApplication.java | 1 - spring-batch-2/src/main/resources/application.properties | 2 -- 2 files changed, 3 deletions(-) diff --git a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java index 5b89163777..349a359efb 100644 --- a/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java +++ b/spring-batch-2/src/main/java/com/baeldung/batchscheduler/SpringBatchSchedulerApplication.java @@ -1,6 +1,5 @@ package com.baeldung.batchscheduler; -import com.baeldung.batch.SpringBootBatchProcessingApplication; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-batch-2/src/main/resources/application.properties b/spring-batch-2/src/main/resources/application.properties index 8d21bbe1c0..0b8c56d3f8 100644 --- a/spring-batch-2/src/main/resources/application.properties +++ b/spring-batch-2/src/main/resources/application.properties @@ -1,3 +1 @@ -#spring.batch.jdbc.initialize-schema=embedded - file.input=coffee-list.csv \ No newline at end of file From dcb9072f2a3d77b7733aeb8087fc5cec75783825 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 25 Nov 2021 09:18:23 +0100 Subject: [PATCH 261/551] JAVA-8362: Remove batchscheduler code from spring-batch module --- .../batchscheduler/SpringBatchScheduler.java | 184 ------------------ .../baeldung/batchscheduler/model/Book.java | 35 ---- .../SpringBatchSchedulerIntegrationTest.java | 61 ------ 3 files changed, 280 deletions(-) delete mode 100644 spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java delete mode 100644 spring-batch/src/main/java/com/baeldung/batchscheduler/model/Book.java delete mode 100644 spring-batch/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java diff --git a/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java b/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java deleted file mode 100644 index cff4e96c89..0000000000 --- a/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.baeldung.batchscheduler; - -import com.baeldung.batchscheduler.model.Book; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.Step; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; -import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; -import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; -import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; -import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.file.FlatFileItemReader; -import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder; -import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import org.springframework.scheduling.support.ScheduledMethodRunnable; - -import javax.sql.DataSource; -import java.util.Date; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -@Configuration -@EnableBatchProcessing -@EnableScheduling -public class SpringBatchScheduler { - - private final Logger logger = LoggerFactory.getLogger(SpringBatchScheduler.class); - - private AtomicBoolean enabled = new AtomicBoolean(true); - - private AtomicInteger batchRunCounter = new AtomicInteger(0); - - private final Map> scheduledTasks = new IdentityHashMap<>(); - - @Autowired - private JobBuilderFactory jobBuilderFactory; - - @Autowired - private StepBuilderFactory stepBuilderFactory; - - @Scheduled(fixedRate = 2000) - public void launchJob() throws Exception { - Date date = new Date(); - logger.debug("scheduler starts at " + date); - if (enabled.get()) { - JobExecution jobExecution = jobLauncher().run(job(), new JobParametersBuilder().addDate("launchDate", date) - .toJobParameters()); - batchRunCounter.incrementAndGet(); - logger.debug("Batch job ends with status as " + jobExecution.getStatus()); - } - logger.debug("scheduler ends "); - } - - public void stop() { - enabled.set(false); - } - - public void start() { - enabled.set(true); - } - - @Bean - public TaskScheduler poolScheduler() { - return new CustomTaskScheduler(); - } - - private class CustomTaskScheduler extends ThreadPoolTaskScheduler { - - private static final long serialVersionUID = -7142624085505040603L; - - @Override - public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) { - ScheduledFuture future = super.scheduleAtFixedRate(task, period); - - ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task; - scheduledTasks.put(runnable.getTarget(), future); - - return future; - } - - } - - public void cancelFutureSchedulerTasks() { - scheduledTasks.forEach((k, v) -> { - if (k instanceof SpringBatchScheduler) { - v.cancel(false); - } - }); - } - - @Bean - public Job job() { - return jobBuilderFactory.get("job") - .start(readBooks()) - .build(); - } - - @Bean - public JobLauncher jobLauncher() throws Exception { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); - jobLauncher.setJobRepository(jobRepository()); - jobLauncher.afterPropertiesSet(); - return jobLauncher; - } - - @Bean - public JobRepository jobRepository() throws Exception { - JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); - factory.setDataSource(dataSource()); - factory.setTransactionManager(new ResourcelessTransactionManager()); - return factory.getObject(); - } - - @Bean - public DataSource dataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("org.sqlite.JDBC"); - dataSource.setUrl("jdbc:sqlite:repository.sqlite"); - return dataSource; - } - - @Bean - protected Step readBooks() { - return stepBuilderFactory.get("readBooks") - . chunk(2) - .reader(reader()) - .writer(writer()) - .build(); - } - - @Bean - public FlatFileItemReader reader() { - return new FlatFileItemReaderBuilder().name("bookItemReader") - .resource(new ClassPathResource("books.csv")) - .delimited() - .names(new String[] { "id", "name" }) - .fieldSetMapper(new BeanWrapperFieldSetMapper() { - { - setTargetType(Book.class); - } - }) - .build(); - } - - @Bean - public ItemWriter writer() { - return new ItemWriter() { - - @Override - public void write(List items) throws Exception { - logger.debug("writer..." + items.size()); - for (Book item : items) { - logger.debug(item.toString()); - } - - } - }; - } - - public AtomicInteger getBatchRunCounter() { - return batchRunCounter; - } - -} diff --git a/spring-batch/src/main/java/com/baeldung/batchscheduler/model/Book.java b/spring-batch/src/main/java/com/baeldung/batchscheduler/model/Book.java deleted file mode 100644 index 8ee986c729..0000000000 --- a/spring-batch/src/main/java/com/baeldung/batchscheduler/model/Book.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.batchscheduler.model; - -public class Book { - private int id; - private String name; - - public Book() {} - - public Book(int id, String name) { - super(); - this.id = id; - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String toString() { - return "Book [id=" + id + ", name=" + name + "]"; - } - -} diff --git a/spring-batch/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java b/spring-batch/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java deleted file mode 100644 index 81877fbc39..0000000000 --- a/spring-batch/src/test/java/com/baeldung/batchscheduler/SpringBatchSchedulerIntegrationTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.baeldung.batchscheduler; - -import com.baeldung.batchscheduler.SpringBatchScheduler; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.awaitility.Awaitility.await; -import static java.util.concurrent.TimeUnit.*; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = SpringBatchScheduler.class) -public class SpringBatchSchedulerIntegrationTest { - - @Autowired - private ApplicationContext context; - - @Test - public void stopJobsWhenSchedulerDisabled() throws Exception { - SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); - await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() - .get())); - schedulerBean.stop(); - await().atLeast(3, SECONDS); - - Assert.assertEquals(2, schedulerBean.getBatchRunCounter() - .get()); - } - - @Test - public void stopJobSchedulerWhenSchedulerDestroyed() throws Exception { - ScheduledAnnotationBeanPostProcessor bean = context.getBean(ScheduledAnnotationBeanPostProcessor.class); - SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); - await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() - .get())); - bean.postProcessBeforeDestruction(schedulerBean, "SpringBatchScheduler"); - await().atLeast(3, SECONDS); - - Assert.assertEquals(2, schedulerBean.getBatchRunCounter() - .get()); - } - - @Test - public void stopJobSchedulerWhenFutureTasksCancelled() throws Exception { - SpringBatchScheduler schedulerBean = context.getBean(SpringBatchScheduler.class); - await().untilAsserted(() -> Assert.assertEquals(2, schedulerBean.getBatchRunCounter() - .get())); - schedulerBean.cancelFutureSchedulerTasks(); - await().atLeast(3, SECONDS); - - Assert.assertEquals(2, schedulerBean.getBatchRunCounter() - .get()); - } - - -} From 960048954292ec60c728967c62b90fc6fab306ee Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 25 Nov 2021 09:22:07 +0100 Subject: [PATCH 262/551] JAVA-8362: Remove awaitility dependency --- spring-batch/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spring-batch/pom.xml b/spring-batch/pom.xml index 9879a4777f..32126fec9b 100644 --- a/spring-batch/pom.xml +++ b/spring-batch/pom.xml @@ -82,12 +82,6 @@ hsqldb runtime - - org.awaitility - awaitility - ${awaitility.version} - test - @@ -97,7 +91,6 @@ 4.1 2.3.1 2.12.3 - 3.1.1 \ No newline at end of file From 6bff29f150c40d34d9027a49c0d85efb68324aee Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 25 Nov 2021 09:25:07 +0100 Subject: [PATCH 263/551] JAVA-8362: Update README.md files --- spring-batch-2/README.md | 2 ++ spring-batch/README.md | 2 +- spring-batch/src/main/resources/books.csv | 4 ---- 3 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 spring-batch/src/main/resources/books.csv diff --git a/spring-batch-2/README.md b/spring-batch-2/README.md index 08bf1933db..9b5d59f0b9 100644 --- a/spring-batch-2/README.md +++ b/spring-batch-2/README.md @@ -1,3 +1,5 @@ ### Relevant Articles: - [Spring Boot With Spring Batch](https://www.baeldung.com/spring-boot-spring-batch) +- [How to Trigger and Stop a Scheduled Spring Batch Job](https://www.baeldung.com/spring-batch-start-stop-job) +- More articles [[<-- prev]](/spring-batch) diff --git a/spring-batch/README.md b/spring-batch/README.md index 3a89459629..b87a2149a0 100644 --- a/spring-batch/README.md +++ b/spring-batch/README.md @@ -7,8 +7,8 @@ This module contains articles about Spring Batch - [Introduction to Spring Batch](https://www.baeldung.com/introduction-to-spring-batch) - [Spring Batch using Partitioner](https://www.baeldung.com/spring-batch-partitioner) - [Spring Batch – Tasklets vs Chunks](https://www.baeldung.com/spring-batch-tasklet-chunk) -- [How to Trigger and Stop a Scheduled Spring Batch Job](https://www.baeldung.com/spring-batch-start-stop-job) - [Configuring Skip Logic in Spring Batch](https://www.baeldung.com/spring-batch-skip-logic) - [Testing a Spring Batch Job](https://www.baeldung.com/spring-batch-testing-job) - [Configuring Retry Logic in Spring Batch](https://www.baeldung.com/spring-batch-retry-logic) - [Conditional Flow in Spring Batch](https://www.baeldung.com/spring-batch-conditional-flow) +- More articles [[next -->]](/spring-batch-2) diff --git a/spring-batch/src/main/resources/books.csv b/spring-batch/src/main/resources/books.csv deleted file mode 100644 index af68e986a2..0000000000 --- a/spring-batch/src/main/resources/books.csv +++ /dev/null @@ -1,4 +0,0 @@ -1,SHARP OBJECTS (MOVIE TIE-IN): A NOVEL -2,ARTEMIS: A NOVEL -3,HER PRETTY FACE -4,ALL WE EVER WANTED \ No newline at end of file From 55e5fd172cc3b5c964861709075d7f24942fc44f Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 25 Nov 2021 12:12:18 +0200 Subject: [PATCH 264/551] Delete README.md --- .../src/test/java/com/baeldung/applicationcontext/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 spring-core/src/test/java/com/baeldung/applicationcontext/README.md diff --git a/spring-core/src/test/java/com/baeldung/applicationcontext/README.md b/spring-core/src/test/java/com/baeldung/applicationcontext/README.md deleted file mode 100644 index a626417d47..0000000000 --- a/spring-core/src/test/java/com/baeldung/applicationcontext/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Intro to the Spring ClassPathXmlApplicationContext](http://www.baeldung.com/spring-classpathxmlapplicationcontext) From 5b50b36e552fa8e13a6595106ad7c38b15168090 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 25 Nov 2021 12:12:38 +0200 Subject: [PATCH 265/551] Update README.md --- spring-core/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-core/README.md b/spring-core/README.md index b8d46f6b34..3f0fe4b4e4 100644 --- a/spring-core/README.md +++ b/spring-core/README.md @@ -11,5 +11,6 @@ This module contains articles about core Spring functionality - [Spring Application Context Events](https://www.baeldung.com/spring-context-events) - [What is a Spring Bean?](https://www.baeldung.com/spring-bean) - [Spring PostConstruct and PreDestroy Annotations](https://www.baeldung.com/spring-postconstruct-predestroy) +- [Intro to the Spring ClassPathXmlApplicationContext](http://www.baeldung.com/spring-classpathxmlapplicationcontext) - More articles: [[next -->]](/spring-core-2) From 8d8ae5daa9b228828f48bfe5c1645b8a009c9660 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 25 Nov 2021 13:10:58 +0100 Subject: [PATCH 266/551] JAVA-8363: Move etag code to spring-boot-mvc-3 --- .../src/main/java/com/baeldung/mime/Foo.java | 93 +++++++++++++++++++ .../java/com/baeldung/mime/WebConfig.java | 28 ++++++ .../java/com/baeldung/mime/FooLiveTest.java | 7 +- .../com/baeldung/mime/JacksonMarshaller.java | 2 +- .../com/baeldung/mime/XStreamMarshaller.java | 2 +- spring-boot-modules/spring-boot-mvc-3/pom.xml | 8 ++ .../src/main/java/com/baeldung/etag/Foo.java | 3 +- .../java/com/baeldung/etag/FooController.java | 4 +- .../main/java/com/baeldung/etag/FooDao.java | 0 .../etag/SpringBootEtagApplication.java | 0 .../java/com/baeldung/etag/WebConfig.java | 0 .../src/main/resources/WEB-INF/web.xml | 0 .../baeldung/etag/EtagIntegrationTest.java | 20 ++-- 13 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/Foo.java create mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/main/java/com/baeldung/etag/Foo.java (99%) rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/main/java/com/baeldung/etag/FooController.java (99%) rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/main/java/com/baeldung/etag/FooDao.java (100%) rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/main/java/com/baeldung/etag/SpringBootEtagApplication.java (100%) rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/main/java/com/baeldung/etag/WebConfig.java (100%) rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/main/resources/WEB-INF/web.xml (100%) rename spring-boot-modules/{spring-boot-mvc-2 => spring-boot-mvc-3}/src/test/java/com/baeldung/etag/EtagIntegrationTest.java (99%) diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/Foo.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/Foo.java new file mode 100644 index 0000000000..a8e379fc79 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/Foo.java @@ -0,0 +1,93 @@ +package com.baeldung.mime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Version; +import java.io.Serializable; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + @Version + private long version; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version = version; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } +} diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java new file mode 100644 index 0000000000..2c9680f628 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java @@ -0,0 +1,28 @@ +package com.baeldung.mime; + +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.filter.ShallowEtagHeaderFilter; + +@Configuration +public class WebConfig { + + // Etags + + // If we're not using Spring Boot we can make use of + // AbstractAnnotationConfigDispatcherServletInitializer#getServletFilters + @Bean + public FilterRegistrationBean shallowEtagHeaderFilter() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>( new ShallowEtagHeaderFilter()); + filterRegistrationBean.addUrlPatterns("/foos/*"); + filterRegistrationBean.setName("etagFilter"); + return filterRegistrationBean; + } + + // We can also just declare the filter directly + // @Bean + // public ShallowEtagHeaderFilter shallowEtagHeaderFilter() { + // return new ShallowEtagHeaderFilter(); + // } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java index e65b106ead..f4aa96b53a 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java +++ b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java @@ -14,15 +14,12 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.baeldung.etag.Foo; -import com.baeldung.etag.WebConfig; - import io.restassured.RestAssured; import io.restassured.response.Response; @RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes= WebConfig.class, webEnvironment = WebEnvironment.RANDOM_PORT) -@ComponentScan({"com.baeldung.mime", "com.baeldung.etag"}) +@SpringBootTest(classes = WebConfig.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@ComponentScan({"com.baeldung.mime"}) @EnableAutoConfiguration @ActiveProfiles("test") public class FooLiveTest { diff --git a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/JacksonMarshaller.java b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/JacksonMarshaller.java index 9dee0ef2cd..c6d14a9427 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/JacksonMarshaller.java +++ b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/JacksonMarshaller.java @@ -7,7 +7,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; -import com.baeldung.etag.Foo; +import com.baeldung.mime.Foo; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/XStreamMarshaller.java b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/XStreamMarshaller.java index 2c67694e83..8a4188ceca 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/XStreamMarshaller.java +++ b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/XStreamMarshaller.java @@ -4,7 +4,7 @@ import java.util.List; import org.springframework.http.MediaType; -import com.baeldung.etag.Foo; +import com.baeldung.mime.Foo; import com.thoughtworks.xstream.XStream; public final class XStreamMarshaller implements IMarshaller { diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index dee217862d..43a492786e 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -27,6 +27,14 @@ org.springframework.boot spring-boot-starter-thymeleaf + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + commons-io commons-io diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/Foo.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/Foo.java similarity index 99% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/Foo.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/Foo.java index e553ca1b72..9790bca663 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/Foo.java +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/Foo.java @@ -1,13 +1,12 @@ package com.baeldung.etag; -import java.io.Serializable; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Version; +import java.io.Serializable; @Entity public class Foo implements Serializable { diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/FooController.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/FooController.java similarity index 99% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/FooController.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/FooController.java index 58f366501d..d40a5e7809 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/FooController.java +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/FooController.java @@ -1,7 +1,5 @@ package com.baeldung.etag; -import javax.servlet.http.HttpServletResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -16,6 +14,8 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; +import javax.servlet.http.HttpServletResponse; + @RestController @RequestMapping(value = "/foos") public class FooController { diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/FooDao.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/FooDao.java similarity index 100% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/FooDao.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/FooDao.java diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/SpringBootEtagApplication.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/SpringBootEtagApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/SpringBootEtagApplication.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/SpringBootEtagApplication.java diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/WebConfig.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/WebConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/etag/WebConfig.java rename to spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/etag/WebConfig.java diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/resources/WEB-INF/web.xml b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/WEB-INF/web.xml similarity index 100% rename from spring-boot-modules/spring-boot-mvc-2/src/main/resources/WEB-INF/web.xml rename to spring-boot-modules/spring-boot-mvc-3/src/main/resources/WEB-INF/web.xml diff --git a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/etag/EtagIntegrationTest.java b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/etag/EtagIntegrationTest.java similarity index 99% rename from spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/etag/EtagIntegrationTest.java rename to spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/etag/EtagIntegrationTest.java index 88c5ae1686..97de6d06f1 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/etag/EtagIntegrationTest.java +++ b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/etag/EtagIntegrationTest.java @@ -1,10 +1,10 @@ package com.baeldung.etag; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import io.restassured.response.Response; import org.assertj.core.util.Preconditions; import org.junit.Ignore; import org.junit.Test; @@ -18,12 +18,10 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.context.junit4.SpringRunner; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.restassured.RestAssured; -import io.restassured.http.ContentType; -import io.restassured.response.Response; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) From 49ffde8b48b9f475173f2ba5dacdb0d23070c6fe Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 25 Nov 2021 13:25:40 +0100 Subject: [PATCH 267/551] JAVA-8363: Fix FooLiveTest - separate mime from etag code --- .../java/com/baeldung/mime/FooController.java | 36 +++++++++++++++++++ .../main/java/com/baeldung/mime/FooDao.java | 8 +++++ .../java/com/baeldung/mime/WebConfig.java | 28 --------------- .../java/com/baeldung/mime/FooLiveTest.java | 6 ++-- 4 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooController.java create mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooDao.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooController.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooController.java new file mode 100644 index 0000000000..d7da9bd849 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooController.java @@ -0,0 +1,36 @@ +package com.baeldung.mime; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import javax.servlet.http.HttpServletResponse; + +@RestController +@RequestMapping(value = "/foos") +public class FooController { + + @Autowired + private FooDao fooDao; + + @GetMapping(value = "/{id}") + public Foo findById(@PathVariable("id") final Long id, final HttpServletResponse response) { + return fooDao.findById(id).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND)); + } + + @PostMapping + @ResponseStatus(HttpStatus.CREATED) + public Foo create(@RequestBody final Foo resource, final HttpServletResponse response) { + return fooDao.save(resource); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooDao.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooDao.java new file mode 100644 index 0000000000..9fc99e1124 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/FooDao.java @@ -0,0 +1,8 @@ +package com.baeldung.mime; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface FooDao extends CrudRepository{ +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java deleted file mode 100644 index 2c9680f628..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/mime/WebConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.mime; - -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.filter.ShallowEtagHeaderFilter; - -@Configuration -public class WebConfig { - - // Etags - - // If we're not using Spring Boot we can make use of - // AbstractAnnotationConfigDispatcherServletInitializer#getServletFilters - @Bean - public FilterRegistrationBean shallowEtagHeaderFilter() { - FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>( new ShallowEtagHeaderFilter()); - filterRegistrationBean.addUrlPatterns("/foos/*"); - filterRegistrationBean.setName("etagFilter"); - return filterRegistrationBean; - } - - // We can also just declare the filter directly - // @Bean - // public ShallowEtagHeaderFilter shallowEtagHeaderFilter() { - // return new ShallowEtagHeaderFilter(); - // } -} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java index f4aa96b53a..86dd4915b4 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java +++ b/spring-boot-modules/spring-boot-mvc-2/src/test/java/com/baeldung/mime/FooLiveTest.java @@ -18,7 +18,7 @@ import io.restassured.RestAssured; import io.restassured.response.Response; @RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = WebConfig.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = FooController.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ComponentScan({"com.baeldung.mime"}) @EnableAutoConfiguration @ActiveProfiles("test") @@ -44,12 +44,12 @@ public class FooLiveTest { createAsUri(resource); } - private final String createAsUri(final Foo resource) { + private String createAsUri(final Foo resource) { final Response response = createAsResponse(resource); return getURL() + "/" + response.getBody().as(Foo.class).getId(); } - private final Response createAsResponse(final Foo resource) { + private Response createAsResponse(final Foo resource) { final String resourceAsString = marshaller.encode(resource); return RestAssured.given() From e3ba14139ed71ea0b2639f0287cac938f69cee8f Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 25 Nov 2021 13:26:46 +0100 Subject: [PATCH 268/551] JAVA-8363: Update README.md files --- spring-boot-modules/spring-boot-mvc-2/README.md | 1 - spring-boot-modules/spring-boot-mvc-3/README.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-mvc-2/README.md b/spring-boot-modules/spring-boot-mvc-2/README.md index f9becb721f..0d0e05daf0 100644 --- a/spring-boot-modules/spring-boot-mvc-2/README.md +++ b/spring-boot-modules/spring-boot-mvc-2/README.md @@ -7,7 +7,6 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) - [Specify an Array of Strings as Body Parameters in Swagger](https://www.baeldung.com/swagger-body-array-of-strings) - [Swagger @ApiParam vs @ApiModelProperty](https://www.baeldung.com/swagger-apiparam-vs-apimodelproperty) -- [ETags for REST with Spring](https://www.baeldung.com/etags-for-rest-with-spring) - [Testing REST with multiple MIME types](https://www.baeldung.com/testing-rest-api-with-multiple-media-types) - [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) - [Spring Boot Consuming and Producing JSON](https://www.baeldung.com/spring-boot-json) diff --git a/spring-boot-modules/spring-boot-mvc-3/README.md b/spring-boot-modules/spring-boot-mvc-3/README.md index f9c6989b3c..fa24ac11ed 100644 --- a/spring-boot-modules/spring-boot-mvc-3/README.md +++ b/spring-boot-modules/spring-boot-mvc-3/README.md @@ -10,4 +10,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Differences in @Valid and @Validated Annotations in Spring](https://www.baeldung.com/spring-valid-vs-validated) - [CharacterEncodingFilter In SpringBoot](https://www.baeldung.com/spring-boot-characterencodingfilter) - [HandlerInterceptors vs. Filters in Spring MVC](https://www.baeldung.com/spring-mvc-handlerinterceptor-vs-filter) +- [ETags for REST with Spring](https://www.baeldung.com/etags-for-rest-with-spring) - More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc-2) From b045b7fe8309076d706fc9bd7568fda48d525404 Mon Sep 17 00:00:00 2001 From: Yavuz Tas <12643010+yavuztas@users.noreply.github.com> Date: Thu, 25 Nov 2021 17:45:26 +0100 Subject: [PATCH 269/551] BAEL-5192 Code samples for the article (#11483) * BAEL-5192 implement code samples * BAEL-5192 simplify some methods * BAEL-5192 remove duplicated test method Co-authored-by: Yavuz Tas --- .../baeldung/jackson/booleanAsInt/Game.java | 49 +++++++ .../GameAnnotatedByJsonFormat.java | 56 ++++++++ ...meAnnotatedByJsonSerializeDeserialize.java | 58 ++++++++ .../NumericBooleanDeserializer.java | 23 +++ .../NumericBooleanSerializer.java | 15 ++ .../BooleanAsIntegerUnitTest.java | 132 ++++++++++++++++++ 6 files changed, 333 insertions(+) create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/Game.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonFormat.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonSerializeDeserialize.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanDeserializer.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanSerializer.java create mode 100644 jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/booleanAsInt/BooleanAsIntegerUnitTest.java diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/Game.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/Game.java new file mode 100644 index 0000000000..0ad77640d4 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/Game.java @@ -0,0 +1,49 @@ +package com.baeldung.jackson.booleanAsInt; + +public class Game { + + private Long id; + private String name; + private Boolean paused; + private Boolean over; + + public Game() { + } + + public Game(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean isPaused() { + return paused; + } + + public void setPaused(Boolean paused) { + this.paused = paused; + } + + public Boolean isOver() { + return over; + } + + public void setOver(Boolean over) { + this.over = over; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonFormat.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonFormat.java new file mode 100644 index 0000000000..b97625fa6b --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonFormat.java @@ -0,0 +1,56 @@ +package com.baeldung.jackson.booleanAsInt; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonFormat.Shape; + +public class GameAnnotatedByJsonFormat { + + private Long id; + private String name; + + @JsonFormat(shape = Shape.NUMBER) + private boolean paused; + + @JsonFormat(shape = Shape.NUMBER) + private boolean over; + + public GameAnnotatedByJsonFormat() { + } + + public GameAnnotatedByJsonFormat(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isPaused() { + return paused; + } + + public void setPaused(boolean paused) { + this.paused = paused; + } + + public boolean isOver() { + return over; + } + + public void setOver(boolean over) { + this.over = over; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonSerializeDeserialize.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonSerializeDeserialize.java new file mode 100644 index 0000000000..50c6d96009 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/GameAnnotatedByJsonSerializeDeserialize.java @@ -0,0 +1,58 @@ +package com.baeldung.jackson.booleanAsInt; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +public class GameAnnotatedByJsonSerializeDeserialize { + + private Long id; + private String name; + + @JsonSerialize(using = NumericBooleanSerializer.class) + @JsonDeserialize(using = NumericBooleanDeserializer.class) + private Boolean paused; + + @JsonSerialize(using = NumericBooleanSerializer.class) + @JsonDeserialize(using = NumericBooleanDeserializer.class) + private Boolean over; + + public GameAnnotatedByJsonSerializeDeserialize() { + } + + public GameAnnotatedByJsonSerializeDeserialize(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean isPaused() { + return paused; + } + + public void setPaused(Boolean paused) { + this.paused = paused; + } + + public Boolean isOver() { + return over; + } + + public void setOver(Boolean over) { + this.over = over; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanDeserializer.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanDeserializer.java new file mode 100644 index 0000000000..e9cb41e91d --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanDeserializer.java @@ -0,0 +1,23 @@ +package com.baeldung.jackson.booleanAsInt; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; + +public class NumericBooleanDeserializer extends JsonDeserializer { + + @Override + public Boolean deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException { + if ("1".equals(p.getText())) { + return Boolean.TRUE; + } + if ("0".equals(p.getText())) { + return Boolean.FALSE; + } + // for other than "1" or "0" throw exception by using Jackson internals + throw ctxt.weirdStringException(p.getText(), Boolean.class, "only \"1\" or \"0\" recognized"); + } + +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanSerializer.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanSerializer.java new file mode 100644 index 0000000000..e9f7112b53 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/booleanAsInt/NumericBooleanSerializer.java @@ -0,0 +1,15 @@ +package com.baeldung.jackson.booleanAsInt; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; + +public class NumericBooleanSerializer extends JsonSerializer { + + @Override + public void serialize(Boolean value, JsonGenerator gen, SerializerProvider serializers) + throws IOException { + gen.writeString(value ? "1" : "0"); + } +} diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/booleanAsInt/BooleanAsIntegerUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/booleanAsInt/BooleanAsIntegerUnitTest.java new file mode 100644 index 0000000000..976f3f4915 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/booleanAsInt/BooleanAsIntegerUnitTest.java @@ -0,0 +1,132 @@ +package com.baeldung.jackson.booleanAsInt; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonFormat.Shape; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.exc.InvalidFormatException; +import com.fasterxml.jackson.databind.module.SimpleModule; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BooleanAsIntegerUnitTest { + + private ObjectMapper mapper; + + @BeforeEach + public void setup() { + mapper = new ObjectMapper(); + } + + @Test + public void givenBoolean_serializedAsInteger() throws Exception { + GameAnnotatedByJsonFormat + game = new GameAnnotatedByJsonFormat(1L, "My Game"); + game.setPaused(true); + game.setOver(false); + String json = mapper.writeValueAsString(game); + + assertThat(json) + .isEqualTo("{\"id\":1,\"name\":\"My Game\",\"paused\":1,\"over\":0}"); + } + + @Test + public void givenInteger_deserializedAsBooleanByDefault() throws Exception { + // Integer "1" and "0" values deserialized correctly out of the box. + // No configuration or @JsonFormat annotation needed. + String json = "{\"id\":1,\"name\":\"My Game\",\"paused\":1,\"over\":0}"; + Game game = mapper.readValue(json, Game.class); + + assertThat(game.isPaused()).isEqualTo(true); + assertThat(game.isOver()).isEqualTo(false); + } + + @Test + public void givenBoolean_serializedAsIntegerGlobally() throws Exception { + // global configuration override for the type Boolean + mapper.configOverride(Boolean.class) + .setFormat(JsonFormat.Value.forShape(Shape.NUMBER)); + + Game game = new Game(1L, "My Game"); + game.setPaused(true); + game.setOver(false); + String json = mapper.writeValueAsString(game); + + assertThat(json) + .isEqualTo("{\"id\":1,\"name\":\"My Game\",\"paused\":1,\"over\":0}"); + } + + @Test + public void givenBooleanWithCustomSerializer_serializedAsNumericString() throws Exception { + GameAnnotatedByJsonSerializeDeserialize + game = new GameAnnotatedByJsonSerializeDeserialize(1L, "My Game"); + game.setPaused(true); + game.setOver(false); + String json = mapper.writeValueAsString(game); + + assertThat(json) + .isEqualTo("{\"id\":1,\"name\":\"My Game\",\"paused\":\"1\",\"over\":\"0\"}"); + } + + @Test + public void givenNumericStringWithCustomDeserializer_deserializedAsBoolean() throws Exception { + String json = "{\"id\":1,\"name\":\"My Game\",\"paused\":\"1\",\"over\":\"0\"}"; + GameAnnotatedByJsonSerializeDeserialize + game = mapper.readValue(json, GameAnnotatedByJsonSerializeDeserialize.class); + + assertThat(game.isPaused()).isEqualTo(true); + assertThat(game.isOver()).isEqualTo(false); + } + + @Test + public void givenBooleanWithCustomSerializer_serializedAsNumericStringGlobally() throws Exception { + // setting serializers globally + SimpleModule module = new SimpleModule(); + module.addSerializer(Boolean.class, new NumericBooleanSerializer()); + mapper.registerModule(module); + + Game game = new Game(1L, "My Game"); + game.setPaused(true); + game.setOver(false); + String json = mapper.writeValueAsString(game); + + assertThat(json) + .isEqualTo("{\"id\":1,\"name\":\"My Game\",\"paused\":\"1\",\"over\":\"0\"}"); + } + + @Test + public void givenNumericStringWithCustomDeserializer_deserializedAsBooleanGlobally() throws Exception { + // setting deserializers globally + SimpleModule module = new SimpleModule(); + module.addDeserializer(Boolean.class, new NumericBooleanDeserializer()); + mapper.registerModule(module); + + String json = "{\"id\":1,\"name\":\"My Game\",\"paused\":\"1\",\"over\":\"0\"}"; + Game game = mapper.readValue(json, Game.class); + + assertThat(game.isPaused()).isEqualTo(true); + assertThat(game.isOver()).isEqualTo(false); + } + + @Test + public void givenInvalidStringWithCustomDeserializer_throwsInvalidFormatException() { + // another number other than "1" or "0" + String json = "{\"id\":1,\"name\":\"My Game\",\"paused\":\"5\"}"; + InvalidFormatException e = Assertions.assertThrows( + InvalidFormatException.class, () -> mapper.readValue(json, GameAnnotatedByJsonSerializeDeserialize.class) + ); + + assertThat(e.getValue()).isEqualTo("5"); + + // non-numeric string + String json2 = "{\"id\":1,\"name\":\"My Game\",\"paused\":\"xxx\"}"; + InvalidFormatException e2 = Assertions.assertThrows( + InvalidFormatException.class, () -> mapper.readValue(json2, GameAnnotatedByJsonSerializeDeserialize.class) + ); + + assertThat(e2.getValue()).isEqualTo("xxx"); + } + +} From 6b178042123062e649c823a248093582d11c435d Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Thu, 25 Nov 2021 19:05:06 +0000 Subject: [PATCH 270/551] [BAEL-44346] Update to use ReaderInputStream from Commons --- .../readertox/JavaReaderToXUnitTest.java | 58 +++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/readertox/JavaReaderToXUnitTest.java b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/readertox/JavaReaderToXUnitTest.java index 72813df9b1..fa3c34d479 100644 --- a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/readertox/JavaReaderToXUnitTest.java +++ b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/readertox/JavaReaderToXUnitTest.java @@ -1,7 +1,7 @@ package com.baeldung.readertox; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.ByteArrayInputStream; import java.io.File; @@ -17,6 +17,7 @@ import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CharSequenceReader; +import org.apache.commons.io.input.ReaderInputStream; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -181,7 +182,7 @@ public class JavaReaderToXUnitTest { } @Test - public void givenUsingCommonsIO_whenConvertingReaderIntoInputStream() throws IOException { + public void givenUsingCommonsIOUtils_whenConvertingReaderIntoInputStream() throws IOException { final Reader initialReader = new StringReader("With Commons IO"); final InputStream targetStream = IOUtils.toInputStream(IOUtils.toString(initialReader)); @@ -191,7 +192,7 @@ public class JavaReaderToXUnitTest { } @Test - public void givenUsingCommonsIO_whenConvertingReaderIntoInputStream_thenCorrect() throws IOException { + public void givenUsingCommonsIOUtils_whenConvertingReaderIntoInputStream_thenCorrect() throws IOException { String initialString = "With Commons IO"; final Reader initialReader = new StringReader(initialString); @@ -204,6 +205,30 @@ public class JavaReaderToXUnitTest { targetStream.close(); } + @Test + public void givenUsingCommonsIOReaderInputStream_whenConvertingReaderIntoInputStream() throws IOException { + final Reader initialReader = new StringReader("With Commons IO"); + + final InputStream targetStream = new ReaderInputStream(initialReader); + + initialReader.close(); + targetStream.close(); + } + + @Test + public void givenUsingCommonsIOReaderInputStream_whenConvertingReaderIntoInputStream_thenCorrect() throws IOException { + String initialString = "With Commons IO"; + final Reader initialReader = new StringReader(initialString); + + final InputStream targetStream = new ReaderInputStream(initialReader); + + final String finalString = IOUtils.toString(targetStream); + assertThat(finalString, equalTo(initialString)); + + initialReader.close(); + targetStream.close(); + } + // tests - Reader to InputStream with encoding @Test @@ -233,7 +258,7 @@ public class JavaReaderToXUnitTest { } @Test - public void givenUsingCommonsIO_whenConvertingReaderIntoInputStreamWithEncoding() throws IOException { + public void givenUsingCommonsIOUtils_whenConvertingReaderIntoInputStreamWithEncoding() throws IOException { final Reader initialReader = new StringReader("With Commons IO"); final InputStream targetStream = IOUtils.toInputStream(IOUtils.toString(initialReader), Charsets.UTF_8); @@ -243,7 +268,7 @@ public class JavaReaderToXUnitTest { } @Test - public void givenUsingCommonsIO_whenConvertingReaderIntoInputStreamWithEncoding_thenCorrect() throws IOException { + public void givenUsingCommonsIOUtils_whenConvertingReaderIntoInputStreamWithEncoding_thenCorrect() throws IOException { String initialString = "With Commons IO"; final Reader initialReader = new StringReader(initialString); final InputStream targetStream = IOUtils.toInputStream(IOUtils.toString(initialReader), Charsets.UTF_8); @@ -255,4 +280,27 @@ public class JavaReaderToXUnitTest { targetStream.close(); } + @Test + public void givenUsingCommonsIOReaderInputStream_whenConvertingReaderIntoInputStreamWithEncoding() throws IOException { + final Reader initialReader = new StringReader("With Commons IO"); + + final InputStream targetStream = new ReaderInputStream(initialReader, Charsets.UTF_8); + + initialReader.close(); + targetStream.close(); + } + + @Test + public void givenUsingCommonsIOReaderInputStream_whenConvertingReaderIntoInputStreamWithEncoding_thenCorrect() throws IOException { + String initialString = "With Commons IO"; + final Reader initialReader = new StringReader(initialString); + + final InputStream targetStream = new ReaderInputStream(initialReader, Charsets.UTF_8); + + String finalString = IOUtils.toString(targetStream, Charsets.UTF_8); + assertThat(finalString, equalTo(initialString)); + + initialReader.close(); + targetStream.close(); + } } From 99cc4be41e5c6be9f8c50db63dd9589d4a38b74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matea=20Pej=C4=8Dinovi=C4=87?= Date: Thu, 25 Nov 2021 20:09:04 +0100 Subject: [PATCH 271/551] BAEL-5032 Swagger to PDF --- .../spring-boot-swagger/pom.xml | 109 +++++++++++++++++- .../controller/UserController.java | 63 ++++++++++ .../baeldung/swagger2pdf/objects/User.java | 12 ++ 3 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java create mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml index 87ee5f04cb..6e91189802 100644 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -25,6 +25,21 @@ springfox-boot-starter ${springfox.version} + + io.springfox + springfox-swagger2 + ${springfox-swagger2.version} + + + io.swagger.core.v3 + swagger-jaxrs2 + ${swagger-jaxrs2.version} + + + javax.ws.rs + javax.ws.rs-api + ${javax.ws.rs-api.version} + @@ -33,11 +48,103 @@ org.springframework.boot spring-boot-maven-plugin + + + + com.github.kongchen + swagger-maven-plugin + 3.1.3 + + + + false + com.baeldung.swagger2pdf.controller.UserController + /api + + DEMO REST API + A simple DEMO project for REST API documentation + v1 + + ${project.build.directory}/api + true + + + + + + package + + generate + + + + + + io.github.robwin + swagger2markup-maven-plugin + 0.9.3 + + ${project.build.directory}/api + ${generated.asciidoc.directory} + asciidoc + + + + package + + process-swagger + + + + + + org.asciidoctor + asciidoctor-maven-plugin + 2.2.1 + + + + org.asciidoctor + asciidoctorj-pdf + 1.6.0 + + + + ${project.build.outputDirectory}/../asciidoc + overview.adoc + + book + left + 2 + ${generated.asciidoc.directory} + + + + + + asciidoc-to-pdf + package + + process-asciidoc + + + pdf + ${project.build.outputDirectory}/api/pdf + + + + + + 3.0.0 + ${project.build.outputDirectory}/asciidoc + 2.10.5 + 2.1.11 + 2.1 - \ No newline at end of file + diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java new file mode 100644 index 0000000000..380bac6f8c --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java @@ -0,0 +1,63 @@ +package com.baeldung.swagger2pdf.controller; + +import com.baeldung.swagger2pdf.objects.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.NonNull; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +@Controller +@Api(value = "/api", description = "A controller for user management") +@RequestMapping("/user") +@ResponseStatus(HttpStatus.OK) +public class UserController { + + static List users; + + static { + users = new ArrayList<>(); + users.add(new User("Mark", "Thompson", 23)); + users.add(new User("Kate", "Jordan", 22)); + } + + @ApiOperation(value = "Retrieves all the users") + @RequestMapping(value = "/users", + method = RequestMethod.GET, + produces = MediaType.APPLICATION_JSON_VALUE) + public List getUsers() { + return users; + } + + @ApiOperation(value = "Retrieves a user based on first name") + @RequestMapping(value = "/user", + method = RequestMethod.GET, + produces = MediaType.APPLICATION_JSON_VALUE) + public User getUser(@NonNull @RequestParam String firstName) { + + if (firstName.isEmpty()) { + return null; + } + + return users.stream() + .filter(user -> user.getFirstName().equals(firstName)) + .findAny() + .orElse(null); + + } + + @ApiOperation(value = "Adds a user.") + @RequestMapping(value = "/user", + method = RequestMethod.POST, + produces = MediaType.APPLICATION_JSON_VALUE) + public List addUser(@NonNull @RequestBody User user) { + users.add(user); + return users; + } +} + diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java new file mode 100644 index 0000000000..8c59cb246a --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java @@ -0,0 +1,12 @@ +package com.baeldung.swagger2pdf.objects; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class User { + private String firstName; + private String lastName; + private int age; +} From 2a3501237cb22243274fe51973fa58664baf8f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matea=20Pej=C4=8Dinovi=C4=87?= Date: Thu, 25 Nov 2021 20:16:02 +0100 Subject: [PATCH 272/551] BAEL-5032 added lombok as dependency --- spring-boot-modules/spring-boot-swagger/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml index 6e91189802..41f41a92b9 100644 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -40,6 +40,11 @@ javax.ws.rs-api ${javax.ws.rs-api.version} + + org.projectlombok + lombok + ${lombok.version} + @@ -145,6 +150,7 @@ 2.10.5 2.1.11 2.1 + 1.18.22 From 805500140f2c37f12a007c71ab0a54cd98a6bd87 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Thu, 25 Nov 2021 19:51:32 +0000 Subject: [PATCH 273/551] [JAVA-8355] Move article code to spring-testing-2 module --- testing-modules/spring-testing-2/README.md | 1 + .../baeldung/testexecutionlisteners/AdditionService.java | 0 .../testexecutionlisteners/AdditionServiceUnitTest.java | 5 +++-- .../CustomTestExecutionListener.java | 0 .../TestExecutionListenersWithMergeModeUnitTest.java | 7 ++++--- .../TestExecutionListenersWithoutMergeModeUnitTest.java | 5 +++-- testing-modules/spring-testing/README.md | 1 - 7 files changed, 11 insertions(+), 8 deletions(-) rename testing-modules/{spring-testing => spring-testing-2}/src/main/java/com/baeldung/testexecutionlisteners/AdditionService.java (100%) rename testing-modules/{spring-testing => spring-testing-2}/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java (92%) rename testing-modules/{spring-testing => spring-testing-2}/src/test/java/com/baeldung/testexecutionlisteners/CustomTestExecutionListener.java (100%) rename testing-modules/{spring-testing => spring-testing-2}/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java (93%) rename testing-modules/{spring-testing => spring-testing-2}/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java (94%) diff --git a/testing-modules/spring-testing-2/README.md b/testing-modules/spring-testing-2/README.md index 16b47adeac..434388d683 100644 --- a/testing-modules/spring-testing-2/README.md +++ b/testing-modules/spring-testing-2/README.md @@ -3,3 +3,4 @@ - [Guide to @DynamicPropertySource in Spring](https://www.baeldung.com/spring-dynamicpropertysource) - [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) - [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledIf) +- [The Spring TestExecutionListener](https://www.baeldung.com/spring-testexecutionlistener) diff --git a/testing-modules/spring-testing/src/main/java/com/baeldung/testexecutionlisteners/AdditionService.java b/testing-modules/spring-testing-2/src/main/java/com/baeldung/testexecutionlisteners/AdditionService.java similarity index 100% rename from testing-modules/spring-testing/src/main/java/com/baeldung/testexecutionlisteners/AdditionService.java rename to testing-modules/spring-testing-2/src/main/java/com/baeldung/testexecutionlisteners/AdditionService.java diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java similarity index 92% rename from testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java index bbe537a3ce..6c5d08f478 100644 --- a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/AdditionServiceUnitTest.java @@ -1,7 +1,5 @@ package com.baeldung.testexecutionlisteners; -import static org.junit.Assert.assertThat; - import org.hamcrest.Matchers; import org.junit.Test; import org.junit.runner.RunWith; @@ -9,9 +7,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.MatcherAssert.assertThat; + @RunWith(SpringRunner.class) @ContextConfiguration(classes = AdditionService.class) public class AdditionServiceUnitTest { + @Autowired private AdditionService additionService; diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/CustomTestExecutionListener.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/CustomTestExecutionListener.java similarity index 100% rename from testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/CustomTestExecutionListener.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/CustomTestExecutionListener.java diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java similarity index 93% rename from testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java index 44937aa755..de1501c54d 100644 --- a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithMergeModeUnitTest.java @@ -1,7 +1,5 @@ package com.baeldung.testexecutionlisteners; -import static org.junit.Assert.assertThat; - import org.hamcrest.Matchers; import org.junit.Test; import org.junit.runner.RunWith; @@ -11,11 +9,14 @@ import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.TestExecutionListeners.MergeMode; import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.MatcherAssert.assertThat; + @RunWith(SpringRunner.class) -@TestExecutionListeners(value = { CustomTestExecutionListener.class }, +@TestExecutionListeners(value = { CustomTestExecutionListener.class }, mergeMode = MergeMode.MERGE_WITH_DEFAULTS) @ContextConfiguration(classes = AdditionService.class) public class TestExecutionListenersWithMergeModeUnitTest { + @Autowired private AdditionService additionService; diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java similarity index 94% rename from testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java index e25ab9f381..b4cc861c29 100644 --- a/testing-modules/spring-testing/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/testexecutionlisteners/TestExecutionListenersWithoutMergeModeUnitTest.java @@ -1,7 +1,5 @@ package com.baeldung.testexecutionlisteners; -import static org.junit.Assert.assertThat; - import org.hamcrest.Matchers; import org.junit.Test; import org.junit.runner.RunWith; @@ -11,11 +9,14 @@ import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; +import static org.hamcrest.MatcherAssert.assertThat; + @RunWith(SpringRunner.class) @TestExecutionListeners(value = {CustomTestExecutionListener.class, DependencyInjectionTestExecutionListener.class}) @ContextConfiguration(classes = AdditionService.class) public class TestExecutionListenersWithoutMergeModeUnitTest { + @Autowired private AdditionService additionService; diff --git a/testing-modules/spring-testing/README.md b/testing-modules/spring-testing/README.md index a4de9c5c57..2427dfabbe 100644 --- a/testing-modules/spring-testing/README.md +++ b/testing-modules/spring-testing/README.md @@ -7,4 +7,3 @@ - [Using SpringJUnit4ClassRunner with Parameterized](https://www.baeldung.com/springjunit4classrunner-parameterized) - [Override Properties in Spring’s Tests](https://www.baeldung.com/spring-tests-override-properties) - [A Quick Guide to @DirtiesContext](https://www.baeldung.com/spring-dirtiescontext) -- [The Spring TestExecutionListener](https://www.baeldung.com/spring-testexecutionlistener) From 02f34bab02b2996abc72a521e1f03954efc321ff Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Fri, 26 Nov 2021 10:40:22 +0200 Subject: [PATCH 274/551] disable tests until they are fixed --- .../version/{VersionUnitTest.java => VersionManualTest.java} | 3 ++- .../java/com/baeldung/java9/modules/ModuleAPIUnitTest.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) rename core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/{VersionUnitTest.java => VersionManualTest.java} (92%) diff --git a/core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/VersionUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/VersionManualTest.java similarity index 92% rename from core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/VersionUnitTest.java rename to core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/VersionManualTest.java index 128c7f60f4..74035a3e2f 100644 --- a/core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/VersionUnitTest.java +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/version/VersionManualTest.java @@ -5,7 +5,8 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -public class VersionUnitTest { +// manual test as the runtime JDK version can be different depending on where the test is run +public class VersionManualTest { @Test public void givenJava_whenUsingRuntime_thenGetVersion() { diff --git a/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java b/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java index b909636b56..f6ea266676 100644 --- a/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java +++ b/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java @@ -16,6 +16,7 @@ import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; +import org.junit.Ignore; public class ModuleAPIUnitTest { @@ -110,6 +111,7 @@ public class ModuleAPIUnitTest { } @Test + @Ignore // fixing in http://team.baeldung.com/browse/JAVA-8679 public void givenModules_whenAccessingModuleDescriptorProvides_thenProvidesAreReturned() { Set javaBaseProvides = javaBaseModule.getDescriptor().provides(); Set javaSqlProvides = javaSqlModule.getDescriptor().provides(); From 49f90c3a555e8222818ebd07dc50a558c45733a1 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Fri, 26 Nov 2021 10:56:49 +0100 Subject: [PATCH 275/551] JAVA-8699: Use @KeycloakConfiguration annotation --- .../main/java/com/baeldung/keycloak/SecurityConfig.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java index 895ac8c562..78023aff8f 100644 --- a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java @@ -1,24 +1,19 @@ package com.baeldung.keycloak; import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; -import org.keycloak.adapters.springsecurity.KeycloakSecurityComponents; +import org.keycloak.adapters.springsecurity.KeycloakConfiguration; import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; import org.springframework.security.core.session.SessionRegistryImpl; import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy; import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; -@Configuration -@EnableWebSecurity -@ComponentScan(basePackageClasses = KeycloakSecurityComponents.class) +@KeycloakConfiguration class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { // Submits the KeycloakAuthenticationProvider to the AuthenticationManager @Autowired From f9f37ac4e69a770c1217fe5c85f15693c24f4793 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Fri, 26 Nov 2021 13:17:01 +0100 Subject: [PATCH 276/551] JAVA-8709: Extract commons-collections4.version property to the main pom.xml --- algorithms-miscellaneous-3/pom.xml | 4 +--- core-java-modules/core-java-10/pom.xml | 1 - core-java-modules/core-java-8/pom.xml | 5 ----- core-java-modules/core-java-9/pom.xml | 1 - core-java-modules/core-java-collections-2/pom.xml | 1 - core-java-modules/core-java-collections-array-list/pom.xml | 4 ---- core-java-modules/core-java-collections-list-2/pom.xml | 4 ---- core-java-modules/core-java-collections-list-3/pom.xml | 1 - core-java-modules/core-java-collections-list/pom.xml | 4 ---- core-java-modules/core-java-collections-maps-2/pom.xml | 1 - core-java-modules/core-java-collections-maps/pom.xml | 4 ---- core-java-modules/core-java-collections-set/pom.xml | 1 - core-java-modules/core-java-concurrency-advanced/pom.xml | 1 - core-java-modules/core-java-os/pom.xml | 1 - gson/pom.xml | 3 --- guava-modules/guava-collections-list/pom.xml | 3 --- guava-modules/guava-collections/pom.xml | 3 --- java-collections-conversions/pom.xml | 4 ---- java-collections-maps-3/pom.xml | 1 - json/pom.xml | 1 - libraries-6/pom.xml | 1 - libraries-apache-commons-collections/pom.xml | 3 +-- pom.xml | 1 + spring-5-reactive-client/pom.xml | 1 - spring-5-reactive-security/pom.xml | 1 - spring-5-reactive/pom.xml | 1 - spring-5/pom.xml | 1 - testing-modules/testing-assertions/pom.xml | 4 ---- video-tutorials/jackson-annotations/pom.xml | 1 - xml/pom.xml | 1 - 30 files changed, 3 insertions(+), 60 deletions(-) diff --git a/algorithms-miscellaneous-3/pom.xml b/algorithms-miscellaneous-3/pom.xml index 525a2556de..11a64eba8b 100644 --- a/algorithms-miscellaneous-3/pom.xml +++ b/algorithms-miscellaneous-3/pom.xml @@ -37,7 +37,7 @@ org.apache.commons commons-lang3 - ${commons.lang3.version} + ${commons-lang3.version} pl.pragmatists @@ -63,10 +63,8 @@ - 4.3 28.0-jre 2.6.0 - 3.8.1 1.1.0 diff --git a/core-java-modules/core-java-10/pom.xml b/core-java-modules/core-java-10/pom.xml index c3406751dc..e2ac8db919 100644 --- a/core-java-modules/core-java-10/pom.xml +++ b/core-java-modules/core-java-10/pom.xml @@ -39,7 +39,6 @@ 10 10 - 4.1 \ No newline at end of file diff --git a/core-java-modules/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml index 85e289280b..89925bdbbb 100644 --- a/core-java-modules/core-java-8/pom.xml +++ b/core-java-modules/core-java-8/pom.xml @@ -43,9 +43,4 @@ - - - 4.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 03a097e7a9..274d9ccb43 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -76,7 +76,6 @@ 1.9 1.9 25.1-jre - 4.1 \ No newline at end of file diff --git a/core-java-modules/core-java-collections-2/pom.xml b/core-java-modules/core-java-collections-2/pom.xml index 23100b1d87..e78f7b5dda 100644 --- a/core-java-modules/core-java-collections-2/pom.xml +++ b/core-java-modules/core-java-collections-2/pom.xml @@ -44,7 +44,6 @@ 7.1.0 - 4.1 1.3 diff --git a/core-java-modules/core-java-collections-array-list/pom.xml b/core-java-modules/core-java-collections-array-list/pom.xml index ca9c173947..6b040739e8 100644 --- a/core-java-modules/core-java-collections-array-list/pom.xml +++ b/core-java-modules/core-java-collections-array-list/pom.xml @@ -22,8 +22,4 @@ - - 4.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-collections-list-2/pom.xml b/core-java-modules/core-java-collections-list-2/pom.xml index 7876b19cf9..59ab8c5f27 100644 --- a/core-java-modules/core-java-collections-list-2/pom.xml +++ b/core-java-modules/core-java-collections-list-2/pom.xml @@ -28,8 +28,4 @@ - - 4.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-collections-list-3/pom.xml b/core-java-modules/core-java-collections-list-3/pom.xml index 9238939df7..3bb0fb4a33 100644 --- a/core-java-modules/core-java-collections-list-3/pom.xml +++ b/core-java-modules/core-java-collections-list-3/pom.xml @@ -54,7 +54,6 @@ - 4.1 3.0.2 8.1.0 1.2.0 diff --git a/core-java-modules/core-java-collections-list/pom.xml b/core-java-modules/core-java-collections-list/pom.xml index b60906d1ba..0cc8828a0d 100644 --- a/core-java-modules/core-java-collections-list/pom.xml +++ b/core-java-modules/core-java-collections-list/pom.xml @@ -27,8 +27,4 @@ - - 4.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-2/pom.xml b/core-java-modules/core-java-collections-maps-2/pom.xml index 060796fafa..36b15c24d5 100644 --- a/core-java-modules/core-java-collections-maps-2/pom.xml +++ b/core-java-modules/core-java-collections-maps-2/pom.xml @@ -55,7 +55,6 @@ 0.6.5 - 4.1 1.7.0 8.2.0 0.7.2 diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index 66aca9c1b2..34b878df53 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -22,8 +22,4 @@ - - 4.1 - - \ No newline at end of file diff --git a/core-java-modules/core-java-collections-set/pom.xml b/core-java-modules/core-java-collections-set/pom.xml index 359c0fc86f..0b6e324c78 100644 --- a/core-java-modules/core-java-collections-set/pom.xml +++ b/core-java-modules/core-java-collections-set/pom.xml @@ -49,7 +49,6 @@ 11 11 - 4.3 2.8.5 diff --git a/core-java-modules/core-java-concurrency-advanced/pom.xml b/core-java-modules/core-java-concurrency-advanced/pom.xml index a026bdb2cd..b50a66cefc 100644 --- a/core-java-modules/core-java-concurrency-advanced/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced/pom.xml @@ -56,7 +56,6 @@ 21.0 3.6.1 - 4.1 4.01 1.7.0 diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 970c8a562a..c24824dfb7 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -69,7 +69,6 @@ - 4.1 4.01 1.8.9 1.9 diff --git a/gson/pom.xml b/gson/pom.xml index a928d87b61..082e53baf0 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -61,10 +61,7 @@ - 2.8.0 - - 4.1 2.9.6 diff --git a/guava-modules/guava-collections-list/pom.xml b/guava-modules/guava-collections-list/pom.xml index 1b989e79b0..6863b4011c 100644 --- a/guava-modules/guava-collections-list/pom.xml +++ b/guava-modules/guava-collections-list/pom.xml @@ -45,9 +45,6 @@
- - 4.1 - 2.0.0.0 diff --git a/guava-modules/guava-collections/pom.xml b/guava-modules/guava-collections/pom.xml index 7929283616..9283107023 100644 --- a/guava-modules/guava-collections/pom.xml +++ b/guava-modules/guava-collections/pom.xml @@ -50,10 +50,7 @@
- - 4.1 0.9.12 - 2.0.0.0 diff --git a/java-collections-conversions/pom.xml b/java-collections-conversions/pom.xml index ae800b21c1..7f5ba38e3e 100644 --- a/java-collections-conversions/pom.xml +++ b/java-collections-conversions/pom.xml @@ -38,8 +38,4 @@
- - 4.4 - - \ No newline at end of file diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml index 6f724ab5ef..81466b17ba 100644 --- a/java-collections-maps-3/pom.xml +++ b/java-collections-maps-3/pom.xml @@ -30,7 +30,6 @@ - 4.1 5.2.5.RELEASE diff --git a/json/pom.xml b/json/pom.xml index 2919a3a4ee..dfe42ee4c1 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -74,7 +74,6 @@ 1.4.1 1.2.21 1.0 - 4.1 1.0.1 20171018 2.8.5 diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index accf5f3a9a..3b932f2bd2 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -146,7 +146,6 @@ 3.5-beta72 3.0 1.8.1 - 4.4 8.12.9 2.4.4 diff --git a/libraries-apache-commons-collections/pom.xml b/libraries-apache-commons-collections/pom.xml index 2cb73babe6..c1a158b16e 100644 --- a/libraries-apache-commons-collections/pom.xml +++ b/libraries-apache-commons-collections/pom.xml @@ -16,7 +16,7 @@ org.apache.commons commons-collections4 - ${commons.collections.version} + ${commons-collections4.version} org.hamcrest @@ -27,7 +27,6 @@ - 4.1 2.0.0.0 diff --git a/pom.xml b/pom.xml index 8a27d67d65..0aab7b3a02 100644 --- a/pom.xml +++ b/pom.xml @@ -1421,6 +1421,7 @@ 1.33 1.33 2.21.0 + 4.4 2.11.0 2.6 3.12.0 diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml index 136f31b49e..4821d0fc6d 100644 --- a/spring-5-reactive-client/pom.xml +++ b/spring-5-reactive-client/pom.xml @@ -153,7 +153,6 @@ 1.1.3 1.0 1.0 - 4.1 1.1.6 4.0.1 diff --git a/spring-5-reactive-security/pom.xml b/spring-5-reactive-security/pom.xml index 267a683fa7..140c6b8296 100644 --- a/spring-5-reactive-security/pom.xml +++ b/spring-5-reactive-security/pom.xml @@ -123,7 +123,6 @@ 1.1.3 1.0 1.0 - 4.1 3.1.6.RELEASE diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml index 408573198b..b9456c7181 100644 --- a/spring-5-reactive/pom.xml +++ b/spring-5-reactive/pom.xml @@ -153,7 +153,6 @@ 1.1.3 1.0 1.0 - 4.1 \ No newline at end of file diff --git a/spring-5/pom.xml b/spring-5/pom.xml index 5799f3bc8f..1ac696e7bd 100644 --- a/spring-5/pom.xml +++ b/spring-5/pom.xml @@ -142,7 +142,6 @@ 1.0 1.5.6 - 4.1 ${project.build.directory}/generated-snippets 4.0.3 diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml index 689ca35733..09f4291b78 100644 --- a/testing-modules/testing-assertions/pom.xml +++ b/testing-modules/testing-assertions/pom.xml @@ -26,8 +26,4 @@ - - 4.4 - - \ No newline at end of file diff --git a/video-tutorials/jackson-annotations/pom.xml b/video-tutorials/jackson-annotations/pom.xml index 29f457964b..eaec50c1f7 100644 --- a/video-tutorials/jackson-annotations/pom.xml +++ b/video-tutorials/jackson-annotations/pom.xml @@ -116,7 +116,6 @@ 2.9.6 2.8.0 - 4.1 3.0.1 3.0.0 diff --git a/xml/pom.xml b/xml/pom.xml index 968682ee38..0764c9d145 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -355,7 +355,6 @@ 1.2.0 2.0.6 1.6.2 - 4.1 1.2.4.5 2.3.1 1.4.2 From 70608bb2e729a793aa24f74d9d137653b01cff8a Mon Sep 17 00:00:00 2001 From: davidmartinezbarua Date: Fri, 26 Nov 2021 10:56:17 -0300 Subject: [PATCH 277/551] Revert "Spring Webflux and @Cacheable Annotation" --- spring-5-webflux/pom.xml | 20 ---- .../com/baeldung/spring/caching/Item.java | 50 ---------- .../spring/caching/ItemRepository.java | 8 -- .../baeldung/spring/caching/ItemService.java | 42 -------- .../SpringWebfluxCachingApplication.java | 16 ---- .../resources/application-cache.properties | 2 - .../MonoFluxResultCachingLiveTest.java | 95 ------------------- 7 files changed, 233 deletions(-) delete mode 100644 spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java delete mode 100644 spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java delete mode 100644 spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java delete mode 100644 spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java delete mode 100644 spring-5-webflux/src/main/resources/application-cache.properties delete mode 100644 spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index d6afb686fc..69de83c227 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -66,31 +66,11 @@ - - io.projectreactor.addons - reactor-extra - 3.4.5 - - - com.github.ben-manes.caffeine - caffeine - 2.9.2 - - - org.springframework.boot - spring-boot-starter-data-mongodb-reactive - io.projectreactor reactor-test test - - org.testcontainers - mongodb - 1.16.2 - test - com.squareup.okhttp3 mockwebserver diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java deleted file mode 100644 index 7b79ff7503..0000000000 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.baeldung.spring.caching; - -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Document; - -@Document -public class Item { - - @Id - private String _id; - private String name; - private double price; - - public Item(String name, double price) { - this.name = name; - this.price = price; - } - - public Item() { - } - - public String get_id() { - return _id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public double getPrice() { - return price; - } - - public void setPrice(double price) { - this.price = price; - } - - @Override - public String toString() { - return "Item{" + - "id='" + _id + '\'' + - ", name='" + name + '\'' + - ", price=" + price + - '}'; - } -} diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java deleted file mode 100644 index 27c97de36a..0000000000 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.spring.caching; - -import org.springframework.data.mongodb.repository.ReactiveMongoRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ItemRepository extends ReactiveMongoRepository { -} diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java deleted file mode 100644 index b24b54521e..0000000000 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.spring.caching; - -import com.github.benmanes.caffeine.cache.Caffeine; -import com.github.benmanes.caffeine.cache.LoadingCache; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import reactor.cache.CacheMono; -import reactor.core.publisher.Mono; - -@Service -public class ItemService { - - private final ItemRepository repository; - private final LoadingCache cache; - - public ItemService(ItemRepository repository) { - this.repository = repository; - this.cache = Caffeine.newBuilder() - .build(this::getItem_withAddons); - } - - @Cacheable("items") - public Mono getItem(String id) { - return repository.findById(id); - } - - public Mono save(Item item) { - return repository.save(item); - } - - @Cacheable("items") - public Mono getItem_withCache(String id) { - return repository.findById(id).cache(); - } - - @Cacheable("items") - public Mono getItem_withAddons(String id) { - return CacheMono.lookup(cache.asMap(), id) - .onCacheMissResume(() -> repository.findById(id).cast(Object.class)).cast(Item.class); - } - -} diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java b/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java deleted file mode 100644 index 5266e33775..0000000000 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.spring.caching; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; - -@SpringBootApplication -@EnableMongoRepositories -@EnableCaching -public class SpringWebfluxCachingApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringWebfluxCachingApplication.class, args); - } -} diff --git a/spring-5-webflux/src/main/resources/application-cache.properties b/spring-5-webflux/src/main/resources/application-cache.properties deleted file mode 100644 index 23414da2dd..0000000000 --- a/spring-5-webflux/src/main/resources/application-cache.properties +++ /dev/null @@ -1,2 +0,0 @@ -logging.level.org.springframework.data.mongodb.core.ReactiveMongoTemplate=DEBUG -logging.level.org.springframework.cache=TRACE \ No newline at end of file diff --git a/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java b/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java deleted file mode 100644 index 322b3c5aa5..0000000000 --- a/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.baeldung.spring.caching; - - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.MongoDBContainer; -import org.testcontainers.utility.DockerImageName; -import reactor.core.publisher.Mono; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest -@ActiveProfiles("cache") -public class MonoFluxResultCachingLiveTest { - - - @Autowired - ItemService itemService; - - final static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")); - - @DynamicPropertySource - static void mongoDbProperties(DynamicPropertyRegistry registry) { - mongoDBContainer.start(); - registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl); - } - -@Test -public void givenItem_whenGetItemIsCalled_thenMonoIsCached() { - Mono glass = itemService.save(new Item("glass", 1.00)); - - String id = glass.block().get_id(); - - Mono mono = itemService.getItem(id); - Item item = mono.block(); - - assertThat(item).isNotNull(); - assertThat(item.getName()).isEqualTo("glass"); - assertThat(item.getPrice()).isEqualTo(1.00); - - Mono mono2 = itemService.getItem(id); - Item item2 = mono2.block(); - - assertThat(item2).isNotNull(); - assertThat(item2.getName()).isEqualTo("glass"); - assertThat(item2.getPrice()).isEqualTo(1.00); -} - - @Test - public void givenItem_whenGetItemWithCacheIsCalled_thenMonoResultIsCached() { - Mono glass = itemService.save(new Item("glass", 1.00)); - - String id = glass.block().get_id(); - - Mono mono = itemService.getItem_withCache(id); - Item item = mono.block(); - - assertThat(item).isNotNull(); - assertThat(item.getName()).isEqualTo("glass"); - assertThat(item.getPrice()).isEqualTo(1.00); - - Mono mono2 = itemService.getItem_withCache(id); - Item item2 = mono2.block(); - - assertThat(item2).isNotNull(); - assertThat(item2.getName()).isEqualTo("glass"); - assertThat(item2.getPrice()).isEqualTo(1.00); - } - - @Test - public void givenItem_whenGetItemWithAddonsIsCalled_thenMonoResultIsCached() { - Mono glass = itemService.save(new Item("glass", 1.00)); - - String id = glass.block().get_id(); - - Mono mono = itemService.getItem_withAddons(id); - Item item = mono.block(); - - assertThat(item).isNotNull(); - assertThat(item.getName()).isEqualTo("glass"); - assertThat(item.getPrice()).isEqualTo(1.00); - - Mono mono2 = itemService.getItem_withAddons(id); - Item item2 = mono2.block(); - - assertThat(item2).isNotNull(); - assertThat(item2.getName()).isEqualTo("glass"); - assertThat(item2.getPrice()).isEqualTo(1.00); - } - -} From d0df1f9e23454e7846824329e13e5e505a788072 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 26 Nov 2021 19:28:29 +0530 Subject: [PATCH 278/551] JAVA-8620: Fix references to parents --- aws-lambda/lambda/pom.xml | 3 +-- aws-lambda/pom.xml | 1 - cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml | 3 +-- cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml | 3 +-- cloud-foundry-uaa/pom.xml | 6 +++--- spf4j/spf4j-aspects-app/pom.xml | 5 ++--- spf4j/spf4j-core-app/pom.xml | 5 ++--- spring-boot-modules/spring-boot-camel/pom.xml | 7 +++---- spring-boot-modules/spring-boot-cassandre/pom.xml | 7 +++---- .../spring-boot-custom-starter/greeter/pom.xml | 5 ++--- .../parent-multi-module/application/pom.xml | 3 +-- .../parent-multi-module/library/pom.xml | 3 +-- .../spring-boot-custom-starter/parent-multi-module/pom.xml | 6 ++++++ spring-boot-modules/spring-boot-groovy/pom.xml | 7 +++---- .../property-exp-default-config/pom.xml | 5 ++--- spring-boot-modules/spring-boot-validation/pom.xml | 7 +++---- 16 files changed, 34 insertions(+), 42 deletions(-) diff --git a/aws-lambda/lambda/pom.xml b/aws-lambda/lambda/pom.xml index b2e5cc3b2d..8bfe7a0ade 100644 --- a/aws-lambda/lambda/pom.xml +++ b/aws-lambda/lambda/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-modules + aws-lambda 1.0.0-SNAPSHOT - ../../ diff --git a/aws-lambda/pom.xml b/aws-lambda/pom.xml index 3264356977..fc655f282d 100644 --- a/aws-lambda/pom.xml +++ b/aws-lambda/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../ diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml index 74603bf0fb..7fcce181a3 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml +++ b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-boot-2 + cloud-foundry-uaa 0.0.1-SNAPSHOT - ../../parent-boot-2 diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml b/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml index 276c8bbaa6..4dffd4d768 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml +++ b/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-boot-2 + cloud-foundry-uaa 0.0.1-SNAPSHOT - ../../parent-boot-2 diff --git a/cloud-foundry-uaa/pom.xml b/cloud-foundry-uaa/pom.xml index 03a5b978d4..6ae43b2c08 100644 --- a/cloud-foundry-uaa/pom.xml +++ b/cloud-foundry-uaa/pom.xml @@ -4,14 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cloud-foundry-uaa - 0.0.1-SNAPSHOT cloud-foundry-uaa pom com.baeldung - parent-modules - 1.0.0-SNAPSHOT + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 diff --git a/spf4j/spf4j-aspects-app/pom.xml b/spf4j/spf4j-aspects-app/pom.xml index c4940b9c97..09ca41ea47 100644 --- a/spf4j/spf4j-aspects-app/pom.xml +++ b/spf4j/spf4j-aspects-app/pom.xml @@ -9,10 +9,9 @@ jar - com.baeldung - parent-modules + com.baeldung.spf4j + spf4j 1.0.0-SNAPSHOT - ../../ diff --git a/spf4j/spf4j-core-app/pom.xml b/spf4j/spf4j-core-app/pom.xml index 28c104afe1..2f7f3745f1 100644 --- a/spf4j/spf4j-core-app/pom.xml +++ b/spf4j/spf4j-core-app/pom.xml @@ -9,10 +9,9 @@ jar - com.baeldung - parent-modules + com.baeldung.spf4j + spf4j 1.0.0-SNAPSHOT - ../../ diff --git a/spring-boot-modules/spring-boot-camel/pom.xml b/spring-boot-modules/spring-boot-camel/pom.xml index 0069dfdbff..5d5e2ce6bd 100644 --- a/spring-boot-modules/spring-boot-camel/pom.xml +++ b/spring-boot-modules/spring-boot-camel/pom.xml @@ -9,10 +9,9 @@ spring-boot-camel - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT diff --git a/spring-boot-modules/spring-boot-cassandre/pom.xml b/spring-boot-modules/spring-boot-cassandre/pom.xml index 14849e50d7..1f2931a2bf 100644 --- a/spring-boot-modules/spring-boot-cassandre/pom.xml +++ b/spring-boot-modules/spring-boot-cassandre/pom.xml @@ -9,10 +9,9 @@ Cassandre trading bot tutorial - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml index f96880b1cf..5c0580d29a 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml @@ -8,10 +8,9 @@ greeter - com.baeldung - parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-custom-starter 0.0.1-SNAPSHOT - ../../../parent-boot-2 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml index 1c26ec32d3..a00c3a3c57 100644 --- a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-boot-2 + parent-multi-module 0.0.1-SNAPSHOT - ../../../../parent-boot-2 diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml index 5d45de0d1d..6e7b3ce78a 100644 --- a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-boot-2 + parent-multi-module 0.0.1-SNAPSHOT - ../../../../parent-boot-2 diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml index 2a483a8fef..4bc8434d43 100644 --- a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml @@ -8,6 +8,12 @@ 0.0.1-SNAPSHOT pom + + com.baeldung.spring-boot-modules + spring-boot-custom-starter + 0.0.1-SNAPSHOT + + library application diff --git a/spring-boot-modules/spring-boot-groovy/pom.xml b/spring-boot-modules/spring-boot-groovy/pom.xml index ea9f3231cd..820bb0fd7a 100644 --- a/spring-boot-modules/spring-boot-groovy/pom.xml +++ b/spring-boot-modules/spring-boot-groovy/pom.xml @@ -10,10 +10,9 @@ Spring Boot Todo Application with Groovy - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml index 496004b0e2..b1c44de9a9 100644 --- a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml @@ -9,10 +9,9 @@ jar - com.baeldung - parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-property-exp 0.0.1-SNAPSHOT - ../../../parent-boot-2 diff --git a/spring-boot-modules/spring-boot-validation/pom.xml b/spring-boot-modules/spring-boot-validation/pom.xml index 86e0a47d0d..fa4e8439e6 100644 --- a/spring-boot-modules/spring-boot-validation/pom.xml +++ b/spring-boot-modules/spring-boot-validation/pom.xml @@ -8,10 +8,9 @@ 0.0.1-SNAPSHOT - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT From e931840ced257bf2a38d9ebe55e66473f05e3445 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 26 Nov 2021 22:19:21 +0530 Subject: [PATCH 279/551] JAVA-8287: Split or move java-jpa-3 module --- persistence-modules/java-jpa-3/README.md | 1 - persistence-modules/java-mongodb/README.md | 1 + .../field}/FieldExistenceLiveTest.java | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename persistence-modules/java-mongodb/src/test/java/com/baeldung/{existence.field => existence/field}/FieldExistenceLiveTest.java (100%) diff --git a/persistence-modules/java-jpa-3/README.md b/persistence-modules/java-jpa-3/README.md index 202c97a830..aa33644b17 100644 --- a/persistence-modules/java-jpa-3/README.md +++ b/persistence-modules/java-jpa-3/README.md @@ -13,5 +13,4 @@ This module contains articles about the Java Persistence API (JPA) in Java. - [Returning an Auto-Generated Id with JPA](https://www.baeldung.com/jpa-get-auto-generated-id) - [How to Return Multiple Entities In JPA Query](https://www.baeldung.com/jpa-return-multiple-entities) - [Defining Unique Constraints in JPA](https://www.baeldung.com/jpa-unique-constraints) -- [How to Check Field Existence in MongoDB?](https://www.baeldung.com/mongodb-check-field-exists) - [Connecting to a Specific Schema in JDBC](https://www.baeldung.com/jdbc-connect-to-schema) diff --git a/persistence-modules/java-mongodb/README.md b/persistence-modules/java-mongodb/README.md index f632e7c662..34acd60c57 100644 --- a/persistence-modules/java-mongodb/README.md +++ b/persistence-modules/java-mongodb/README.md @@ -11,3 +11,4 @@ This module contains articles about MongoDB in Java. - [Introduction to Morphia – Java ODM for MongoDB](https://www.baeldung.com/mongodb-morphia) - [MongoDB Aggregations Using Java](https://www.baeldung.com/java-mongodb-aggregations) - [BSON to JSON Document Conversion in Java](https://www.baeldung.com/java-convert-bson-to-json) +- [How to Check Field Existence in MongoDB?](https://www.baeldung.com/mongodb-check-field-exists) diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/existence.field/FieldExistenceLiveTest.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/existence/field/FieldExistenceLiveTest.java similarity index 100% rename from persistence-modules/java-mongodb/src/test/java/com/baeldung/existence.field/FieldExistenceLiveTest.java rename to persistence-modules/java-mongodb/src/test/java/com/baeldung/existence/field/FieldExistenceLiveTest.java From 86dcb518b2d9d95321405d3099ea5ce8fe5857e7 Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Azam Khan Date: Fri, 26 Nov 2021 20:54:37 +0400 Subject: [PATCH 280/551] Indentation and Formatting Changes --- .../baeldung/unsupportedmediatype/User.java | 10 ++--- .../ApplicationUnitTest.java | 38 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java index f9c3d9c191..765149dad5 100644 --- a/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java +++ b/spring-boot-rest-2/src/main/java/com/baeldung/unsupportedmediatype/User.java @@ -55,11 +55,11 @@ public class User implements Serializable { @Override public String toString() { return "User{" - + "id=" + id - + ", name='" + name + '\'' - + ", age=" + age - + ", address='" + address + '\'' - + '}'; + + "id=" + id + + ", name='" + name + '\'' + + ", age=" + age + + ", address='" + address + '\'' + + '}'; } diff --git a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java index 95de780106..498ad9d537 100644 --- a/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java +++ b/spring-boot-rest-2/src/test/java/com/baeldung/unsupportedmediatype/ApplicationUnitTest.java @@ -20,39 +20,39 @@ public class ApplicationUnitTest { @Test public void JsonTestCase() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .contentType(MediaType.APPLICATION_JSON_VALUE) - .content( "{\n" - + " \"name\": \"Andy\",\n" - + " \"age\": 1,\n" - + " \"address\": \"Hello world\"\n" - + "}")) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON_VALUE) + .content( "{\n" + + " \"name\": \"Andy\",\n" + + " \"age\": 1,\n" + + " \"address\": \"Hello world\"\n" + + "}")) + .andExpect(status().isOk()); } @Test public void JsonFailTestCase() throws Exception {// Because no content-type added mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .content( "{\n" - + " \"name\": \"Andy\",\n" - + " \"age\": 1,\n" - + " \"address\": \"Hello world\"\n" - + "}")) - .andExpect(status().isUnsupportedMediaType()); + .content( "{\n" + + " \"name\": \"Andy\",\n" + + " \"age\": 1,\n" + + " \"address\": \"Hello world\"\n" + + "}")) + .andExpect(status().isUnsupportedMediaType()); } @Test public void XmlTestCase() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .contentType(MediaType.APPLICATION_XML_VALUE) - .content("Andy1
Hello world
")) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_XML_VALUE) + .content("Andy1
Hello world
")) + .andExpect(status().isOk()); } @Test public void StringFailTestCase() throws Exception { // Because content-type is not supported mockMvc.perform(MockMvcRequestBuilders.post("/user/") - .contentType(MediaType.TEXT_PLAIN_VALUE) - .content("Andy1
Hello world
")) - .andExpect(status().isUnsupportedMediaType()); + .contentType(MediaType.TEXT_PLAIN_VALUE) + .content("Andy1
Hello world
")) + .andExpect(status().isUnsupportedMediaType()); } } From dcd9411cf3622982f497de30a0070ec57a8bd1b6 Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Fri, 26 Nov 2021 18:06:20 +0100 Subject: [PATCH 281/551] BAEL-5076 Unix domain socket in Java 16 (#11493) * BAEL-5076 Unix domain socket in Java 16 * BAEL-5076 Unix domain socket in Java 16 * BAEL-5076 Unix domain socket in Java 16 * BAEL-5076 Unix domain socket in Java 16 Co-authored-by: krzysztof --- .../core-java-networking-3/pom.xml | 10 +++ .../socket/UnixDomainSocketClient.java | 49 +++++++++++ .../socket/UnixDomainSocketServer.java | 57 +++++++++++++ .../UnixDomainSocketClientUnitTest.java | 82 +++++++++++++++++++ .../UnixDomainSocketServerUnitTest.java | 50 +++++++++++ core-java-modules/pom.xml | 1 - pom.xml | 2 + 7 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketClient.java create mode 100644 core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketServer.java create mode 100644 core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketClientUnitTest.java create mode 100644 core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketServerUnitTest.java diff --git a/core-java-modules/core-java-networking-3/pom.xml b/core-java-modules/core-java-networking-3/pom.xml index ee822e57cb..297d665544 100644 --- a/core-java-modules/core-java-networking-3/pom.xml +++ b/core-java-modules/core-java-networking-3/pom.xml @@ -64,6 +64,16 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + + 16 + 16 + + +
diff --git a/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketClient.java b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketClient.java new file mode 100644 index 0000000000..2a8ae05628 --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketClient.java @@ -0,0 +1,49 @@ +package com.baeldung.socket; + +import java.io.IOException; +import java.net.StandardProtocolFamily; +import java.net.UnixDomainSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; +import java.nio.file.Path; + +class UnixDomainSocketClient { + + public static void main(String[] args) throws Exception { + new UnixDomainSocketClient().runClient(); + } + + void runClient() throws IOException { + Path socketPath = Path.of(System.getProperty("user.home")) + .resolve("baeldung.socket"); + UnixDomainSocketAddress socketAddress = getAddress(socketPath); + + SocketChannel channel = openSocketChannel(socketAddress); + + String message = "Hello from Baeldung Unix domain socket article"; + writeMessage(channel, message); + } + + UnixDomainSocketAddress getAddress(Path socketPath) { + return UnixDomainSocketAddress.of(socketPath); + } + + SocketChannel openSocketChannel(UnixDomainSocketAddress socketAddress) throws IOException { + SocketChannel channel = SocketChannel + .open(StandardProtocolFamily.UNIX); + channel.connect(socketAddress); + return channel; + } + + void writeMessage(SocketChannel socketChannel, String message) throws IOException { + ByteBuffer buffer = ByteBuffer.allocate(1024); + buffer.clear(); + buffer.put(message.getBytes()); + buffer.flip(); + + while (buffer.hasRemaining()) { + socketChannel.write(buffer); + } + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketServer.java b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketServer.java new file mode 100644 index 0000000000..c3093ae00c --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/main/java/com/baeldung/socket/UnixDomainSocketServer.java @@ -0,0 +1,57 @@ +package com.baeldung.socket; + +import java.io.IOException; +import java.net.StandardProtocolFamily; +import java.net.UnixDomainSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; + +class UnixDomainSocketServer { + + public static void main(String[] args) throws IOException, InterruptedException { + new UnixDomainSocketServer().runServer(); + } + + void runServer() throws IOException, InterruptedException { + Path socketPath = Path.of(System.getProperty("user.home")) + .resolve("baeldung.socket"); + Files.deleteIfExists(socketPath); + UnixDomainSocketAddress socketAddress = getAddress(socketPath); + + ServerSocketChannel serverChannel = createServerSocketChannel(socketAddress); + + SocketChannel channel = serverChannel.accept(); + + while (true) { + readSocketMessage(channel) + .ifPresent(message -> System.out.printf("[Client message] %s%n", message)); + Thread.sleep(100); + } + } + + UnixDomainSocketAddress getAddress(Path socketPath) { + return UnixDomainSocketAddress.of(socketPath); + } + + ServerSocketChannel createServerSocketChannel(UnixDomainSocketAddress socketAddress) throws IOException { + ServerSocketChannel serverChannel = ServerSocketChannel.open(StandardProtocolFamily.UNIX); + serverChannel.bind(socketAddress); + return serverChannel; + } + + Optional readSocketMessage(SocketChannel channel) throws IOException { + ByteBuffer buffer = ByteBuffer.allocate(1024); + int bytesRead = channel.read(buffer); + if (bytesRead < 0) return Optional.empty(); + byte[] bytes = new byte[bytesRead]; + buffer.flip(); + buffer.get(bytes); + String message = new String(bytes); + return Optional.of(message); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketClientUnitTest.java b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketClientUnitTest.java new file mode 100644 index 0000000000..8cd2ee94d4 --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketClientUnitTest.java @@ -0,0 +1,82 @@ +package com.baeldung.socket; + +import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.stubbing.Answer; + +import java.io.File; +import java.io.IOException; +import java.net.StandardProtocolFamily; +import java.net.UnixDomainSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.nio.file.Path; +import java.util.UUID; + +import static java.nio.file.Files.deleteIfExists; +import static org.assertj.core.util.Files.newTemporaryFile; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class UnixDomainSocketClientUnitTest { + + @Test + public void givenSocketPath_shouldCreateUnixDomainSocketAddress() { + // given + File tempFile = newTemporaryFile(); + Path socketPath = tempFile.toPath(); + + // when + UnixDomainSocketAddress address = new UnixDomainSocketClient().getAddress(socketPath); + + // then + assertEquals(address.getPath(), socketPath); + + // cleanup + tempFile.delete(); + } + + @Test + public void givenUnixDomainSocketAddress_shouldOpenSocketChannel() throws IOException { + // given + File tempFile = newTemporaryFile(); + Path socketPath = tempFile.toPath(); + deleteIfExists(socketPath); + UnixDomainSocketAddress address = UnixDomainSocketAddress.of(socketPath); + + // bind address as a unix domain socket + ServerSocketChannel serverChannel = ServerSocketChannel.open(StandardProtocolFamily.UNIX); + serverChannel.bind(address); + + // when + SocketChannel socketChannel = new UnixDomainSocketClient().openSocketChannel(address); + + // then + assertTrue(socketChannel.isOpen()); + assertEquals(socketChannel.getRemoteAddress(), address); + + // cleanup + tempFile.delete(); + } + + @Test + public void givenSocketChannelAndMessage_shouldWriteMessage() throws IOException { + // given + SocketChannel socketChannel = Mockito.mock(SocketChannel.class); + String message = UUID.randomUUID().toString(); + Mockito.when(socketChannel.write(Mockito.any(ByteBuffer.class))) + .thenAnswer( + (Answer) invocationOnMock -> { + ((ByteBuffer) invocationOnMock.getArguments()[0]).position(message.getBytes().length); + return -1; + } + ); + + // when + new UnixDomainSocketClient().writeMessage(socketChannel, message); + + // then + Mockito.verify(socketChannel, Mockito.times(1)).write(Mockito.any(ByteBuffer.class)); + } +} diff --git a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketServerUnitTest.java b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketServerUnitTest.java new file mode 100644 index 0000000000..1d0a68ac2f --- /dev/null +++ b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/UnixDomainSocketServerUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.socket; + +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.net.UnixDomainSocketAddress; +import java.nio.channels.ServerSocketChannel; +import java.nio.file.Path; + +import static java.nio.file.Files.deleteIfExists; +import static org.assertj.core.util.Files.newTemporaryFile; +import static org.junit.Assert.assertEquals; + +public class UnixDomainSocketServerUnitTest { + + @Test + public void givenSocketPath_shouldCreateUnixDomainSocketAddress() { + // given + File tempFile = newTemporaryFile(); + Path socketPath = tempFile.toPath(); + + // when + UnixDomainSocketAddress address = new UnixDomainSocketServer().getAddress(socketPath); + + // then + assertEquals(address.getPath(), socketPath); + + // cleanup + tempFile.delete(); + } + + @Test + public void givenUnixDomainSocketAddress_shouldCreateServerSocketChannel() throws IOException { + // given + File tempFile = newTemporaryFile(); + Path socketPath = tempFile.toPath(); + deleteIfExists(socketPath); + UnixDomainSocketAddress address = UnixDomainSocketAddress.of(socketPath); + + // when + ServerSocketChannel serverSocketChannel = new UnixDomainSocketServer().createServerSocketChannel(address); + + // then + assertEquals(serverSocketChannel.getLocalAddress(), address); + + // cleanup + tempFile.delete(); + } +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index a57cd54191..d9da5a845b 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -90,7 +90,6 @@ core-java-lang-syntax-2 core-java-networking core-java-networking-2 - core-java-networking-3 core-java-nio core-java-nio-2 core-java-optional diff --git a/pom.xml b/pom.xml index 845b32615a..a2bd38bc06 100644 --- a/pom.xml +++ b/pom.xml @@ -1322,6 +1322,7 @@ core-java-modules/core-java-string-operations-3 core-java-modules/core-java-string-operations-4 core-java-modules/core-java-time-measurements + core-java-modules/core-java-networking-3 core-java-modules/multimodulemavenproject persistence-modules/sirix quarkus-vs-springboot @@ -1375,6 +1376,7 @@ core-java-modules/core-java-os core-java-modules/core-java-string-operations-3 core-java-modules/core-java-time-measurements + core-java-modules/core-java-networking-3 core-java-modules/multimodulemavenproject core-java-modules/core-java-strings persistence-modules/sirix From 334df050b87f28b1867325d2bd873bf39eb3c07a Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Fri, 26 Nov 2021 18:07:02 +0100 Subject: [PATCH 282/551] JAVA-8710: Update to lombok 1.8.22 --- core-java-modules/core-java-os/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 970c8a562a..d2bf842897 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -45,6 +45,12 @@ grep4j ${grep4j.version} + + org.projectlombok + lombok + ${lombok.version} + provided + @@ -77,6 +83,7 @@ 25.1-jre 0.4 1.8.7 + 1.18.22 From 4e211b64d74bd85adadc865a70d95d33624fd89f Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Fri, 26 Nov 2021 22:15:04 +0000 Subject: [PATCH 283/551] [JAVA-8353] Wait longer for the threads to finish --- .../IllegalMonitorStateExceptionUnitTest.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java index bef90e671f..857ab02c13 100644 --- a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -1,11 +1,12 @@ package com.baeldung.exceptions.illegalmonitorstate; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.junit.jupiter.api.Test; -import java.time.Duration; - -import static org.junit.jupiter.api.Assertions.*; - public class IllegalMonitorStateExceptionUnitTest { @Test @@ -20,11 +21,11 @@ public class IllegalMonitorStateExceptionUnitTest { Thread senderThread = new Thread(sender, "sender-thread"); senderThread.start(); - senderThread.join(1000); - receiverThread.join(1000); + // we need to wait for the sender and receiver threads to finish + senderThread.join(10_000); + receiverThread.join(10_000); - // we need to wait for enough time so that sender has had a chance to send the data - assertTimeout(Duration.ofSeconds(10), () -> assertEquals("test", receiver.getMessage())); + assertEquals("test", receiver.getMessage()); assertFalse(sender.hasIllegalMonitorStateExceptionOccurred()); assertFalse(receiver.hasIllegalMonitorStateExceptionOccurred()); } From fbb1e36049678806b1d6a9096b4b013934ea0bdb Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Sat, 27 Nov 2021 11:10:33 +0100 Subject: [PATCH 284/551] Spring Webflux and @Cacheable Annotation - moved to new package --- pom.xml | 3 + spring-5-webflux-2/README.md | 7 ++ spring-5-webflux-2/pom.xml | 102 ++++++++++++++++++ .../src/main/java}/caching/Item.java | 2 +- .../main/java}/caching/ItemRepository.java | 2 +- .../src/main/java}/caching/ItemService.java | 2 +- .../SpringWebfluxCachingApplication.java | 2 +- .../resources/application-cache.properties | 0 .../src/main/resources/logback.xml | 31 ++++++ .../MonoFluxResultCachingLiveTest.java | 2 +- .../src/test/resources/logback-test.xml | 13 +++ spring-5-webflux/README.md | 1 - spring-5-webflux/pom.xml | 20 ---- 13 files changed, 161 insertions(+), 26 deletions(-) create mode 100644 spring-5-webflux-2/README.md create mode 100644 spring-5-webflux-2/pom.xml rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/Item.java (96%) rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/ItemRepository.java (85%) rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/ItemService.java (96%) rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/SpringWebfluxCachingApplication.java (93%) rename {spring-5-webflux => spring-5-webflux-2}/src/main/resources/application-cache.properties (100%) create mode 100644 spring-5-webflux-2/src/main/resources/logback.xml rename {spring-5-webflux/src/test/java/com/baeldung/spring => spring-5-webflux-2/src/test/java}/caching/MonoFluxResultCachingLiveTest.java (98%) create mode 100644 spring-5-webflux-2/src/test/resources/logback-test.xml diff --git a/pom.xml b/pom.xml index a2bd38bc06..9581cfb004 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,9 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + + spring-5-webflux-2 + parent-modules pom diff --git a/spring-5-webflux-2/README.md b/spring-5-webflux-2/README.md new file mode 100644 index 0000000000..0222ddbaa4 --- /dev/null +++ b/spring-5-webflux-2/README.md @@ -0,0 +1,7 @@ +## Spring 5 WebFlux 2 + +This module contains articles about Spring 5 WebFlux + +## Relevant articles: + +- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable) \ No newline at end of file diff --git a/spring-5-webflux-2/pom.xml b/spring-5-webflux-2/pom.xml new file mode 100644 index 0000000000..c90fcbe3d9 --- /dev/null +++ b/spring-5-webflux-2/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + spring-5-webflux-2 + spring-5-webflux-2 + http://www.baeldung.com + 1.0-SNAPSHOT + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.jupiter + junit-jupiter + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.platform + junit-plaform-commons + + + + + io.projectreactor.addons + reactor-extra + 3.4.5 + + + com.github.ben-manes.caffeine + caffeine + 2.9.2 + + + org.springframework.boot + spring-boot-starter-data-mongodb-reactive + + + io.projectreactor + reactor-test + test + + + org.testcontainers + mongodb + 1.16.2 + test + + + com.squareup.okhttp3 + mockwebserver + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java b/spring-5-webflux-2/src/main/java/caching/Item.java similarity index 96% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java rename to spring-5-webflux-2/src/main/java/caching/Item.java index 7b79ff7503..627eeef740 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java +++ b/spring-5-webflux-2/src/main/java/caching/Item.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java b/spring-5-webflux-2/src/main/java/caching/ItemRepository.java similarity index 85% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java rename to spring-5-webflux-2/src/main/java/caching/ItemRepository.java index 27c97de36a..d69edaf5df 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java +++ b/spring-5-webflux-2/src/main/java/caching/ItemRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.springframework.data.mongodb.repository.ReactiveMongoRepository; import org.springframework.stereotype.Repository; diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java b/spring-5-webflux-2/src/main/java/caching/ItemService.java similarity index 96% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java rename to spring-5-webflux-2/src/main/java/caching/ItemService.java index b24b54521e..85d7005831 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java +++ b/spring-5-webflux-2/src/main/java/caching/ItemService.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java b/spring-5-webflux-2/src/main/java/caching/SpringWebfluxCachingApplication.java similarity index 93% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java rename to spring-5-webflux-2/src/main/java/caching/SpringWebfluxCachingApplication.java index 5266e33775..df648fe6a3 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java +++ b/spring-5-webflux-2/src/main/java/caching/SpringWebfluxCachingApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-5-webflux/src/main/resources/application-cache.properties b/spring-5-webflux-2/src/main/resources/application-cache.properties similarity index 100% rename from spring-5-webflux/src/main/resources/application-cache.properties rename to spring-5-webflux-2/src/main/resources/application-cache.properties diff --git a/spring-5-webflux-2/src/main/resources/logback.xml b/spring-5-webflux-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..48b68c6bf1 --- /dev/null +++ b/spring-5-webflux-2/src/main/resources/logback.xml @@ -0,0 +1,31 @@ + + + + + + %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable + + + + + + netty-access.log + + %msg%n + + + + + + + + + + + + + + + + diff --git a/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java b/spring-5-webflux-2/src/test/java/caching/MonoFluxResultCachingLiveTest.java similarity index 98% rename from spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java rename to spring-5-webflux-2/src/test/java/caching/MonoFluxResultCachingLiveTest.java index 322b3c5aa5..daf8367209 100644 --- a/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java +++ b/spring-5-webflux-2/src/test/java/caching/MonoFluxResultCachingLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.junit.jupiter.api.Test; diff --git a/spring-5-webflux-2/src/test/resources/logback-test.xml b/spring-5-webflux-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..12cedf5952 --- /dev/null +++ b/spring-5-webflux-2/src/test/resources/logback-test.xml @@ -0,0 +1,13 @@ + + + + + + %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable + + + + + + + diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md index 889f211fc6..bd667468fb 100644 --- a/spring-5-webflux/README.md +++ b/spring-5-webflux/README.md @@ -11,4 +11,3 @@ This module contains articles about Spring 5 WebFlux - [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) - [Set a Timeout in Spring 5 Webflux WebClient](https://www.baeldung.com/spring-webflux-timeout) - [Guide to Retry in Spring WebFlux](https://www.baeldung.com/spring-webflux-retry) -- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable) diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index d6afb686fc..69de83c227 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -66,31 +66,11 @@ - - io.projectreactor.addons - reactor-extra - 3.4.5 - - - com.github.ben-manes.caffeine - caffeine - 2.9.2 - - - org.springframework.boot - spring-boot-starter-data-mongodb-reactive - io.projectreactor reactor-test test - - org.testcontainers - mongodb - 1.16.2 - test - com.squareup.okhttp3 mockwebserver From 7c8ba28e63a2460f1364c436b89a81c3b7f69b14 Mon Sep 17 00:00:00 2001 From: Mladen Savic Date: Sat, 27 Nov 2021 11:10:33 +0100 Subject: [PATCH 285/551] Spring Webflux and @Cacheable Annotation - moved to new package --- pom.xml | 1 + spring-5-webflux-2/README.md | 7 ++ spring-5-webflux-2/pom.xml | 102 ++++++++++++++++++ .../src/main/java}/caching/Item.java | 2 +- .../main/java}/caching/ItemRepository.java | 2 +- .../src/main/java}/caching/ItemService.java | 2 +- .../SpringWebfluxCachingApplication.java | 2 +- .../resources/application-cache.properties | 0 .../src/main/resources/logback.xml | 31 ++++++ .../MonoFluxResultCachingLiveTest.java | 2 +- .../src/test/resources/logback-test.xml | 13 +++ spring-5-webflux/README.md | 1 - spring-5-webflux/pom.xml | 20 ---- 13 files changed, 159 insertions(+), 26 deletions(-) create mode 100644 spring-5-webflux-2/README.md create mode 100644 spring-5-webflux-2/pom.xml rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/Item.java (96%) rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/ItemRepository.java (85%) rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/ItemService.java (96%) rename {spring-5-webflux/src/main/java/com/baeldung/spring => spring-5-webflux-2/src/main/java}/caching/SpringWebfluxCachingApplication.java (93%) rename {spring-5-webflux => spring-5-webflux-2}/src/main/resources/application-cache.properties (100%) create mode 100644 spring-5-webflux-2/src/main/resources/logback.xml rename {spring-5-webflux/src/test/java/com/baeldung/spring => spring-5-webflux-2/src/test/java}/caching/MonoFluxResultCachingLiveTest.java (98%) create mode 100644 spring-5-webflux-2/src/test/resources/logback-test.xml diff --git a/pom.xml b/pom.xml index a2bd38bc06..bd431ef5cd 100644 --- a/pom.xml +++ b/pom.xml @@ -615,6 +615,7 @@ spring-5-reactive-oauth spring-5-reactive-security spring-5-webflux + spring-5-webflux-2 spring-activiti spring-akka diff --git a/spring-5-webflux-2/README.md b/spring-5-webflux-2/README.md new file mode 100644 index 0000000000..0222ddbaa4 --- /dev/null +++ b/spring-5-webflux-2/README.md @@ -0,0 +1,7 @@ +## Spring 5 WebFlux 2 + +This module contains articles about Spring 5 WebFlux + +## Relevant articles: + +- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable) \ No newline at end of file diff --git a/spring-5-webflux-2/pom.xml b/spring-5-webflux-2/pom.xml new file mode 100644 index 0000000000..c90fcbe3d9 --- /dev/null +++ b/spring-5-webflux-2/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + spring-5-webflux-2 + spring-5-webflux-2 + http://www.baeldung.com + 1.0-SNAPSHOT + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.jupiter + junit-jupiter + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.platform + junit-plaform-commons + + + + + io.projectreactor.addons + reactor-extra + 3.4.5 + + + com.github.ben-manes.caffeine + caffeine + 2.9.2 + + + org.springframework.boot + spring-boot-starter-data-mongodb-reactive + + + io.projectreactor + reactor-test + test + + + org.testcontainers + mongodb + 1.16.2 + test + + + com.squareup.okhttp3 + mockwebserver + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java b/spring-5-webflux-2/src/main/java/caching/Item.java similarity index 96% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java rename to spring-5-webflux-2/src/main/java/caching/Item.java index 7b79ff7503..627eeef740 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/Item.java +++ b/spring-5-webflux-2/src/main/java/caching/Item.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java b/spring-5-webflux-2/src/main/java/caching/ItemRepository.java similarity index 85% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java rename to spring-5-webflux-2/src/main/java/caching/ItemRepository.java index 27c97de36a..d69edaf5df 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemRepository.java +++ b/spring-5-webflux-2/src/main/java/caching/ItemRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.springframework.data.mongodb.repository.ReactiveMongoRepository; import org.springframework.stereotype.Repository; diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java b/spring-5-webflux-2/src/main/java/caching/ItemService.java similarity index 96% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java rename to spring-5-webflux-2/src/main/java/caching/ItemService.java index b24b54521e..85d7005831 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/ItemService.java +++ b/spring-5-webflux-2/src/main/java/caching/ItemService.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java b/spring-5-webflux-2/src/main/java/caching/SpringWebfluxCachingApplication.java similarity index 93% rename from spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java rename to spring-5-webflux-2/src/main/java/caching/SpringWebfluxCachingApplication.java index 5266e33775..df648fe6a3 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/caching/SpringWebfluxCachingApplication.java +++ b/spring-5-webflux-2/src/main/java/caching/SpringWebfluxCachingApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-5-webflux/src/main/resources/application-cache.properties b/spring-5-webflux-2/src/main/resources/application-cache.properties similarity index 100% rename from spring-5-webflux/src/main/resources/application-cache.properties rename to spring-5-webflux-2/src/main/resources/application-cache.properties diff --git a/spring-5-webflux-2/src/main/resources/logback.xml b/spring-5-webflux-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..48b68c6bf1 --- /dev/null +++ b/spring-5-webflux-2/src/main/resources/logback.xml @@ -0,0 +1,31 @@ + + + + + + %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable + + + + + + netty-access.log + + %msg%n + + + + + + + + + + + + + + + + diff --git a/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java b/spring-5-webflux-2/src/test/java/caching/MonoFluxResultCachingLiveTest.java similarity index 98% rename from spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java rename to spring-5-webflux-2/src/test/java/caching/MonoFluxResultCachingLiveTest.java index 322b3c5aa5..daf8367209 100644 --- a/spring-5-webflux/src/test/java/com/baeldung/spring/caching/MonoFluxResultCachingLiveTest.java +++ b/spring-5-webflux-2/src/test/java/caching/MonoFluxResultCachingLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.caching; +package caching; import org.junit.jupiter.api.Test; diff --git a/spring-5-webflux-2/src/test/resources/logback-test.xml b/spring-5-webflux-2/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..12cedf5952 --- /dev/null +++ b/spring-5-webflux-2/src/test/resources/logback-test.xml @@ -0,0 +1,13 @@ + + + + + + %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable + + + + + + + diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md index 889f211fc6..bd667468fb 100644 --- a/spring-5-webflux/README.md +++ b/spring-5-webflux/README.md @@ -11,4 +11,3 @@ This module contains articles about Spring 5 WebFlux - [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) - [Set a Timeout in Spring 5 Webflux WebClient](https://www.baeldung.com/spring-webflux-timeout) - [Guide to Retry in Spring WebFlux](https://www.baeldung.com/spring-webflux-retry) -- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable) diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index d6afb686fc..69de83c227 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -66,31 +66,11 @@ - - io.projectreactor.addons - reactor-extra - 3.4.5 - - - com.github.ben-manes.caffeine - caffeine - 2.9.2 - - - org.springframework.boot - spring-boot-starter-data-mongodb-reactive - io.projectreactor reactor-test test - - org.testcontainers - mongodb - 1.16.2 - test - com.squareup.okhttp3 mockwebserver From 3f28be96dbc4fc2c9568e3a7e89cbbc81514fe33 Mon Sep 17 00:00:00 2001 From: ACHRAF TAITAI <43656331+achraftt@users.noreply.github.com> Date: Sat, 27 Nov 2021 17:59:29 +0100 Subject: [PATCH 286/551] BAEL-5147 : convert ByteBuffer to String (#11504) * BAEL-5147: convert ByteBuffer to String * Update README.md --- .../core-java-string-conversions-2/README.md | 1 + .../ByteArrayToStringUnitTest.java | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/bytebuffertostring/ByteArrayToStringUnitTest.java diff --git a/core-java-modules/core-java-string-conversions-2/README.md b/core-java-modules/core-java-string-conversions-2/README.md index 46eb783a27..22f4cd89a1 100644 --- a/core-java-modules/core-java-string-conversions-2/README.md +++ b/core-java-modules/core-java-string-conversions-2/README.md @@ -9,4 +9,5 @@ This module contains articles about string conversions from/to another type. - [Converting String to BigDecimal in Java](https://www.baeldung.com/java-string-to-bigdecimal) - [Converting String to BigInteger in Java](https://www.baeldung.com/java-string-to-biginteger) - [Convert a String to Camel Case](https://www.baeldung.com/java-string-to-camel-case) +- [Convert a ByteBuffer to String] - More articles: [[<-- prev]](/core-java-string-conversions) diff --git a/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/bytebuffertostring/ByteArrayToStringUnitTest.java b/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/bytebuffertostring/ByteArrayToStringUnitTest.java new file mode 100644 index 0000000000..c498921d9a --- /dev/null +++ b/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/bytebuffertostring/ByteArrayToStringUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.bytebuffertostring; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +import org.junit.Test; + +public class ByteArrayToStringUnitTest { + private static Charset charset = StandardCharsets.UTF_8; + private static final String content = "baeldung"; + + @Test + public void convertUsingNewStringFromBufferArray_thenOK() { + // Allocate a ByteBuffer + ByteBuffer byteBuffer = ByteBuffer.wrap(content.getBytes()); + if (byteBuffer.hasArray()) { + String newContent = new String(byteBuffer.array(), charset); + assertEquals(content, newContent); + } + } + + @Test + public void convertUsingNewStringFromByteBufferGetBytes_thenOK() { + // Allocate a ByteBuffer + ByteBuffer byteBuffer = ByteBuffer.wrap(content.getBytes()); + byte[] bytes = new byte[byteBuffer.remaining()]; + byteBuffer.get(bytes); + String newContent = new String(bytes, charset); + assertEquals(content, newContent); + } + + @Test + public void convertUsingCharsetDecode_thenOK() { + // Allocate a ByteBuffer + ByteBuffer byteBuffer = ByteBuffer.wrap(content.getBytes()); + String newContent = charset.decode(byteBuffer) + .toString(); + assertEquals(content, newContent); + } + +} From 7b564fe3ef4a9e309b34646215e1c086ed883537 Mon Sep 17 00:00:00 2001 From: Azhwani <13301425+azhwani@users.noreply.github.com> Date: Sun, 28 Nov 2021 16:47:49 +0100 Subject: [PATCH 287/551] init commit (#11496) --- .../baeldung/regex/matcher/MatcherUnitTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java index 304b9f2f1d..7ec4a1ae58 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java @@ -11,6 +11,9 @@ import org.junit.jupiter.api.Test; public class MatcherUnitTest { + private static final String STRING_INPUT = "test+"; + private static final String REGEX = "\\+"; + @Test public void whenFindFourDigitWorks_thenCorrect() { Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); @@ -60,4 +63,16 @@ public class MatcherUnitTest { assertTrue(m.matches());// matches will always return the same return } + @Test + public void whenUsingMatcher_thenReturnTrue() { + Pattern pattern = Pattern.compile(REGEX); + Matcher matcher = pattern.matcher(STRING_INPUT); + assertTrue(matcher.find()); + } + + @Test + public void whenUsingMatches_thenReturnFalse() { + assertFalse(Pattern.matches(REGEX, STRING_INPUT)); + } + } From 9461caeb278d32997871fa42a80d0ce3f8201a52 Mon Sep 17 00:00:00 2001 From: wugangca Date: Sun, 28 Nov 2021 08:51:13 -0700 Subject: [PATCH 288/551] BAEL-5205 Adding a column to an Excel file using Apache POI (#11491) * BAEL-5205 Adding a column to an Excel file using Apache POI * BAEL-5205 move the test xls file into the test folder Co-authored-by: Gang Wu --- apache-poi-2/.gitignore | 3 ++ apache-poi-2/pom.xml | 24 +++++++++++ .../poi/excel/newcolumn/ExcelColumn.java | 16 +++++++ .../excel/newcolumn/ExcelColumnUnitTest.java | 40 ++++++++++++++++++ .../src/test/resources/newColumnTest.xlsx | Bin 0 -> 3375 bytes 5 files changed, 83 insertions(+) create mode 100644 apache-poi-2/.gitignore create mode 100644 apache-poi-2/pom.xml create mode 100644 apache-poi-2/src/main/java/com/baeldung/poi/excel/newcolumn/ExcelColumn.java create mode 100644 apache-poi-2/src/test/java/com/baeldung/poi/excel/newcolumn/ExcelColumnUnitTest.java create mode 100644 apache-poi-2/src/test/resources/newColumnTest.xlsx diff --git a/apache-poi-2/.gitignore b/apache-poi-2/.gitignore new file mode 100644 index 0000000000..9552c1e63d --- /dev/null +++ b/apache-poi-2/.gitignore @@ -0,0 +1,3 @@ +*.docx +temp.xls +temp.xlsx diff --git a/apache-poi-2/pom.xml b/apache-poi-2/pom.xml new file mode 100644 index 0000000000..1cb6509457 --- /dev/null +++ b/apache-poi-2/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + apache-poi + 0.0.1-SNAPSHOT + apache-poi + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.poi + poi-ooxml + 5.0.0 + + + + \ No newline at end of file diff --git a/apache-poi-2/src/main/java/com/baeldung/poi/excel/newcolumn/ExcelColumn.java b/apache-poi-2/src/main/java/com/baeldung/poi/excel/newcolumn/ExcelColumn.java new file mode 100644 index 0000000000..00ca24f6e8 --- /dev/null +++ b/apache-poi-2/src/main/java/com/baeldung/poi/excel/newcolumn/ExcelColumn.java @@ -0,0 +1,16 @@ +package com.baeldung.poi.excel.newcolumn; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + + +public class ExcelColumn { + + public void addColumn(Sheet sheet, CellType cellType) { + for (Row currentRow : sheet) { + currentRow.createCell(currentRow.getLastCellNum(), cellType); + } + } +} diff --git a/apache-poi-2/src/test/java/com/baeldung/poi/excel/newcolumn/ExcelColumnUnitTest.java b/apache-poi-2/src/test/java/com/baeldung/poi/excel/newcolumn/ExcelColumnUnitTest.java new file mode 100644 index 0000000000..9b991719b1 --- /dev/null +++ b/apache-poi-2/src/test/java/com/baeldung/poi/excel/newcolumn/ExcelColumnUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.poi.excel.newcolumn; + +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import static org.junit.Assert.assertEquals; + +public class ExcelColumnUnitTest { + private static final String FILE_NAME = "newColumnTest.xlsx"; + private String fileLocation; + + @Before + public void setup() throws URISyntaxException { + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + } + + @Test + public void givenExistingRows_whenAddNewColumn_thenRowColumnNumberIncreased() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + assertEquals(5, row.getLastCellNum()); + + ExcelColumn excelColumn = new ExcelColumn(); + excelColumn.addColumn(sheet, CellType.STRING); + assertEquals(6, row.getLastCellNum()); + + workbook.close(); + } + +} \ No newline at end of file diff --git a/apache-poi-2/src/test/resources/newColumnTest.xlsx b/apache-poi-2/src/test/resources/newColumnTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..54e8734d58f7e14ba90c1bd65417142c460db369 GIT binary patch literal 3375 zcmaJ@2{@E%8y-f+P?4l59h3=8#W*8tc4`>QjHHm=ScWmiR*WUokbO_tvUEsMvNo~| z*&-o(nIj^Sts_gwKcoLY=J-!N-}TKmb6wx_&ig#?{oMDBMgiIQ02~|~fJ(q|G=M4g z)4!W(5L`X6uAY`gK5keKbBSwsm$D0OuJv%9^`w@5n9L&j;(;Iyp=SOEi@+Nc$Ja9FKfyu`i1R)Z=a;jzn{{ z-T6dwlxTHaxm4O&elBP)Zan{n2B!DkbV^vt(;)wjXS%Bw6?pkHGxmoE=dK>7g%;<> zj+|;xf8Mf?Zx#v8Z4wk#Y%9JEUL@%+rUZlzTwVxqYdqrPY@nOP28ngnzivF6yO8&; zR^2p!{N#B?AQ7?@ILIv=Zhc6|J?uTnpq2%V0&(~zz9cHL002kW008t)d(TDhy`?+W z#Y0kp@mUy8#WlcplPw!3X>v1Gk(i3xzfa;LXIZ4pv~_LT28NQWH`*o4P@Dpv#i9P2 zpl)xKQ0;1rL`F`K*PGyM$HCPBfosZ2k7iX5P$%6+k?hAB0xJBo!S`Jgsd?G3WBkAn zB&DA+5X72H-rqPhB?n40ov;uq6=ka!^h8B zFg3g|Dn_#wJYMuy@?IB9pq5EXO$wm;^V3ytqKgosUr%?c7VF3#9{mp1%l2~g!4(9> z1pYK_ilEaUlMMtb@U3TCa7>j54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GWD$8V!C9v%$nOgaOmP&+Ms*K_2X|oXNNqE_${Sc5?BD#uCem# zGHlCzFhWtVUyn&%3)sEV@*aP#o6EcEdPwz=5`~Dau^au5SN`~ZzjmWH&`lnx-gCj{ zx8X8W09ziUs&Z+9i-8z2P%*BDUOD2Ih=FV)#={Yd_4J?<75yQ##q{xJ1|h0EH~-XI z=T7zShL|`O-eq?zz}pJlg*f|LT2gUs-tXP*-e;?+Y zv-r_-!cq31nbH+R&1Cm;fn-(K)#Cw^6MMo>ogebld?0c}su~KK@%kR}*W%pR=f|3V&LnumF(cPX@5m+_x@p0~Z-xA8gEPF)_vI^cI zAAN72d3a3;cZaHT_Ypc->oDe$C*q^i3zLE~!A`xgC24{mp*qOo>CyH@&?j8aSL^cX zxhWxzz%9XDBzV>!=_r-mIt><9KESrOWp-W+Z~M>q7pIFx{c{0kd%`ei+u=w5OD4Ov zGm+T_Fx<;_q|o=d)64A4X4XH3RoD(EAXE1LjKj`!X0>66y!oQz-p0XhyWcmMzZ literal 0 HcmV?d00001 From 9ab2a1ab0f5e5845f43f76b0d6473c85fe9916a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matea=20Pej=C4=8Dinovi=C4=87?= Date: Sun, 28 Nov 2021 18:03:38 +0100 Subject: [PATCH 289/551] BAEL-5253 moving the tests to other module --- .../core-java-string-algorithms-3/pom.xml | 9 ++- .../StringFirstCharacterUppercase.java | 2 +- .../controller/UserController.java | 63 ------------------- .../baeldung/swagger2pdf/objects/User.java | 12 ---- 4 files changed, 8 insertions(+), 78 deletions(-) rename core-java-modules/{core-java-string-algorithms-2 => core-java-string-algorithms-3}/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java (100%) delete mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java delete mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 6700e9ba95..180d75cc61 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -24,6 +24,11 @@ commons-validator ${validator.version} + + com.google.guava + guava + ${guava.version} + @@ -49,8 +54,8 @@ - 28.1-jre + 31.0.1-jre 1.7 - \ No newline at end of file + diff --git a/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java similarity index 100% rename from core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java rename to core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java index 0d9d3b6431..f9edd005dc 100644 --- a/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java @@ -1,9 +1,9 @@ package com.baeldung.isuppercase; -import com.google.common.base.Ascii; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import com.google.common.base.Ascii; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.matchesPattern; diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java deleted file mode 100644 index 380bac6f8c..0000000000 --- a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/controller/UserController.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.baeldung.swagger2pdf.controller; - -import com.baeldung.swagger2pdf.objects.User; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.NonNull; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; - -@Controller -@Api(value = "/api", description = "A controller for user management") -@RequestMapping("/user") -@ResponseStatus(HttpStatus.OK) -public class UserController { - - static List users; - - static { - users = new ArrayList<>(); - users.add(new User("Mark", "Thompson", 23)); - users.add(new User("Kate", "Jordan", 22)); - } - - @ApiOperation(value = "Retrieves all the users") - @RequestMapping(value = "/users", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public List getUsers() { - return users; - } - - @ApiOperation(value = "Retrieves a user based on first name") - @RequestMapping(value = "/user", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public User getUser(@NonNull @RequestParam String firstName) { - - if (firstName.isEmpty()) { - return null; - } - - return users.stream() - .filter(user -> user.getFirstName().equals(firstName)) - .findAny() - .orElse(null); - - } - - @ApiOperation(value = "Adds a user.") - @RequestMapping(value = "/user", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE) - public List addUser(@NonNull @RequestBody User user) { - users.add(user); - return users; - } -} - diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java deleted file mode 100644 index 8c59cb246a..0000000000 --- a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2pdf/objects/User.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.swagger2pdf.objects; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class User { - private String firstName; - private String lastName; - private int age; -} From f5b596784f1673ce21173063b0d5dc81f759b7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matea=20Pej=C4=8Dinovi=C4=87?= Date: Sun, 28 Nov 2021 18:14:42 +0100 Subject: [PATCH 290/551] renaming the test class --- ...ppercase.java => StringFirstCharacterUppercaseUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/{StringFirstCharacterUppercase.java => StringFirstCharacterUppercaseUnitTest.java} (94%) diff --git a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java similarity index 94% rename from core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java rename to core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java index f9edd005dc..6803285ca2 100644 --- a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java @@ -9,7 +9,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.matchesPattern; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class StringFirstCharacterUppercase { +public class StringFirstCharacterUppercaseUnitTest { @Test public void givenString_whenCheckingWithCharacterIsUpperCase_thenStringCapitalized() { From 28b7ea96c7229147deb7cf7046a5b69e5caeb371 Mon Sep 17 00:00:00 2001 From: Bhaskara Date: Mon, 29 Nov 2021 05:02:23 +0530 Subject: [PATCH 291/551] BAEL-4648: How to debug Websockets (#11469) * BAEL-4648: How to debug Websockets * Formatted the code * Incorporated comments from Kevin --- spring-websockets/pom.xml | 4 +- .../debugwebsockets/StockTicksController.java | 39 ++++++ .../StompClientSessionHandler.java | 31 +++++ .../debugwebsockets/StompWebSocketClient.java | 24 ++++ .../debugwebsockets/WebsocketApplication.java | 13 ++ .../WebsocketConfiguration.java | 25 ++++ .../WebSocketIntegrationTest.java | 114 ++++++++++++++++++ 7 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 spring-websockets/src/main/java/com/baeldung/debugwebsockets/StockTicksController.java create mode 100644 spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompClientSessionHandler.java create mode 100644 spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompWebSocketClient.java create mode 100644 spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketApplication.java create mode 100644 spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketConfiguration.java create mode 100644 spring-websockets/src/test/java/com/baeldung/debugwebsockets/WebSocketIntegrationTest.java diff --git a/spring-websockets/pom.xml b/spring-websockets/pom.xml index a28ef8749a..28c875d50d 100644 --- a/spring-websockets/pom.xml +++ b/spring-websockets/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-websockets spring-websockets diff --git a/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StockTicksController.java b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StockTicksController.java new file mode 100644 index 0000000000..0942657c33 --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StockTicksController.java @@ -0,0 +1,39 @@ +package com.baeldung.debugwebsockets; + +import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Controller; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; + +@Controller +public class StockTicksController { + private final SimpMessagingTemplate simpMessagingTemplate; + + public StockTicksController(SimpMessagingTemplate simpMessagingTemplate) { + this.simpMessagingTemplate = simpMessagingTemplate; + } + + @Scheduled(fixedRate = 3000) + public void sendTicks() { + simpMessagingTemplate.convertAndSend("/topic/ticks", getStockTicks()); + } + + private Map getStockTicks() { + Map ticks = new HashMap<>(); + ticks.put("AAPL", getRandomTick()); + ticks.put("GOOGL", getRandomTick()); + ticks.put("MSFT", getRandomTick()); + ticks.put("TSLA", getRandomTick()); + ticks.put("AMZN", getRandomTick()); + ticks.put("HPE", getRandomTick()); + + return ticks; + } + + private int getRandomTick() { + return ThreadLocalRandom.current().nextInt(-100, 100 + 1); + } +} \ No newline at end of file diff --git a/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompClientSessionHandler.java b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompClientSessionHandler.java new file mode 100644 index 0000000000..535be79cee --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompClientSessionHandler.java @@ -0,0 +1,31 @@ +package com.baeldung.debugwebsockets; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.messaging.simp.stomp.StompHeaders; +import org.springframework.messaging.simp.stomp.StompSession; +import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter; + +import java.lang.reflect.Type; +import java.util.Map; + +public class StompClientSessionHandler extends StompSessionHandlerAdapter { + private static final Logger logger = LoggerFactory.getLogger("StompClientSessionHandler"); + + @Override + public void afterConnected(StompSession session, StompHeaders connectedHeaders) { + logger.info("New session established. Session Id -> {}", session.getSessionId()); + session.subscribe("/topic/ticks", this); + logger.info("Subscribed to topic: /topic/ticks"); + } + + @Override + public void handleFrame(StompHeaders headers, Object payload) { + logger.info("Payload -> {}", payload); + } + + @Override + public Type getPayloadType(StompHeaders headers) { + return Map.class; + } +} diff --git a/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompWebSocketClient.java b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompWebSocketClient.java new file mode 100644 index 0000000000..0cbe32bf65 --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/StompWebSocketClient.java @@ -0,0 +1,24 @@ +package com.baeldung.debugwebsockets; + +import org.springframework.messaging.converter.MappingJackson2MessageConverter; +import org.springframework.messaging.simp.stomp.StompSessionHandler; +import org.springframework.web.socket.client.WebSocketClient; +import org.springframework.web.socket.client.standard.StandardWebSocketClient; +import org.springframework.web.socket.messaging.WebSocketStompClient; + +import java.util.Scanner; + +public class StompWebSocketClient { + + private static final String URL = "ws://localhost:8080/stock-ticks/websocket"; + + public static void main(String[] args) { + WebSocketClient client = new StandardWebSocketClient(); + WebSocketStompClient stompClient = new WebSocketStompClient(client); + stompClient.setMessageConverter(new MappingJackson2MessageConverter()); + StompSessionHandler sessionHandler = new StompClientSessionHandler(); + stompClient.connect(URL, sessionHandler); + + new Scanner(System.in).nextLine(); + } +} diff --git a/spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketApplication.java b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketApplication.java new file mode 100644 index 0000000000..1d0d6950d3 --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.debugwebsockets; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class WebsocketApplication { + + public static void main(String[] args) { + SpringApplication.run(WebsocketApplication.class, args); + } + +} diff --git a/spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketConfiguration.java b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketConfiguration.java new file mode 100644 index 0000000000..3735e7359b --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/debugwebsockets/WebsocketConfiguration.java @@ -0,0 +1,25 @@ +package com.baeldung.debugwebsockets; + +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.simp.config.MessageBrokerRegistry; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; +import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +@Configuration +@EnableWebSocketMessageBroker +@EnableScheduling +public class WebsocketConfiguration implements WebSocketMessageBrokerConfigurer { + @Override + public void configureMessageBroker(MessageBrokerRegistry config) { + config.enableSimpleBroker("/topic"); + config.setApplicationDestinationPrefixes("/app"); + } + + @Override + public void registerStompEndpoints(StompEndpointRegistry registry) { + registry.addEndpoint("/stock-ticks").setAllowedOriginPatterns("*").withSockJS(); + } + +} diff --git a/spring-websockets/src/test/java/com/baeldung/debugwebsockets/WebSocketIntegrationTest.java b/spring-websockets/src/test/java/com/baeldung/debugwebsockets/WebSocketIntegrationTest.java new file mode 100644 index 0000000000..bdc283b9e4 --- /dev/null +++ b/spring-websockets/src/test/java/com/baeldung/debugwebsockets/WebSocketIntegrationTest.java @@ -0,0 +1,114 @@ +package com.baeldung.debugwebsockets; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.messaging.converter.MappingJackson2MessageConverter; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompFrameHandler; +import org.springframework.messaging.simp.stomp.StompHeaders; +import org.springframework.messaging.simp.stomp.StompSession; +import org.springframework.messaging.simp.stomp.StompSessionHandler; +import org.springframework.web.socket.client.WebSocketClient; +import org.springframework.web.socket.client.standard.StandardWebSocketClient; +import org.springframework.web.socket.messaging.WebSocketStompClient; + +import java.lang.reflect.Type; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + +/** + * This should be part of integration test suite. + * The test starts the server and then connects to the WebSocket. Then verifies if the messages are received from the + * WebSocket. + * This test is inspired from: https://github.com/spring-guides/gs-messaging-stomp-websocket/blob/main/complete/src/test/java/com/example/messagingstompwebsocket/GreetingIntegrationTests.java + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class WebSocketIntegrationTest{ + WebSocketClient client; + WebSocketStompClient stompClient; + @LocalServerPort + private int port; + private static final Logger logger= LoggerFactory.getLogger(WebSocketIntegrationTest.class); + + @BeforeEach + public void setup() { + logger.info("Setting up the tests ..."); + client = new StandardWebSocketClient(); + stompClient = new WebSocketStompClient(client); + stompClient.setMessageConverter(new MappingJackson2MessageConverter()); + } + + @Test + void givenWebSocket_whenMessage_thenVerifyMessage() throws Exception { + final CountDownLatch latch = new CountDownLatch(1); + final AtomicReference failure = new AtomicReference<>(); + StompSessionHandler sessionHandler = new StompSessionHandler() { + @Override + public Type getPayloadType(StompHeaders headers) { + return null; + } + + @Override + public void handleFrame(StompHeaders headers, Object payload) { + } + + @Override + public void afterConnected(StompSession session, StompHeaders connectedHeaders) { + logger.info("Connected to the WebSocket ..."); + session.subscribe("/topic/ticks", new StompFrameHandler() { + @Override + public Type getPayloadType(StompHeaders headers) { + return Map.class; + } + + @Override + public void handleFrame(StompHeaders headers, Object payload) { + try { + + assertThat(payload).isNotNull(); + assertThat(payload).isInstanceOf(Map.class); + + @SuppressWarnings("unchecked") + Map map = (Map) payload; + + assertThat(map).containsKey("HPE"); + assertThat(map.get("HPE")).isInstanceOf(Integer.class); + } catch (Throwable t) { + failure.set(t); + logger.error("There is an exception ", t); + } finally { + session.disconnect(); + latch.countDown(); + } + + } + }); + } + + @Override + public void handleException(StompSession session, StompCommand command, StompHeaders headers, byte[] payload, Throwable exception) { + } + + @Override + public void handleTransportError(StompSession session, Throwable exception) { + } + }; + stompClient.connect("ws://localhost:{port}/stock-ticks/websocket", sessionHandler, this.port); + if (latch.await(20, TimeUnit.SECONDS)) { + if (failure.get() != null) { + fail("Assertion Failed", failure.get()); + } + } else { + fail("Could not receive the message on time"); + } + } +} From 0c7a0bcb8db0e851f8ac22e7b2680d38381e54aa Mon Sep 17 00:00:00 2001 From: Teica Date: Mon, 29 Nov 2021 21:02:40 +0100 Subject: [PATCH 292/551] Update pom.xml --- .../spring-boot-swagger/pom.xml | 113 ------------------ 1 file changed, 113 deletions(-) diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml index 41f41a92b9..d6b62bce3c 100644 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -25,26 +25,6 @@ springfox-boot-starter ${springfox.version} - - io.springfox - springfox-swagger2 - ${springfox-swagger2.version} - - - io.swagger.core.v3 - swagger-jaxrs2 - ${swagger-jaxrs2.version} - - - javax.ws.rs - javax.ws.rs-api - ${javax.ws.rs-api.version} - - - org.projectlombok - lombok - ${lombok.version} - @@ -53,104 +33,11 @@ org.springframework.boot spring-boot-maven-plugin - - - - com.github.kongchen - swagger-maven-plugin - 3.1.3 - - - - false - com.baeldung.swagger2pdf.controller.UserController - /api - - DEMO REST API - A simple DEMO project for REST API documentation - v1 - - ${project.build.directory}/api - true - - - - - - package - - generate - - - - - - io.github.robwin - swagger2markup-maven-plugin - 0.9.3 - - ${project.build.directory}/api - ${generated.asciidoc.directory} - asciidoc - - - - package - - process-swagger - - - - - - org.asciidoctor - asciidoctor-maven-plugin - 2.2.1 - - - - org.asciidoctor - asciidoctorj-pdf - 1.6.0 - - - - ${project.build.outputDirectory}/../asciidoc - overview.adoc - - book - left - 2 - ${generated.asciidoc.directory} - - - - - - asciidoc-to-pdf - package - - process-asciidoc - - - pdf - ${project.build.outputDirectory}/api/pdf - - - - - - 3.0.0 - ${project.build.outputDirectory}/asciidoc - 2.10.5 - 2.1.11 - 2.1 - 1.18.22 From d9b41d973700f64d3752c84393a02f211b0262b0 Mon Sep 17 00:00:00 2001 From: Teica Date: Mon, 29 Nov 2021 21:03:28 +0100 Subject: [PATCH 293/551] Update pom.xml From 3cf650f4ebeb9101b6b3085bd02beedb61ea7f7c Mon Sep 17 00:00:00 2001 From: Teica Date: Mon, 29 Nov 2021 21:04:08 +0100 Subject: [PATCH 294/551] Update pom.xml From c215f719592286fbe8ab4b702e0013dcd987a41c Mon Sep 17 00:00:00 2001 From: Teica Date: Mon, 29 Nov 2021 21:05:29 +0100 Subject: [PATCH 295/551] Delete pom.xml --- .../spring-boot-swagger/pom.xml | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-swagger/pom.xml diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml deleted file mode 100644 index d6b62bce3c..0000000000 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - 4.0.0 - spring-boot-swagger - 0.1.0-SNAPSHOT - spring-boot-swagger - jar - Module For Spring Boot Swagger - - - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - io.springfox - springfox-boot-starter - ${springfox.version} - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - 3.0.0 - - - From 3bcedb6eda3bf64e592d5e5a7c8762b57e72c76a Mon Sep 17 00:00:00 2001 From: Teica Date: Mon, 29 Nov 2021 21:07:36 +0100 Subject: [PATCH 296/551] Create pom.xml --- .../spring-boot-swagger/pom.xml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 spring-boot-modules/spring-boot-swagger/pom.xml diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml new file mode 100644 index 0000000000..d6b62bce3c --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + spring-boot-swagger + 0.1.0-SNAPSHOT + spring-boot-swagger + jar + Module For Spring Boot Swagger + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + + + + + org.springframework.boot + spring-boot-starter-web + + + io.springfox + springfox-boot-starter + ${springfox.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + 3.0.0 + + + From 719c4e4e0bd230f26e28d13e8b21c9002dc6cfe1 Mon Sep 17 00:00:00 2001 From: Teica Date: Tue, 30 Nov 2021 01:26:16 +0100 Subject: [PATCH 297/551] Feature bael 5253 (#11526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BAEL-5032 Swagger to PDF * BAEL-5032 added lombok as dependency * BAEL-5253 moving the tests to other module * renaming the test class * Update pom.xml * Update pom.xml * Update pom.xml * Delete pom.xml * Create pom.xml Co-authored-by: Matea Pejčinović --- core-java-modules/core-java-string-algorithms-3/pom.xml | 9 +++++++-- .../StringFirstCharacterUppercaseUnitTest.java} | 4 ++-- spring-boot-modules/spring-boot-swagger/pom.xml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) rename core-java-modules/{core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java => core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java} (94%) diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 6700e9ba95..180d75cc61 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -24,6 +24,11 @@ commons-validator ${validator.version} + + com.google.guava + guava + ${guava.version} + @@ -49,8 +54,8 @@ - 28.1-jre + 31.0.1-jre 1.7 - \ No newline at end of file + diff --git a/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java similarity index 94% rename from core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java rename to core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java index 0d9d3b6431..6803285ca2 100644 --- a/core-java-modules/core-java-string-algorithms-2/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercase.java +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java @@ -1,15 +1,15 @@ package com.baeldung.isuppercase; -import com.google.common.base.Ascii; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import com.google.common.base.Ascii; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.matchesPattern; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class StringFirstCharacterUppercase { +public class StringFirstCharacterUppercaseUnitTest { @Test public void givenString_whenCheckingWithCharacterIsUpperCase_thenStringCapitalized() { diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml index 87ee5f04cb..d6b62bce3c 100644 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -40,4 +40,4 @@ 3.0.0 - \ No newline at end of file + From 2026f9cae7043b5e8ec1a0f88722517593851da6 Mon Sep 17 00:00:00 2001 From: vaibhav007jain <72961247+vaibhav007jain@users.noreply.github.com> Date: Tue, 30 Nov 2021 08:51:17 +0530 Subject: [PATCH 298/551] BAEL-5228: Adding code for approaches to concatenating null string in java (#11464) * commited initial code for hexagonal architecture * Deleting to check in again * Deleing to check in again * Push first code for Hexagonal Architecture * final code with UT for JSON to Java conversion * removed hexagonal-architecture code from last commit * BEL-5071 updated README * BAEL-5071: Undo README changes and added a nested object in the JSON example. * BAEL-5071: fixed whitespace/indentation in JsonToJavaClassConversion.java * BAEL-5151: Added code for getting the first of a String * BAEL-5151: Renamed Unit Test * BAEL-5151: Moved the files from core-java-string-operations to core-java-string-operations-3 * BAEL-5151: Replaced tabs with white spaces. * BAEL-5228: Adding code for approaches to concatening null string in java * BAEL-5228: Moved file to correct folder and added a UT. * BAEL-5228: corrected import statements. * BAEL-5228: corrected last commit. * BAEL-5228: removed extra import. * BAEL-5228: renamed UT Co-authored-by: Vaibhav Jain --- .../concatenation/ConcatenatingNull.java | 86 +++++++++++++++++++ .../ConcatenatingNullUnitTest.java | 59 +++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/concatenation/ConcatenatingNull.java create mode 100644 core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/concatenation/ConcatenatingNullUnitTest.java diff --git a/core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/concatenation/ConcatenatingNull.java b/core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/concatenation/ConcatenatingNull.java new file mode 100644 index 0000000000..250a0d6b25 --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/src/main/java/com/baeldung/concatenation/ConcatenatingNull.java @@ -0,0 +1,86 @@ +package com.baeldung.concatenation; + +import java.util.StringJoiner; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ConcatenatingNull { + + public static void main(String[] args) { + String[] values = { "Java ", null, "", "is ", "great!" }; + + concatenateUsingPlusOperator(values); + concatenateUsingHelperMethod(values); + concatenateUsingStringBuilder(values); + concatenateUsingJoin(values); + concatenateUsingStringJoiner(values); + concatenateUsingCollectorsJoining(values); + concatenateUsingStringConcat(values); + } + + public static String concatenateUsingStringConcat(String[] values) { + String result = ""; + + for (String value : values) { + result = result.concat(getNonNullString(value)); + } + + return result; + } + + public static String concatenateUsingCollectorsJoining(String[] values) { + String result = Stream.of(values).filter(value -> null != value).collect(Collectors.joining("")); + + return result; + } + + public static String concatenateUsingStringJoiner(String[] values) { + StringJoiner result = new StringJoiner(""); + + for (String value : values) { + result = result.add(getNonNullString(value)); + } + + return result.toString(); + } + + public static String concatenateUsingJoin(String[] values) { + String result = String.join("", values); + + return result; + } + + public static String concatenateUsingStringBuilder(String[] values) { + StringBuilder result = new StringBuilder(); + + for (String value : values) { + result = result.append(getNonNullString(value)); + } + + return result.toString(); + } + + public static String concatenateUsingHelperMethod(String[] values) { + String result = ""; + + for (String value : values) { + result = result + getNonNullString(value); + } + + return result; + } + + public static String concatenateUsingPlusOperator(String[] values) { + String result = ""; + + for (String value : values) { + result = result + (value == null ? "" : value); + } + + return result; + } + + private static String getNonNullString(String value) { + return value == null ? "" : value; + } +} diff --git a/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/concatenation/ConcatenatingNullUnitTest.java b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/concatenation/ConcatenatingNullUnitTest.java new file mode 100644 index 0000000000..20e5f6ad7d --- /dev/null +++ b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/concatenation/ConcatenatingNullUnitTest.java @@ -0,0 +1,59 @@ +package com.baeldung.concatenation; + +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingCollectorsJoining; +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingHelperMethod; +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingJoin; +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingPlusOperator; +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingStringBuilder; +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingStringConcat; +import static com.baeldung.concatenation.ConcatenatingNull.concatenateUsingStringJoiner; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class ConcatenatingNullUnitTest { + + String[] values = { "Java ", null, "", "is ", "great!" }; + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingPlus_thenNullIsIgnored() { + String result = concatenateUsingPlusOperator(values); + assertEquals("Java is great!", result); + } + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingHelperMethod_thenNullIsIgnored() { + String result = concatenateUsingHelperMethod(values); + assertEquals("Java is great!", result); + } + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingStringBuilder_thenNullIsIgnored() { + String result = concatenateUsingStringBuilder(values); + assertEquals("Java is great!", result); + } + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingJoin_thenNullIsNotIgnored() { + String result = concatenateUsingJoin(values); + assertEquals("Java nullis great!", result); + } + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingStringJoiner_thenNullIsIgnored() { + String result = concatenateUsingStringJoiner(values); + assertEquals("Java is great!", result); + } + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingCollectorsJoining_thenNullIsIgnored() { + String result = concatenateUsingCollectorsJoining(values); + assertEquals("Java is great!", result); + } + + @Test + public void givenStringElementsWithNull_whenConcatenatedUsingStringConcat_thenNullIsIgnored() { + String result = concatenateUsingStringConcat(values); + assertEquals("Java is great!", result); + } +} From 318df3fb842e1089707426e5f3115f7e6d5da40e Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Tue, 30 Nov 2021 09:06:22 +0530 Subject: [PATCH 299/551] JAVA-8735: fix logging related integration tests --- logging-modules/logback/pom.xml | 36 ++++++++++++++++++++++++++++++ spring-5-reactive-2/pom.xml | 38 +++++++++++++++++++++++++++++++- spring-5-reactive-client/pom.xml | 38 +++++++++++++++++++++++++++++++- 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml index 48bb37b881..b4ee42367f 100644 --- a/logging-modules/logback/pom.xml +++ b/logging-modules/logback/pom.xml @@ -74,4 +74,40 @@ 1.1.1 + + + integration-lite-first + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + integration-lite-second + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + \ No newline at end of file diff --git a/spring-5-reactive-2/pom.xml b/spring-5-reactive-2/pom.xml index 0758365932..e48d42a863 100644 --- a/spring-5-reactive-2/pom.xml +++ b/spring-5-reactive-2/pom.xml @@ -75,9 +75,45 @@
+ + + integration-lite-first + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + integration-lite-second + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + 1.0.1.RELEASE 2.24.0 - \ No newline at end of file diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml index 136f31b49e..4502059ed3 100644 --- a/spring-5-reactive-client/pom.xml +++ b/spring-5-reactive-client/pom.xml @@ -148,6 +148,43 @@
+ + + integration-lite-first + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + integration-lite-second + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + 1.0.1.RELEASE 1.1.3 @@ -157,5 +194,4 @@ 1.1.6 4.0.1 - \ No newline at end of file From 696b754971fe8d25fde5f31687e77efac873caa0 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Mon, 29 Nov 2021 22:19:32 -0600 Subject: [PATCH 300/551] Add and update README files (#11530) --- apache-poi-2/README.md | 8 ++++++++ apache-poi/README.md | 1 + 2 files changed, 9 insertions(+) create mode 100644 apache-poi-2/README.md diff --git a/apache-poi-2/README.md b/apache-poi-2/README.md new file mode 100644 index 0000000000..69aabf4616 --- /dev/null +++ b/apache-poi-2/README.md @@ -0,0 +1,8 @@ +## Apache POI + +This module contains articles about Apache POI + +### Relevant Articles: + +- [Adding a Column to an Excel Sheet Using Apache POI](https://www.baeldung.com/java-excel-add-column) +- More articles: [[<-- prev]](/apache-poi) diff --git a/apache-poi/README.md b/apache-poi/README.md index d3d60358c5..6d5b80b03a 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -15,3 +15,4 @@ This module contains articles about Apache POI - [Multiline Text in Excel Cell Using Apache POI](https://www.baeldung.com/apache-poi-write-multiline-text) - [Set Background Color of a Cell with Apache POI](https://www.baeldung.com/apache-poi-background-color) - [Add Borders to Excel Cells With Apache POI](https://www.baeldung.com/apache-poi-add-borders) +- More articles: [[next -->]](/apache-poi-2) From 052eb565bc2cc7e0413afe60377a88db70bda085 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Wed, 1 Dec 2021 01:17:36 +0100 Subject: [PATCH 301/551] Java Hashmap with different value types (#11495) * Java Hashmap with different value types * some fixes according to review comments * convert liveTest -> unitTest * convert liveTest -> unitTest --- .../mulipletypesinmap/DynamicTypeValue.java | 5 ++ .../mulipletypesinmap/InstantTypeValue.java | 24 ++++++ .../mulipletypesinmap/IntArrayTypeValue.java | 20 +++++ .../mulipletypesinmap/IntegerTypeValue.java | 17 +++++ .../MultipleTypesInMapUnitTest.java | 75 +++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/DynamicTypeValue.java create mode 100644 core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/InstantTypeValue.java create mode 100644 core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntArrayTypeValue.java create mode 100644 core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntegerTypeValue.java create mode 100644 core-java-modules/core-java-collections-4/src/test/java/com/baeldung/multipletypesinmap/MultipleTypesInMapUnitTest.java diff --git a/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/DynamicTypeValue.java b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/DynamicTypeValue.java new file mode 100644 index 0000000000..4c9ed89f63 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/DynamicTypeValue.java @@ -0,0 +1,5 @@ +package com.baeldung.collections.mulipletypesinmap; + +public interface DynamicTypeValue { + String valueDescription(); +} diff --git a/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/InstantTypeValue.java b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/InstantTypeValue.java new file mode 100644 index 0000000000..448e66d872 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/InstantTypeValue.java @@ -0,0 +1,24 @@ +package com.baeldung.collections.mulipletypesinmap; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; + +public class InstantTypeValue implements DynamicTypeValue { + private static DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + .withZone(ZoneId.systemDefault()); + private Instant value; + + public InstantTypeValue(Instant value) { + this.value = value; + } + + @Override + public String valueDescription() { + if (value == null) { + return "The value is null."; + } + return String.format("The value is an instant: %s", FORMATTER.format(value)); + } + +} diff --git a/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntArrayTypeValue.java b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntArrayTypeValue.java new file mode 100644 index 0000000000..290982183f --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntArrayTypeValue.java @@ -0,0 +1,20 @@ +package com.baeldung.collections.mulipletypesinmap; + +import java.util.Arrays; + +public class IntArrayTypeValue implements DynamicTypeValue { + private int[] value; + + public IntArrayTypeValue(int[] value) { + this.value = value; + } + + @Override + public String valueDescription() { + if (value == null) { + return "The value is null."; + } + return String.format("The value is an array of %d integers: %s", value.length, Arrays.toString(value)); + } + +} diff --git a/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntegerTypeValue.java b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntegerTypeValue.java new file mode 100644 index 0000000000..463b06f768 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/main/java/com/baeldung/collections/mulipletypesinmap/IntegerTypeValue.java @@ -0,0 +1,17 @@ +package com.baeldung.collections.mulipletypesinmap; + +public class IntegerTypeValue implements DynamicTypeValue { + private Integer value; + + public IntegerTypeValue(Integer value) { + this.value = value; + } + + @Override + public String valueDescription() { + if(value == null){ + return "The value is null."; + } + return String.format("The value is a %s integer: %d", value > 0 ? "positive" : "negative", value); + } +} diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/multipletypesinmap/MultipleTypesInMapUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/multipletypesinmap/MultipleTypesInMapUnitTest.java new file mode 100644 index 0000000000..87ea310ab0 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/multipletypesinmap/MultipleTypesInMapUnitTest.java @@ -0,0 +1,75 @@ +package com.baeldung.multipletypesinmap; + +import com.baeldung.collections.mulipletypesinmap.DynamicTypeValue; +import com.baeldung.collections.mulipletypesinmap.InstantTypeValue; +import com.baeldung.collections.mulipletypesinmap.IntArrayTypeValue; +import com.baeldung.collections.mulipletypesinmap.IntegerTypeValue; +import org.junit.jupiter.api.Test; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +class MultipleTypesInMapUnitTest { + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + .withZone(ZoneId.systemDefault()); + + private static final Integer intValue = 777; + private static final int[] intArray = new int[]{2, 3, 5, 7, 11, 13}; + private static final Instant instant = Instant.now(); + + private static final String KEY_INT = "E1 (Integer)"; + private static final String KEY_INT_ARRAY = "E2 (IntArray)"; + private static final String KEY_INSTANT = "E3 (Instant)"; + + @Test + void givenThreeTypes_whenUsingRawMap_thenPrintDescription() { + Map rawMap = new HashMap<>(); + rawMap.put(KEY_INT, intValue); + rawMap.put(KEY_INT_ARRAY, intArray); + rawMap.put(KEY_INSTANT, instant); + + rawMap.forEach((k, v) -> { + if (v instanceof Integer) { + Integer theV = (Integer) v; + String desc = String.format("The value is a %s integer: %d", theV > 0 ? "positive" : "negative", theV); + System.out.println(k + " -> " + desc); + assertThat(k).isEqualTo(KEY_INT); + assertThat(desc).isEqualTo("The value is a positive integer: 777"); + } else if (v instanceof int[]) { + int[] theV = (int[]) v; + String desc = String.format("The value is an array of %d integers: %s", theV.length, Arrays.toString(theV)); + System.out.println(k + " -> " + desc); + assertThat(k).isEqualTo(KEY_INT_ARRAY); + assertThat(desc).isEqualTo("The value is an array of 6 integers: [2, 3, 5, 7, 11, 13]"); + } else if (v instanceof Instant) { + Instant theV = (Instant) v; + String desc = String.format("The value is an instant: %s", FORMATTER.format(theV)); + System.out.println(k + " -> " + desc); + assertThat(k).isEqualTo(KEY_INSTANT); + assertThat(desc).matches("^The value is an instant: \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}"); + } else { + throw new IllegalStateException("Unknown Type found."); + } + }); + } + + @Test + void givenThreeTypes_whenUsingAnInterface_thenPrintDescription() { + Map theMap = new HashMap<>(); + theMap.put(KEY_INT, new IntegerTypeValue(intValue)); + theMap.put(KEY_INT_ARRAY, new IntArrayTypeValue(intArray)); + theMap.put(KEY_INSTANT, new InstantTypeValue(instant)); + + theMap.forEach((k, v) -> System.out.println(k + " -> " + v.valueDescription())); + + assertThat(theMap.get(KEY_INT).valueDescription()).isEqualTo("The value is a positive integer: 777"); + assertThat(theMap.get(KEY_INT_ARRAY).valueDescription()).isEqualTo("The value is an array of 6 integers: [2, 3, 5, 7, 11, 13]"); + assertThat(theMap.get(KEY_INSTANT).valueDescription()).matches("^The value is an instant: \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}"); + } +} From 879e60f8c0b8e89ce260815c36d03c613ed759ea Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:16:25 +0800 Subject: [PATCH 302/551] Create README.md --- quarkus-jandex/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 quarkus-jandex/README.md diff --git a/quarkus-jandex/README.md b/quarkus-jandex/README.md new file mode 100644 index 0000000000..cca5fa7714 --- /dev/null +++ b/quarkus-jandex/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Quarkus Bean Discovery With Jandex Indexing](https://www.baeldung.com/quarkus-bean-discovery-index) From eb4276fe3bc31563c789feacff291100a76cf9d3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:18:13 +0800 Subject: [PATCH 303/551] Update README.md --- jackson-modules/jackson-conversions-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson-modules/jackson-conversions-2/README.md b/jackson-modules/jackson-conversions-2/README.md index bddbb60bd7..fa3568652a 100644 --- a/jackson-modules/jackson-conversions-2/README.md +++ b/jackson-modules/jackson-conversions-2/README.md @@ -11,4 +11,5 @@ This module contains articles about Jackson conversions. - [Jackson Streaming API](https://www.baeldung.com/jackson-streaming-api) - [Jackson: java.util.LinkedHashMap cannot be cast to X](https://www.baeldung.com/jackson-linkedhashmap-cannot-be-cast) - [Deserialize Snake Case to Camel Case With Jackson](https://www.baeldung.com/jackson-deserialize-snake-to-camel-case) +- [Serialize and Deserialize Booleans as Integers With Jackson](https://www.baeldung.com/jackson-booleans-as-integers) - More articles: [[<-- prev]](../jackson-conversions) From a30954150377edc3931e37a3820131ef3e3ec866 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:23:15 +0800 Subject: [PATCH 304/551] Update README.md --- spring-websockets/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-websockets/README.md b/spring-websockets/README.md index 7d69c21b78..88a97850b5 100644 --- a/spring-websockets/README.md +++ b/spring-websockets/README.md @@ -7,3 +7,4 @@ This module contains articles about Spring WebSockets. - [A Quick Example of Spring Websockets’ @SendToUser Annotation](https://www.baeldung.com/spring-websockets-sendtouser) - [Scheduled WebSocket Push with Spring Boot](https://www.baeldung.com/spring-boot-scheduled-websocket) - [Test WebSocket APIs With Postman](https://www.baeldung.com/postman-websocket-apis) +- [Debugging WebSockets](https://www.baeldung.com/debug-websockets) From f579ec9ed5acd8aa3bd62c4ac814a87bc622810e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:25:31 +0800 Subject: [PATCH 305/551] Update README.md --- spring-boot-rest-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-rest-2/README.md b/spring-boot-rest-2/README.md index 41270d58ea..985aa97a86 100644 --- a/spring-boot-rest-2/README.md +++ b/spring-boot-rest-2/README.md @@ -2,3 +2,4 @@ - [Get All Endpoints in Spring Boot](https://www.baeldung.com/spring-boot-get-all-endpoints) - [HTTP PUT vs. POST in REST API](https://www.baeldung.com/rest-http-put-vs-post) +- [415 Unsupported MediaType in Spring Application](https://www.baeldung.com/spring-415-unsupported-mediatype) From d6460d88b8774ec3eda1dd5d0ab648c1e68bae46 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:31:04 +0800 Subject: [PATCH 306/551] Update README.md --- core-java-modules/core-java-networking-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-networking-3/README.md b/core-java-modules/core-java-networking-3/README.md index 0dc9ad9f70..82e75820ba 100644 --- a/core-java-modules/core-java-networking-3/README.md +++ b/core-java-modules/core-java-networking-3/README.md @@ -9,4 +9,5 @@ This module contains articles about networking in Java - [Connection Timeout vs. Read Timeout for Java Sockets](https://www.baeldung.com/java-socket-connection-read-timeout) - [Find Whether an IP Address Is in the Specified Range or Not in Java](https://www.baeldung.com/java-check-ip-address-range) - [Find the IP Address of a Client Connected to a Server](https://www.baeldung.com/java-client-get-ip-address) +- [Unix Domain Socket in Java 16](https://www.baeldung.com/java-unix-domain-socket) - [[<-- Prev]](/core-java-modules/core-java-networking-2) From 689396a360df0dbb8962fae13cdf471de0c947fb Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:33:28 +0800 Subject: [PATCH 307/551] Update README.md --- core-java-modules/core-java-string-operations-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations-4/README.md b/core-java-modules/core-java-string-operations-4/README.md index be4c9ae05f..83bfeb4d05 100644 --- a/core-java-modules/core-java-string-operations-4/README.md +++ b/core-java-modules/core-java-string-operations-4/README.md @@ -2,4 +2,5 @@ - [Ignoring Commas in Quotes When Splitting a Comma-separated String](https://www.baeldung.com/java-split-string-commas) - [Compare Strings While Ignoring Whitespace in Java](https://www.baeldung.com/java-compare-string-whitespace) +- [Concatenating Null Strings in Java](https://www.baeldung.com/java-concat-null-string) From 5f78536a3a96b65564ad7aa1b8b0add55cabaf00 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 1 Dec 2021 11:39:46 +0200 Subject: [PATCH 308/551] JAVA-8748 temporarily disable test --- .../{FindFreePortUnitTest.java => FindFreePortManualTest.java} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/{FindFreePortUnitTest.java => FindFreePortManualTest.java} (98%) diff --git a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortManualTest.java similarity index 98% rename from core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java rename to core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortManualTest.java index 95530ef292..3e533b3fc0 100644 --- a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java +++ b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortManualTest.java @@ -14,7 +14,8 @@ import java.net.ServerSocket; import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat; -public class FindFreePortUnitTest { +// fixing in JAVA-8748 +public class FindFreePortManualTest { private static int FREE_PORT_NUMBER; private static int[] FREE_PORT_RANGE; From f913e0c006bafe2f9a69efb6cd3544d9898133fb Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 1 Dec 2021 10:48:53 +0100 Subject: [PATCH 309/551] JAVA-8358: Move Spring Boot Exit Codes code --- spring-boot-modules/spring-boot-basic-customization-2/README.md | 1 + .../baeldung/exitcode/event/ExitCodeEventDemoApplication.java | 0 .../exception/ExitCodeExceptionMapperDemoApplication.java | 0 .../exceptionexitgen/ExceptionExitCodeGeneratorApplication.java | 0 .../exitcode/exceptionexitgen/FailedToStartException.java | 0 .../exitcode/generator/ExitCodeGeneratorDemoApplication.java | 0 spring-boot-modules/spring-boot-basic-customization/README.md | 1 - 7 files changed, 1 insertion(+), 1 deletion(-) rename spring-boot-modules/{spring-boot-basic-customization => spring-boot-basic-customization-2}/src/main/java/com/baeldung/exitcode/event/ExitCodeEventDemoApplication.java (100%) rename spring-boot-modules/{spring-boot-basic-customization => spring-boot-basic-customization-2}/src/main/java/com/baeldung/exitcode/exception/ExitCodeExceptionMapperDemoApplication.java (100%) rename spring-boot-modules/{spring-boot-basic-customization => spring-boot-basic-customization-2}/src/main/java/com/baeldung/exitcode/exceptionexitgen/ExceptionExitCodeGeneratorApplication.java (100%) rename spring-boot-modules/{spring-boot-basic-customization => spring-boot-basic-customization-2}/src/main/java/com/baeldung/exitcode/exceptionexitgen/FailedToStartException.java (100%) rename spring-boot-modules/{spring-boot-basic-customization => spring-boot-basic-customization-2}/src/main/java/com/baeldung/exitcode/generator/ExitCodeGeneratorDemoApplication.java (100%) diff --git a/spring-boot-modules/spring-boot-basic-customization-2/README.md b/spring-boot-modules/spring-boot-basic-customization-2/README.md index 0e688bda2a..9488618ca5 100644 --- a/spring-boot-modules/spring-boot-basic-customization-2/README.md +++ b/spring-boot-modules/spring-boot-basic-customization-2/README.md @@ -7,3 +7,4 @@ This module contains articles about Spring Boot customization 2 - [DispatcherServlet and web.xml in Spring Boot](https://www.baeldung.com/spring-boot-dispatcherservlet-web-xml) - [XML Defined Beans in Spring Boot](https://www.baeldung.com/spring-boot-xml-beans) - [What Is OncePerRequestFilter?](https://www.baeldung.com/spring-onceperrequestfilter) + - [Spring Boot Exit Codes](https://www.baeldung.com/spring-boot-exit-codes) diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/event/ExitCodeEventDemoApplication.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/event/ExitCodeEventDemoApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/event/ExitCodeEventDemoApplication.java rename to spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/event/ExitCodeEventDemoApplication.java diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/exception/ExitCodeExceptionMapperDemoApplication.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/exception/ExitCodeExceptionMapperDemoApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/exception/ExitCodeExceptionMapperDemoApplication.java rename to spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/exception/ExitCodeExceptionMapperDemoApplication.java diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/exceptionexitgen/ExceptionExitCodeGeneratorApplication.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/exceptionexitgen/ExceptionExitCodeGeneratorApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/exceptionexitgen/ExceptionExitCodeGeneratorApplication.java rename to spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/exceptionexitgen/ExceptionExitCodeGeneratorApplication.java diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/exceptionexitgen/FailedToStartException.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/exceptionexitgen/FailedToStartException.java similarity index 100% rename from spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/exceptionexitgen/FailedToStartException.java rename to spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/exceptionexitgen/FailedToStartException.java diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/generator/ExitCodeGeneratorDemoApplication.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/generator/ExitCodeGeneratorDemoApplication.java similarity index 100% rename from spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/exitcode/generator/ExitCodeGeneratorDemoApplication.java rename to spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/exitcode/generator/ExitCodeGeneratorDemoApplication.java diff --git a/spring-boot-modules/spring-boot-basic-customization/README.md b/spring-boot-modules/spring-boot-basic-customization/README.md index 6c067fc5a1..a3d9f1b1fc 100644 --- a/spring-boot-modules/spring-boot-basic-customization/README.md +++ b/spring-boot-modules/spring-boot-basic-customization/README.md @@ -11,4 +11,3 @@ This module contains articles about Spring Boot customization - [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class) - [How to Define a Spring Boot Filter?](https://www.baeldung.com/spring-boot-add-filter) - [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon) - - [Spring Boot Exit Codes](https://www.baeldung.com/spring-boot-exit-codes) From cb9bfcbce8cb3e6e1d50820b8e0f261d4e889478 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Wed, 1 Dec 2021 20:39:43 +0530 Subject: [PATCH 310/551] JAVA-8649-1: updating spring-cloud release train version in spring-cloud-vault and removing bootstrap.yml --- spring-cloud/spring-cloud-vault/pom.xml | 2 +- .../src/main/resources/application.yml | 45 ++++++++++++++----- .../src/main/resources/bootstrap.yml | 37 --------------- 3 files changed, 35 insertions(+), 49 deletions(-) delete mode 100644 spring-cloud/spring-cloud-vault/src/main/resources/bootstrap.yml diff --git a/spring-cloud/spring-cloud-vault/pom.xml b/spring-cloud/spring-cloud-vault/pom.xml index 131d58c967..3f72ac9fe2 100644 --- a/spring-cloud/spring-cloud-vault/pom.xml +++ b/spring-cloud/spring-cloud-vault/pom.xml @@ -78,7 +78,7 @@ - Greenwich.RELEASE + 2020.0.3 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-vault/src/main/resources/application.yml b/spring-cloud/spring-cloud-vault/src/main/resources/application.yml index 1c75ac21e6..cb0b2d60fd 100644 --- a/spring-cloud/spring-cloud-vault/src/main/resources/application.yml +++ b/spring-cloud/spring-cloud-vault/src/main/resources/application.yml @@ -1,11 +1,34 @@ -spring: - application: - name: fakebank - - datasource: - url: jdbc:mysql://localhost:3306/fakebank?serverTimezone=GMT-3 - hikari: connection-test-query: select 1 - idle-timeout: 5000 - max-lifetime: 120000 - maximum-pool-size: 5 - minimum-idle: 5 +spring: + application: + name: fakebank + datasource: + url: jdbc:mysql://localhost:3306/fakebank?serverTimezone=GMT-3 + hikari: + connection-test-query: select 1 + idle-timeout: 5000 + max-lifetime: 120000 + maximum-pool-size: 5 + minimum-idle: 5 + cloud: + vault: + uri: https://localhost:8200 + connection-timeout: 5000 + read-timeout: 15000 + ssl: + trust-store: classpath:/vault.jks + trust-store-password: changeit + generic: + enabled: true + application-name: fakebank + # kv: + # enabled: false + # backend: kv + # application-name: fakebank + database: + enabled: true + role: fakebank-accounts-ro + backend: database + username-property: spring.datasource.username + password-property: spring.datasource.password + config: + import: vault:// \ No newline at end of file diff --git a/spring-cloud/spring-cloud-vault/src/main/resources/bootstrap.yml b/spring-cloud/spring-cloud-vault/src/main/resources/bootstrap.yml deleted file mode 100644 index 7d38b06c0f..0000000000 --- a/spring-cloud/spring-cloud-vault/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,37 +0,0 @@ -spring: - cloud: - vault: - uri: https://localhost:8200 - connection-timeout: 5000 - read-timeout: 15000 - - ssl: - trust-store: classpath:/vault.jks - trust-store-password: changeit - - generic: - enabled: true - application-name: fakebank - -# kv: -# enabled: false -# backend: kv -# application-name: fakebank -# - database: - enabled: true - role: fakebank-accounts-rw - backend: database - username-property: spring.datasource.username - password-property: spring.datasource.password -# -# - - - - - - - - - \ No newline at end of file From 36866c09f79be1e1bc8bb2bf2782b7eab5c9ab7c Mon Sep 17 00:00:00 2001 From: Olsi Seferi <72546616+olsiseferi@users.noreply.github.com> Date: Wed, 1 Dec 2021 19:19:19 +0100 Subject: [PATCH 311/551] ExcelUtility Jira issue BAEL-5198 (#11503) * CODE REFACTOR AND ADDED UNIT TEST * SMALL CHANGE * FIXED TESTS TIMEZONE ISSUES Co-authored-by: Olsi Seferi --- .../com/baeldung/poi/excel/ExcelUtility.java | 66 ++++++++++++++++++ .../poi/excel/ExcelUtilityUnitTest.java | 54 ++++++++++++++ apache-poi/src/test/resources/baeldung.xlsx | Bin 0 -> 16777 bytes 3 files changed, 120 insertions(+) create mode 100644 apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java create mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java create mode 100644 apache-poi/src/test/resources/baeldung.xlsx diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java new file mode 100644 index 0000000000..e4a5b791c9 --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java @@ -0,0 +1,66 @@ +package com.baeldung.poi.excel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class ExcelUtility { + private static final String ENDLINE = System.getProperty("line.separator"); + + public static String readExcel(String filePath) throws IOException { + File file = new File(filePath); + FileInputStream inputStream = null; + StringBuilder toReturn = new StringBuilder(); + try { + inputStream = new FileInputStream(file); + Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream); + for (Sheet sheet : baeuldungWorkBook) { + toReturn.append("--------------------------------------------------------------------").append(ENDLINE); + toReturn.append("Worksheet :").append(sheet.getSheetName()).append(ENDLINE); + toReturn.append("--------------------------------------------------------------------").append(ENDLINE); + int firstRow = sheet.getFirstRowNum(); + int lastRow = sheet.getLastRowNum(); + for (int index = firstRow + 1; index <= lastRow; index++) { + Row row = sheet.getRow(index); + toReturn.append("|| "); + for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) { + Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); + printCellValue(cell, toReturn); + } + toReturn.append(" ||").append(ENDLINE); + } + } + inputStream.close(); + + } catch (IOException e) { + throw e; + } + return toReturn.toString(); + } + + public static void printCellValue(Cell cell, StringBuilder toReturn) { + CellType cellType = cell.getCellType().equals(CellType.FORMULA) ? cell.getCachedFormulaResultType() + : cell.getCellType(); + if (cellType.equals(CellType.STRING)) { + toReturn.append(cell.getStringCellValue()).append(" | "); + } + if (cellType.equals(CellType.NUMERIC)) { + if (DateUtil.isCellDateFormatted(cell)) { + toReturn.append(cell.getDateCellValue()).append(" | "); + } else { + toReturn.append(cell.getNumericCellValue()).append(" | "); + } + } + if (cellType.equals(CellType.BOOLEAN)) { + toReturn.append(cell.getBooleanCellValue()).append(" | "); + } + } +} \ No newline at end of file diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java new file mode 100644 index 0000000000..6638d77066 --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java @@ -0,0 +1,54 @@ +package com.baeldung.poi.excel; + +import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +import org.junit.Before; +import org.junit.Test; + +public class ExcelUtilityUnitTest { + private static final String FILE_NAME = "baeldung.xlsx"; + private String fileLocation; + private static final String ENDLINE = System.getProperty("line.separator"); + private StringBuilder output; + + @Before + public void setupUnitTest() throws IOException, URISyntaxException, ParseException { + output = new StringBuilder(); + output.append("--------------------------------------------------------------------").append(ENDLINE); + output.append("Worksheet :Sheet1").append(ENDLINE); + output.append("--------------------------------------------------------------------").append(ENDLINE); + output.append("|| Name1 | Surname1 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | ‡ | ||") + .append(ENDLINE); + output.append("|| Name2 | Surname2 | 5.646513512E9 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021").toString()).append(" | false | ||") + .append(ENDLINE); + output.append("|| Name3 | Surname3 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | 7.17039641738E11 | ||") + .append(ENDLINE); + output.append("--------------------------------------------------------------------").append(ENDLINE); + output.append("Worksheet :Sheet2").append(ENDLINE); + output.append("--------------------------------------------------------------------").append(ENDLINE); + output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 | ||").append(ENDLINE); + + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + } + + @Test + public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException { + assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation)); + + } + + @Test + public void givenStringPath_whenReadExcel_thenThrowException() { + assertThrows(IOException.class, () -> { + ExcelUtility.readExcel("baeldung"); + }); + } + +} diff --git a/apache-poi/src/test/resources/baeldung.xlsx b/apache-poi/src/test/resources/baeldung.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..a6ed6c4e6ac8b0d3bd39dd4bb114bf5e0ab56479 GIT binary patch literal 16777 zcmeHuWmFvLwl)N};O_1cB)CI@1q~2f8`nmIySoO5Ai>?;-90!24ek!NCv(opOlI!4 z?)USqJJqYJyH~yYSyj9Dez(g@LqKAHL4(19fq{{NW$-R%hJk~D1w(^@p@YG`&=9q@ zvIkh%>%9MH1F+L#a<;S}`3(7jCKK!hX#GFO|6vYvD-Xzav7oe&pCU(><=d`%p_nZ| z453ER5U(vv^%fdvq|;V=j&*DK$(v%bh+V)UWRClOuG#-S$Xnxsy zr$#BzJJ!OhKtgLBhd@ME@d6`zeXB>eIm8P})wNjc9ma94n3iaEIU*`wq>QK;#;I}g zK>mg1h|tQ#eVrnV+*-j~#sHj`M0$l-5g}hFpS9_eJ}`#_UN$EbqS3uEt|7ys6KuH^ zpG24{n9=poW=GW0m&rt&1)HvCr5Xy`BMh3yfp17;^X{_B!B?eJHPZXA7^G_Ph#cU! zX|0;lsHz=dh=gHHHxX(!-=xWNi#h3r*4fO5I9bEdAP&ebUi~i6o3_Hz{(B_9lt;*ZOe4YtQ>8qBWLKG^GSuM%AiC2!3SX!u%8e zCaVrbmo-TKo}VGW2rr*y0DDVGajs3%;7stGl zhIoY%aP0F;I^4p$NJlnl!7RS}&hQcZRnns_XHry7H{k~oo!(>?h5JR9Y~gfUS@V|yA;lY?{g^19 zy>J}fs`U8qH)xu2eTWC*s9#7S7gB1*ZxIHp;>nM&_l!!w^4dXs7Px7?ZGO%9uFQ1E z#d;u@oIWZ~Y&1&kChDum_j8WVDp|P{9pxT_dqIQuWCjpK)as8JyT|4eii&S2{gWZm zwr>x(psJg5#O=^Mmy+JN?XWbnB7gZ{#XRu&`c(zL!KmsOC)(&r<=x+^%n&C(PdEe^ zm?OvxB7;^qTQECW1I_iVt<8V4dBw^K*4bPr9)f#M5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B%Q;v=7tIdS=cC~>(*5x_dJPjSuAX_=0nb(IvK0YCQ!FboFy{poG7J6?)*UF5;@_YH+@AKZQ zOq3M%Mc+*91Mi)Tmc;MgJ{(M^nHmOoUAMW z)pb`8zx`w*vKzAgqXGa^dOTB)}gxBC2tY+u^zLkvdl}{tQZn6mdyjQH1~CE4oEN zB1-bj<|4zi1>GgvC*M}BLn9N}cL=UgRhiIA3T^WzOBPP&jc)2YRYC!=O5->mR*%>! z6>10a>Pv-ndm#d(2So@Jw{5Y&ARYKagG~y90|)1^?sdDqy^34tLcLH%2lANABTc zx%>ne!2bd8v+3nm(qG#Iev)<*{Z9I8)4;C?zgE+KBCHbs%7eeHt^W%6YjOG~;5y0w z1Mp|5`d7eT)15y7H%Wg0{!-}u+rsbv9CVHDe**d=qxvi8uffUBJ6&S?0s5y< Date: Wed, 1 Dec 2021 21:28:24 +0100 Subject: [PATCH 312/551] removed Hamcrest --- .../isuppercase/StringFirstCharacterUppercaseUnitTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java index 6803285ca2..ede31a3649 100644 --- a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/isuppercase/StringFirstCharacterUppercaseUnitTest.java @@ -5,9 +5,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import com.google.common.base.Ascii; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.matchesPattern; - @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class StringFirstCharacterUppercaseUnitTest { @@ -21,7 +18,7 @@ public class StringFirstCharacterUppercaseUnitTest { public void givenString_whenCheckingWithRegex_thenStringCapitalized() { String example = "Katie"; String regEx = "[A-Z]\\w*"; - assertThat(example, matchesPattern(regEx)); + Assertions.assertTrue(example.matches(regEx)); } @Test From 1ff29cf596df437780d59ec42f454e556758d402 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Wed, 1 Dec 2021 22:40:29 +0000 Subject: [PATCH 313/551] [JAVA-8703] Fix Live test to allow isolated execution --- testing-modules/spring-testing-2/pom.xml | 2 +- .../dynamicproperties/ArticleTestFixtureLiveTest.java | 11 +++++++++-- .../dynamicproperties/PostgreSQLExtension.java | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/testing-modules/spring-testing-2/pom.xml b/testing-modules/spring-testing-2/pom.xml index 82a9ed9599..6bdec33d96 100644 --- a/testing-modules/spring-testing-2/pom.xml +++ b/testing-modules/spring-testing-2/pom.xml @@ -63,7 +63,7 @@ - 1.12.2 + 1.16.2 \ No newline at end of file diff --git a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java index bb3ad28365..2975104c14 100644 --- a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java @@ -4,13 +4,17 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; +import java.util.List; + import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @ActiveProfiles("pg") @ExtendWith(PostgreSQLExtension.class) +@DirtiesContext public class ArticleTestFixtureLiveTest { @Autowired @@ -23,8 +27,11 @@ public class ArticleTestFixtureLiveTest { article.setContent("Today's applications..."); articleRepository.save(article); - Article persisted = articleRepository.findAll().get(0); - assertThat(persisted.getId()).isNotNull(); + + List
allArticles = articleRepository.findAll(); + assertThat(allArticles).hasSize(1); + + Article persisted = allArticles.get(0); assertThat(persisted.getTitle()).isEqualTo("A Guide to @DynamicPropertySource in Spring"); assertThat(persisted.getContent()).isEqualTo("Today's applications..."); } diff --git a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java index 8c08ad67d7..28aab34867 100644 --- a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java @@ -18,14 +18,14 @@ public class PostgreSQLExtension implements BeforeAllCallback, AfterAllCallback .withExposedPorts(5432); postgres.start(); - String jdbcUrl = String.format("jdbc:postgresql://localhost:%d/prop", postgres.getFirstMappedPort()); - System.setProperty("spring.datasource.url", jdbcUrl); - System.setProperty("spring.datasource.username", "postgres"); - System.setProperty("spring.datasource.password", "pass"); + + System.setProperty("spring.datasource.url", postgres.getJdbcUrl()); + System.setProperty("spring.datasource.username", postgres.getUsername()); + System.setProperty("spring.datasource.password", postgres.getPassword()); } @Override public void afterAll(ExtensionContext context) { - postgres.stop(); + // do nothing, Testcontainers handles container shutdown } } From 9d0dd5e34f41e74b6d365f6ca9ce6a13db559a8c Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 2 Dec 2021 09:33:35 +0100 Subject: [PATCH 314/551] JAVA-8748: Make each test get available port on its own --- ...ualTest.java => FindFreePortUnitTest.java} | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) rename core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/{FindFreePortManualTest.java => FindFreePortUnitTest.java} (78%) diff --git a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortManualTest.java b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java similarity index 78% rename from core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortManualTest.java rename to core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java index 3e533b3fc0..679503cb6d 100644 --- a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortManualTest.java +++ b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java @@ -4,37 +4,27 @@ import org.apache.catalina.LifecycleException; import org.apache.catalina.startup.Tomcat; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.util.SocketUtils; import java.io.IOException; import java.net.ServerSocket; +import java.util.Random; -import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; -// fixing in JAVA-8748 -public class FindFreePortManualTest { +public class FindFreePortUnitTest { - private static int FREE_PORT_NUMBER; - private static int[] FREE_PORT_RANGE; - - @BeforeAll - public static void getExplicitFreePortNumberAndRange() { - try (ServerSocket serverSocket = new ServerSocket(0)) { - FREE_PORT_NUMBER = serverSocket.getLocalPort(); - FREE_PORT_RANGE = new int[] {FREE_PORT_NUMBER, FREE_PORT_NUMBER + 1, FREE_PORT_NUMBER + 2}; - } catch (IOException e) { - fail("No free port is available"); - } - } + private static final int DEFAULT_RANDOM_PORT = 34307; @Test public void givenExplicitFreePort_whenCreatingServerSocket_thenThatPortIsAssigned() { - try (ServerSocket serverSocket = new ServerSocket(FREE_PORT_NUMBER)) { + int freePort = getFreePort(); + + try (ServerSocket serverSocket = new ServerSocket(freePort)) { assertThat(serverSocket).isNotNull(); - assertThat(serverSocket.getLocalPort()).isEqualTo(FREE_PORT_NUMBER); + assertThat(serverSocket.getLocalPort()).isEqualTo(freePort); } catch (IOException e) { fail("Port is not available"); } @@ -42,8 +32,10 @@ public class FindFreePortManualTest { @Test public void givenExplicitOccupiedPort_whenCreatingServerSocket_thenExceptionIsThrown() { - try (ServerSocket serverSocket = new ServerSocket(FREE_PORT_NUMBER)) { - new ServerSocket(FREE_PORT_NUMBER); + int freePort = getFreePort(); + + try (ServerSocket serverSocket = new ServerSocket(freePort)) { + new ServerSocket(freePort); fail("Same port cannot be used twice"); } catch (IOException e) { assertThat(e).hasMessageContaining("Address already in use"); @@ -52,7 +44,7 @@ public class FindFreePortManualTest { @Test public void givenExplicitPortRange_whenCreatingServerSocket_thenOnePortIsAssigned() { - for (int port : FREE_PORT_RANGE) { + for (int port : getFreePorts()) { try (ServerSocket serverSocket = new ServerSocket(port)) { assertThat(serverSocket).isNotNull(); assertThat(serverSocket.getLocalPort()).isEqualTo(port); @@ -105,11 +97,12 @@ public class FindFreePortManualTest { public void givenExplicitFreePort_whenCreatingJettyServer_thenThatPortIsAssigned() throws Exception { Server jettyServer = new Server(); ServerConnector serverConnector = new ServerConnector(jettyServer); - serverConnector.setPort(FREE_PORT_NUMBER); + int freePort = getFreePort(); + serverConnector.setPort(freePort); jettyServer.addConnector(serverConnector); try { jettyServer.start(); - assertThat(serverConnector.getLocalPort()).isEqualTo(FREE_PORT_NUMBER); + assertThat(serverConnector.getLocalPort()).isEqualTo(freePort); } catch (Exception e) { fail("Failed to start Jetty server"); } finally { @@ -136,10 +129,11 @@ public class FindFreePortManualTest { @Test public void givenExplicitFreePort_whenCreatingTomcatServer_thenThatPortIsAssigned() throws Exception { Tomcat tomcatServer = new Tomcat(); - tomcatServer.setPort(FREE_PORT_NUMBER); + int freePort = getFreePort(); + tomcatServer.setPort(freePort); try { tomcatServer.start(); - assertThat(tomcatServer.getConnector().getLocalPort()).isEqualTo(FREE_PORT_NUMBER); + assertThat(tomcatServer.getConnector().getLocalPort()).isEqualTo(freePort); } catch (LifecycleException e) { fail("Failed to start Tomcat server"); } finally { @@ -148,4 +142,25 @@ public class FindFreePortManualTest { } } + private int[] getFreePorts() { + int freePort = getFreePort(); + return new int[]{freePort - 1, freePort, freePort + 1}; + } + + private int getFreePort() { + return new Random() + .ints(36000, 65000) + .filter(FindFreePortUnitTest::isFree) + .findFirst() + .orElse(DEFAULT_RANDOM_PORT); + } + + private static boolean isFree(int port) { + try { + new ServerSocket(port).close(); + return true; + } catch (IOException e) { + return false; + } + } } From 4f178a1af5b0ff4fd4bd655842b3138231f3df99 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 2 Dec 2021 11:20:46 +0200 Subject: [PATCH 315/551] remove duplicate dependency --- core-java-modules/core-java-string-algorithms-3/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 180d75cc61..ccb9457a11 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -24,11 +24,6 @@ commons-validator ${validator.version} - - com.google.guava - guava - ${guava.version} - From 205ad52ea26029318fba1fe0bcb9190149667396 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 2 Dec 2021 12:27:52 +0100 Subject: [PATCH 316/551] JAVA-8764: Fix test/main directories structure --- .../springbootxml/SpringBootXmlApplicationIntegrationTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spring-boot-modules/spring-boot-basic-customization-2/src/{main/test => test/java}/com/baeldung/springbootxml/SpringBootXmlApplicationIntegrationTest.java (100%) diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/test/com/baeldung/springbootxml/SpringBootXmlApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-basic-customization-2/src/test/java/com/baeldung/springbootxml/SpringBootXmlApplicationIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-basic-customization-2/src/main/test/com/baeldung/springbootxml/SpringBootXmlApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-basic-customization-2/src/test/java/com/baeldung/springbootxml/SpringBootXmlApplicationIntegrationTest.java From 85faed7f391bf38baf3ca438b6f764eff7fdf1f5 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 2 Dec 2021 12:58:13 +0100 Subject: [PATCH 317/551] JAVA-8748: Use ServerSocket(0) approach to get free port --- .../baeldung/socket/FindFreePortUnitTest.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java index 679503cb6d..4dfc114438 100644 --- a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java +++ b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java @@ -9,7 +9,6 @@ import org.springframework.util.SocketUtils; import java.io.IOException; import java.net.ServerSocket; -import java.util.Random; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -148,19 +147,10 @@ public class FindFreePortUnitTest { } private int getFreePort() { - return new Random() - .ints(36000, 65000) - .filter(FindFreePortUnitTest::isFree) - .findFirst() - .orElse(DEFAULT_RANDOM_PORT); - } - - private static boolean isFree(int port) { - try { - new ServerSocket(port).close(); - return true; - } catch (IOException e) { - return false; + try(ServerSocket serverSocket = new ServerSocket(0)){ + return serverSocket.getLocalPort(); + } catch (IOException ex){ + return DEFAULT_RANDOM_PORT; } } } From 615f3ba2bc8fd93ef8d4fee954a2c4b1061b78a2 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Thu, 2 Dec 2021 14:43:55 +0100 Subject: [PATCH 318/551] Feature/bael 5133 utility class constructor (#11421) * BAEL-5133: initial commit * BAEL-5133: better example * BAEL-5133: add Lombok examples * BAEL-5133: add interface and enum examples * BAEL-5133: add exception * BAEL-5133: add suppress warning * BAEL-5133: dummy Co-authored-by: ashleyfrieze --- .../core-java-lang-oop-methods/pom.xml | 5 +++- .../com/baeldung/utilities/StringUtils.java | 17 +++++++++++ .../alternatives/StringUtilsEnum.java | 13 +++++++++ .../alternatives/StringUtilsInterface.java | 13 +++++++++ .../StringUtilsWithNoArgsConstructor.java | 17 +++++++++++ .../lombok/StringUtilsWithUtilityClass.java | 16 ++++++++++ .../warning/StringUtilsSuppressWarning.java | 14 +++++++++ .../utilities/StringUtilsUnitTest.java | 28 ++++++++++++++++++ .../alternatives/StringUtilsEnumUnitTest.java | 29 +++++++++++++++++++ .../StringUtilsInterfaceUnitTest.java | 29 +++++++++++++++++++ ...ingUtilsWithNoArgsConstructorUnitTest.java | 29 +++++++++++++++++++ .../StringUtilsWithUtilityClassUnitTest.java | 29 +++++++++++++++++++ ...ilsStringUtilsSuppressWarningUnitTest.java | 29 +++++++++++++++++++ 13 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/StringUtils.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsEnum.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsInterface.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructor.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClass.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/warning/StringUtilsSuppressWarning.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/StringUtilsUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsEnumUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsInterfaceUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructorUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClassUnitTest.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/warning/StringUtilsStringUtilsSuppressWarningUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml index e57b51b7bd..e41c56fc6f 100644 --- a/core-java-modules/core-java-lang-oop-methods/pom.xml +++ b/core-java-modules/core-java-lang-oop-methods/pom.xml @@ -2,6 +2,7 @@ + 4.0.0 core-java-lang-oop-methods core-java-lang-oop-methods @@ -33,7 +34,9 @@ - 1.18.12 + 1.18.22 + 2.6 + 3.10.0 3.0.3 diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/StringUtils.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/StringUtils.java new file mode 100644 index 0000000000..1e94281d21 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/StringUtils.java @@ -0,0 +1,17 @@ +package com.baeldung.utilities; + +public final class StringUtils { + + private StringUtils() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } + + public static boolean isEmpty(String source) { + return source == null || source.length() == 0; + } + + public static String wrap(String source, String wrapWith) { + return isEmpty(source) ? source : wrapWith + source + wrapWith; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsEnum.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsEnum.java new file mode 100644 index 0000000000..2fa96874c0 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsEnum.java @@ -0,0 +1,13 @@ +package com.baeldung.utilities.alternatives; + +public enum StringUtilsEnum {; + + public static boolean isEmpty(String source) { + return source == null || source.length() == 0; + } + + public static String wrap(String source, String wrapWith) { + return isEmpty(source) ? source : wrapWith + source + wrapWith; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsInterface.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsInterface.java new file mode 100644 index 0000000000..b6afdfff5d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/alternatives/StringUtilsInterface.java @@ -0,0 +1,13 @@ +package com.baeldung.utilities.alternatives; + +public interface StringUtilsInterface { + + static boolean isEmpty(String source) { + return source == null || source.length() == 0; + } + + static String wrap(String source, String wrapWith) { + return isEmpty(source) ? source : wrapWith + source + wrapWith; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructor.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructor.java new file mode 100644 index 0000000000..38e60e0216 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructor.java @@ -0,0 +1,17 @@ +package com.baeldung.utilities.lombok; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access= AccessLevel.PRIVATE) +public final class StringUtilsWithNoArgsConstructor { + + public static boolean isEmpty(String source) { + return source == null || source.length() == 0; + } + + public static String wrap(String source, String wrapWith) { + return isEmpty(source) ? source : wrapWith + source + wrapWith; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClass.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClass.java new file mode 100644 index 0000000000..56718f8ce4 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClass.java @@ -0,0 +1,16 @@ +package com.baeldung.utilities.lombok; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class StringUtilsWithUtilityClass { + + public static boolean isEmpty(String source) { + return source == null || source.length() == 0; + } + + public static String wrap(String source, String wrapWith) { + return isEmpty(source) ? source : wrapWith + source + wrapWith; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/warning/StringUtilsSuppressWarning.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/warning/StringUtilsSuppressWarning.java new file mode 100644 index 0000000000..d8354f993d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/utilities/warning/StringUtilsSuppressWarning.java @@ -0,0 +1,14 @@ +package com.baeldung.utilities.warning; + +@SuppressWarnings("java:S1118") +public final class StringUtilsSuppressWarning { + + public static boolean isEmpty(String source) { + return source == null || source.length() == 0; + } + + public static String wrap(String source, String wrapWith) { + return isEmpty(source) ? source : wrapWith + source + wrapWith; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/StringUtilsUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/StringUtilsUnitTest.java new file mode 100644 index 0000000000..ca8b270d8d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/StringUtilsUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.utilities; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; + +class StringUtilsUnitTest { + + @Test + void givenAnEmptyString_whenCallingIsEmpty_thenResultIsTrue() { + assertThat(StringUtils.isEmpty("")).isTrue(); + } + + @Test + void givenNonEmptyString_whenCallingIsEmpty_thenResultIsFalse() { + assertThat(StringUtils.isEmpty("asd")).isFalse(); + } + + @Test + void givenAnEmptyString_whenCallingWrap_thenResultIsAnEmptyString() { + assertThat(StringUtils.wrap("", "wrapper")).isEmpty(); + } + + @Test + void givenNonEmptyString_whenCallingWrap_thenResultIsWrappedString() { + assertThat(StringUtils.wrap("asd", "wrapper")).isEqualTo("wrapperasdwrapper"); + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsEnumUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsEnumUnitTest.java new file mode 100644 index 0000000000..4d948c44ae --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsEnumUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.utilities.alternatives; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class StringUtilsEnumUnitTest { + + @Test + void givenAnEmptyString_whenCallingIsEmpty_thenResultIsTrue() { + assertThat(StringUtilsEnum.isEmpty("")).isTrue(); + } + + @Test + void givenNonEmptyString_whenCallingIsEmpty_thenResultIsFalse() { + assertThat(StringUtilsEnum.isEmpty("asd")).isFalse(); + } + + @Test + void givenAnEmptyString_whenCallingWrap_thenResultIsAnEmptyString() { + assertThat(StringUtilsEnum.wrap("", "wrapper")).isEmpty(); + } + + @Test + void givenNonEmptyString_whenCallingWrap_thenResultIsWrappedString() { + assertThat(StringUtilsEnum.wrap("asd", "wrapper")).isEqualTo("wrapperasdwrapper"); + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsInterfaceUnitTest.java new file mode 100644 index 0000000000..600f6c2156 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/alternatives/StringUtilsInterfaceUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.utilities.alternatives; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class StringUtilsInterfaceUnitTest { + + @Test + void givenAnEmptyString_whenCallingIsEmpty_thenResultIsTrue() { + assertThat(StringUtilsInterface.isEmpty("")).isTrue(); + } + + @Test + void givenNonEmptyString_whenCallingIsEmpty_thenResultIsFalse() { + assertThat(StringUtilsInterface.isEmpty("asd")).isFalse(); + } + + @Test + void givenAnEmptyString_whenCallingWrap_thenResultIsAnEmptyString() { + assertThat(StringUtilsInterface.wrap("", "wrapper")).isEmpty(); + } + + @Test + void givenNonEmptyString_whenCallingWrap_thenResultIsWrappedString() { + assertThat(StringUtilsInterface.wrap("asd", "wrapper")).isEqualTo("wrapperasdwrapper"); + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructorUnitTest.java new file mode 100644 index 0000000000..b110c31080 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithNoArgsConstructorUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.utilities.lombok; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class StringUtilsWithNoArgsConstructorUnitTest { + + @Test + void givenAnEmptyString_whenCallingIsEmpty_thenResultIsTrue() { + assertThat(StringUtilsWithNoArgsConstructor.isEmpty("")).isTrue(); + } + + @Test + void givenNonEmptyString_whenCallingIsEmpty_thenResultIsFalse() { + assertThat(StringUtilsWithNoArgsConstructor.isEmpty("asd")).isFalse(); + } + + @Test + void givenAnEmptyString_whenCallingWrap_thenResultIsAnEmptyString() { + assertThat(StringUtilsWithNoArgsConstructor.wrap("", "wrapper")).isEmpty(); + } + + @Test + void givenNonEmptyString_whenCallingWrap_thenResultIsWrappedString() { + assertThat(StringUtilsWithNoArgsConstructor.wrap("asd", "wrapper")).isEqualTo("wrapperasdwrapper"); + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClassUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClassUnitTest.java new file mode 100644 index 0000000000..c2f5003ada --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/lombok/StringUtilsWithUtilityClassUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.utilities.lombok; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class StringUtilsWithUtilityClassUnitTest { + + @Test + void givenAnEmptyString_whenCallingIsEmpty_thenResultIsTrue() { + assertThat(StringUtilsWithUtilityClass.isEmpty("")).isTrue(); + } + + @Test + void givenNonEmptyString_whenCallingIsEmpty_thenResultIsFalse() { + assertThat(StringUtilsWithUtilityClass.isEmpty("asd")).isFalse(); + } + + @Test + void givenAnEmptyString_whenCallingWrap_thenResultIsAnEmptyString() { + assertThat(StringUtilsWithUtilityClass.wrap("", "wrapper")).isEmpty(); + } + + @Test + void givenNonEmptyString_whenCallingWrap_thenResultIsWrappedString() { + assertThat(StringUtilsWithUtilityClass.wrap("asd", "wrapper")).isEqualTo("wrapperasdwrapper"); + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/warning/StringUtilsStringUtilsSuppressWarningUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/warning/StringUtilsStringUtilsSuppressWarningUnitTest.java new file mode 100644 index 0000000000..646da08cc4 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/utilities/warning/StringUtilsStringUtilsSuppressWarningUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.utilities.warning; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class StringUtilsStringUtilsSuppressWarningUnitTest { + + @Test + void givenAnEmptyString_whenCallingIsEmpty_thenResultIsTrue() { + assertThat(StringUtilsSuppressWarning.isEmpty("")).isTrue(); + } + + @Test + void givenNonEmptyString_whenCallingIsEmpty_thenResultIsFalse() { + assertThat(StringUtilsSuppressWarning.isEmpty("asd")).isFalse(); + } + + @Test + void givenAnEmptyString_whenCallingWrap_thenResultIsAnEmptyString() { + assertThat(StringUtilsSuppressWarning.wrap("", "wrapper")).isEmpty(); + } + + @Test + void givenNonEmptyString_whenCallingWrap_thenResultIsWrappedString() { + assertThat(StringUtilsSuppressWarning.wrap("asd", "wrapper")).isEqualTo("wrapperasdwrapper"); + } + +} From 7ce6fc4e4596ab0f1b5071c0ed1b11f343620b5c Mon Sep 17 00:00:00 2001 From: sachin <56427366+sachin071287@users.noreply.github.com> Date: Thu, 2 Dec 2021 19:18:05 +0530 Subject: [PATCH 319/551] BAEL-5203 :Add an image to an Excel file with Java (#11391) Co-authored-by: Sachin kumar Co-authored-by: ashleyfrieze --- apache-poi-2/pom.xml | 13 ++- .../addimageincell/ExcelCellImageHelper.java | 76 ++++++++++++++++++ apache-poi-2/src/main/resources/ironman.png | Bin 0 -> 47793 bytes apache-poi-2/src/main/resources/spiderman.png | Bin 0 -> 57060 bytes 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 apache-poi-2/src/main/java/com/baeldung/poi/excel/write/addimageincell/ExcelCellImageHelper.java create mode 100644 apache-poi-2/src/main/resources/ironman.png create mode 100644 apache-poi-2/src/main/resources/spiderman.png diff --git a/apache-poi-2/pom.xml b/apache-poi-2/pom.xml index 1cb6509457..a46365c63c 100644 --- a/apache-poi-2/pom.xml +++ b/apache-poi-2/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - apache-poi + apache-poi-2 0.0.1-SNAPSHOT - apache-poi + apache-poi-2 com.baeldung @@ -17,8 +17,13 @@ org.apache.poi poi-ooxml - 5.0.0 + ${poi.version} - \ No newline at end of file + + 5.0.0 + + + + diff --git a/apache-poi-2/src/main/java/com/baeldung/poi/excel/write/addimageincell/ExcelCellImageHelper.java b/apache-poi-2/src/main/java/com/baeldung/poi/excel/write/addimageincell/ExcelCellImageHelper.java new file mode 100644 index 0000000000..6bd4f9d66b --- /dev/null +++ b/apache-poi-2/src/main/java/com/baeldung/poi/excel/write/addimageincell/ExcelCellImageHelper.java @@ -0,0 +1,76 @@ +package com.baeldung.poi.excel.write.addimageincell; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * This Helper class Add an Image to a Cell of an Excel File With apache-poi api. + * + */ +public class ExcelCellImageHelper { + + public static void main(String[] args) throws IOException, InvalidFormatException { + try (final Workbook workbook = new XSSFWorkbook(); + FileOutputStream saveExcel = new FileOutputStream("target/baeldung-apachepoi.xlsx");) { + + Sheet sheet = workbook.createSheet("Avengers"); + + XSSFDrawing drawing = (XSSFDrawing) sheet.createDrawingPatriarch(); + XSSFClientAnchor ironManAnchor = new XSSFClientAnchor(); + XSSFClientAnchor spiderManAnchor = new XSSFClientAnchor(); + + // Fill row1 data + Row row1 = sheet.createRow(0); + row1.setHeight((short) 1000); + row1.createCell(0) + .setCellValue("IRON-MAN"); + updateCellWithImage(workbook, 1, drawing, ironManAnchor, "ironman.png"); + + // Fill row2 data + Row row2 = sheet.createRow(1); + row2.setHeight((short) 1000); + row2.createCell(0) + .setCellValue("SPIDER-MAN"); + updateCellWithImage(workbook, 2, drawing, spiderManAnchor, "spiderman.png"); + + // Resize all columns to fit the content size + for (int i = 0; i < 2; i++) { + sheet.autoSizeColumn(i); + } + workbook.write(saveExcel); + } + + } + + /** + * This method position the anchor for a given rowNum and add the image correctly. + * @param workbook + * @param rowNum + * @param drawing + * @param inputImageAnchor + * @throws IOException + */ + private static void updateCellWithImage(Workbook workbook, int rowNum, XSSFDrawing drawing, XSSFClientAnchor inputImageAnchor, String inputImageName) throws IOException { + InputStream inputImageStream = ExcelCellImageHelper.class.getClassLoader() + .getResourceAsStream(inputImageName); + byte[] inputImageBytes = IOUtils.toByteArray(inputImageStream); + int inputImagePictureID = workbook.addPicture(inputImageBytes, Workbook.PICTURE_TYPE_PNG); + inputImageStream.close(); + inputImageAnchor.setCol1(1); + inputImageAnchor.setRow1(rowNum - 1); + inputImageAnchor.setCol2(2); + inputImageAnchor.setRow2(rowNum); + drawing.createPicture(inputImageAnchor, inputImagePictureID); + } + +} diff --git a/apache-poi-2/src/main/resources/ironman.png b/apache-poi-2/src/main/resources/ironman.png new file mode 100644 index 0000000000000000000000000000000000000000..30096294c9b26a8dc0a20d1427e2f3fdcbf4c8a8 GIT binary patch literal 47793 zcmZU31ymf((&#Sk?iM^ia0m`rG&l<^?(PuWf)m``+2HQ(PSD^k!9BP`^7!t5-~I1- zug|Hen$qp+?wy{R4hJiKMn@q*0RRB#GSU(%Z#d}ju7PNB*eu{!F-oS?nIs`Pr}lM1C|Cx$HC#qMj?w1#IQ0g zq2_5$t6@tn!u-gizN=%n>tcu;9c?R#%q!_YMm}t-{(Am(bM5gwo$D{7`~HR?!1B(K zEM!Kj#VtY|%rEjWTILwevZo8XBN0{C)gBEC_PQQhXqX=Rq;hrb0wHV1v&m7k0CJ`s2oR!5#jK^ii}& zk9P|f_LFlA@I_*4ER$j3YI7vpBG?96?f`HEm?FKP;d8VnCr`z@ug3t_Eobq3N}dot z-7Hev${7pOh(3O-{`o+Hh%5eZEK*R1CMBvIc-b~lFHbvGi-~;(h`Ngef zPU3*dWj8hoACs?qzI0j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I$(dY%xjf1a1F_50 zfUGkJsy5fTV(WPr6l^XZ?Tk)_O0#H;sTk!f@=zL-Wdm2~&;^6=2YQ)4s0cP+kQZOy z-BVd)2wT3$HjBfo(8VjUJeBDu>u@gkHf4&j z9Srnw!-djiU5JA&85&*%!!ZyxwPm&B5Del%RzSI34C-KKFE*p9if{$@tNIh~;Ys!l zCYXijhZy(|{U;?d Date: Fri, 3 Dec 2021 17:20:12 +0530 Subject: [PATCH 320/551] JAVA-8736: update JDK version for the jdk9-and-above Jenkins jobs --- core-java-modules/core-java-11-2/pom.xml | 1 + core-java-modules/core-java-11/pom.xml | 2 ++ .../core-java-time-measurements/pom.xml | 16 ++++++++-------- .../com/baeldung/time/InstantUnitTest.java | 19 +++++++------------ .../baeldung/time/LocalDateTimeUnitTest.java | 7 ------- quarkus-vs-springboot/spring-project/pom.xml | 2 +- 6 files changed, 19 insertions(+), 28 deletions(-) diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 332b24ff2e..757c1c0772 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -12,6 +12,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../../pom.xml diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index fc61e373ec..1fa5ae2b45 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -13,6 +13,8 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + + ../../pom.xml diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index e2924b5278..28959d0938 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -38,15 +38,15 @@ ${asspectj.version} - org.powermock - powermock-module-junit4 - ${powermock.version} + org.mockito + mockito-inline + ${mockito-inline.version} test - org.powermock - powermock-api-mockito2 - ${powermock.version} + org.mockito + mockito-core + ${mockito-inline.version} test @@ -82,10 +82,10 @@ 3.6.1 2.10 - 1.18.12 + 1.18.22 1.8.9 - 2.0.7 1.44 + 4.0.0 \ No newline at end of file diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java index 608199197a..ba1821b1ce 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java @@ -1,20 +1,15 @@ package com.baeldung.time; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.MockedStatic; import java.time.Clock; import java.time.Instant; import java.time.ZoneId; import static org.assertj.core.api.Assertions.assertThat; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.mockito.Mockito.mockStatic; -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Instant.class }) public class InstantUnitTest { @Test @@ -22,12 +17,12 @@ public class InstantUnitTest { String instantExpected = "2014-12-22T10:15:30Z"; Clock clock = Clock.fixed(Instant.parse(instantExpected), ZoneId.of("UTC")); Instant instant = Instant.now(clock); - mockStatic(Instant.class); - when(Instant.now()).thenReturn(instant); - Instant now = Instant.now(); - - assertThat(now.toString()).isEqualTo(instantExpected); + try (MockedStatic mockedStatic = mockStatic(Instant.class)) { + mockedStatic.when(Instant::now).thenReturn(instant); + Instant now = Instant.now(); + assertThat(now.toString()).isEqualTo(instantExpected); + } } @Test diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java index 52dc9ba1c6..e4401d67b7 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java @@ -1,9 +1,6 @@ package com.baeldung.time; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import java.time.Clock; import java.time.Instant; @@ -11,11 +8,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -@RunWith(PowerMockRunner.class) -@PrepareForTest({ LocalDateTime.class }) public class LocalDateTimeUnitTest { @Test diff --git a/quarkus-vs-springboot/spring-project/pom.xml b/quarkus-vs-springboot/spring-project/pom.xml index 128966c07e..ad841a4c0f 100644 --- a/quarkus-vs-springboot/spring-project/pom.xml +++ b/quarkus-vs-springboot/spring-project/pom.xml @@ -166,7 +166,7 @@ 11 - 0.10.3 + 0.10.5 \ No newline at end of file From fdadff3a517add0813b4be752b3168f2f7cc4801 Mon Sep 17 00:00:00 2001 From: chaos2418 <> Date: Sat, 4 Dec 2021 10:00:10 +0530 Subject: [PATCH 321/551] JAVA-8736: fixing plugin versions in core-java-11-2 to work with JDK 17 --- core-java-modules/core-java-11-2/pom.xml | 20 ++++--------------- .../soap/ws/client/generated/Country.java | 8 ++++---- .../ws/client/generated/CountryService.java | 18 ++++++++--------- .../generated/CountryServiceImplService.java | 16 +++++++-------- .../soap/ws/client/generated/Currency.java | 5 ++--- .../ws/client/generated/ObjectFactory.java | 2 +- .../ws/client/generated/package-info.java | 2 +- 7 files changed, 29 insertions(+), 42 deletions(-) diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 757c1c0772..fac23f9bfd 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -36,18 +36,6 @@ jakarta.xml.ws-api ${jakarta.ws-api.version} - - com.sun.xml.ws - jaxws-rt - ${jaxws-rt.version} - runtime - - - com.sun.xml.ws - jaxws-ri - ${jaxws-ri.version} - pom - @@ -83,10 +71,10 @@ 11 29.0-jre 5.11.1 - 3.0.0 - 3.0.0 - 2.3.1 - 2.3.2 + 3.0.1 + 3.0.2 + 3.0.2 + 3.0.2 \ No newline at end of file diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Country.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Country.java index 950d588661..d39f333b41 100644 --- a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Country.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Country.java @@ -1,10 +1,10 @@ package com.baeldung.soap.ws.client.generated; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlSchemaType; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java index 807d152cf1..f10dcade1b 100644 --- a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java @@ -1,19 +1,19 @@ package com.baeldung.soap.ws.client.generated; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.Action; +import jakarta.jws.WebMethod; +import jakarta.jws.WebParam; +import jakarta.jws.WebResult; +import jakarta.jws.WebService; +import jakarta.jws.soap.SOAPBinding; +import jakarta.xml.bind.annotation.XmlSeeAlso; +import jakarta.xml.ws.Action; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.3.2 - * Generated source version: 2.2 + * JAX-WS RI 3.0.2 + * Generated source version: 3.0 * */ @WebService(name = "CountryService", targetNamespace = "http://server.ws.soap.baeldung.com/") diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java index 97d6c82145..ae7ff38f7d 100644 --- a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java @@ -4,17 +4,17 @@ package com.baeldung.soap.ws.client.generated; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import javax.xml.ws.WebEndpoint; -import javax.xml.ws.WebServiceClient; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; +import jakarta.xml.ws.Service; +import jakarta.xml.ws.WebEndpoint; +import jakarta.xml.ws.WebServiceClient; +import jakarta.xml.ws.WebServiceException; +import jakarta.xml.ws.WebServiceFeature; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.3.2 - * Generated source version: 2.2 + * JAX-WS RI 3.0.2 + * Generated source version: 3.0 * */ @WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl") @@ -75,7 +75,7 @@ public class CountryServiceImplService /** * * @param features - * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. * @return * returns CountryService */ diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java index c010f5533c..ad42c65461 100644 --- a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java @@ -1,15 +1,14 @@ package com.baeldung.soap.ws.client.generated; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlEnum; +import jakarta.xml.bind.annotation.XmlType; /** *

Java class for currency. * *

The following schema fragment specifies the expected content contained within this class. - *

*

  * <simpleType name="currency">
  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java
index 9ed85fe2b9..0489e49c2b 100644
--- a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java
+++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java
@@ -1,7 +1,7 @@
 
 package com.baeldung.soap.ws.client.generated;
 
-import javax.xml.bind.annotation.XmlRegistry;
+import jakarta.xml.bind.annotation.XmlRegistry;
 
 
 /**
diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java
index dfc556859f..6dcc08c268 100644
--- a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java
+++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java
@@ -1,2 +1,2 @@
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://server.ws.soap.baeldung.com/")
+@jakarta.xml.bind.annotation.XmlSchema(namespace = "http://server.ws.soap.baeldung.com/")
 package com.baeldung.soap.ws.client.generated;

From 3a001425f82a3308cd48ede405d779c01d1b6248 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 16:10:21 +0800
Subject: [PATCH 322/551] Update README.md

---
 spring-5-webflux/README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md
index bd667468fb..889f211fc6 100644
--- a/spring-5-webflux/README.md
+++ b/spring-5-webflux/README.md
@@ -11,3 +11,4 @@ This module contains articles about Spring 5 WebFlux
 - [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux)
 - [Set a Timeout in Spring 5 Webflux WebClient](https://www.baeldung.com/spring-webflux-timeout)
 - [Guide to Retry in Spring WebFlux](https://www.baeldung.com/spring-webflux-retry)
+- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable)

From 65f604e05df66f41b7b506889bb7b96e39795edf Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 16:14:21 +0800
Subject: [PATCH 323/551] Update README.md

---
 core-java-modules/core-java-string-algorithms-3/README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core-java-modules/core-java-string-algorithms-3/README.md b/core-java-modules/core-java-string-algorithms-3/README.md
index 8d515b9aea..e6dbf3a489 100644
--- a/core-java-modules/core-java-string-algorithms-3/README.md
+++ b/core-java-modules/core-java-string-algorithms-3/README.md
@@ -6,3 +6,4 @@ This module contains articles about string-related algorithms.
 
 - [Check if Two Strings are Anagrams in Java](https://www.baeldung.com/java-strings-anagrams)
 - [Email Validation in Java](https://www.baeldung.com/java-email-validation-regex)
+- [Check if the First Letter of a String is Uppercase](https://www.baeldung.com/java-check-first-letter-uppercase)

From 77c7b12b20801c883b46516b75bd4dfada96a67d Mon Sep 17 00:00:00 2001
From: chaos2418 <>
Date: Sat, 4 Dec 2021 10:33:19 +0530
Subject: [PATCH 324/551] JAVA-8736: updating spring-aot-maven-plugin version
 in sprng-project to be compatible with JDK 17

---
 quarkus-vs-springboot/spring-project/pom.xml | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/quarkus-vs-springboot/spring-project/pom.xml b/quarkus-vs-springboot/spring-project/pom.xml
index ad841a4c0f..989e30526f 100644
--- a/quarkus-vs-springboot/spring-project/pom.xml
+++ b/quarkus-vs-springboot/spring-project/pom.xml
@@ -10,7 +10,7 @@
     
         org.springframework.boot
         spring-boot-starter-parent
-        2.5.4
+        2.6.0
         
     
 
@@ -96,6 +96,15 @@
                 false
             
         
+        
+        
+            spring-milestones
+            Spring Milestones
+            https://repo.spring.io/libs-milestone-local
+            
+                false
+            
+        
     
     
         
@@ -106,6 +115,15 @@
                 false
             
         
+        
+        
+            spring-milestones
+            Spring Milestones
+            https://repo.spring.io/libs-milestone-local
+            
+                false
+            
+        
     
 
     
@@ -166,7 +184,7 @@
     
         11
         
-        0.10.5
+        0.11.0-RC1
     
 
 
\ No newline at end of file

From 6666a7574ad08be0cf9fa1479ada0b194c833902 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 19:22:39 +0800
Subject: [PATCH 325/551] Update README.md

---
 persistence-modules/spring-jpa/README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md
index 202f5b0293..aa9e833260 100644
--- a/persistence-modules/spring-jpa/README.md
+++ b/persistence-modules/spring-jpa/README.md
@@ -5,7 +5,6 @@
 - [JPA Pagination](https://www.baeldung.com/jpa-pagination)
 - [Sorting with JPA](https://www.baeldung.com/jpa-sort)
 - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database)
-- [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys)
 - [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations)
 - [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source)
 - More articles: [[next -->]](/spring-jpa-2)

From 42549ff9e2b87615a2b3db0fdacefb9b451104a3 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 19:26:22 +0800
Subject: [PATCH 326/551] Update README.md

---
 core-java-modules/core-java-string-algorithms-2/README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/core-java-modules/core-java-string-algorithms-2/README.md b/core-java-modules/core-java-string-algorithms-2/README.md
index aa71e5f59e..dbfbb3ef3c 100644
--- a/core-java-modules/core-java-string-algorithms-2/README.md
+++ b/core-java-modules/core-java-string-algorithms-2/README.md
@@ -13,5 +13,4 @@ This module contains articles about string-related algorithms.
 - [Remove Leading and Trailing Characters from a String](https://www.baeldung.com/java-remove-trailing-characters)
 - [Counting Words in a String with Java](https://www.baeldung.com/java-word-counting)
 - [Finding the Difference Between Two Strings in Java](https://www.baeldung.com/java-difference-between-two-strings)
-- [Check if the First Letter of a String is Uppercase](https://www.baeldung.com/java-check-first-letter-uppercase)
 - More articles: [[<-- prev]](../core-java-string-algorithms)

From 48e61e7d56464f4803b7a600fa40b1b5431348f6 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 19:35:52 +0800
Subject: [PATCH 327/551] Update README.md

---
 persistence-modules/spring-boot-persistence/README.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/persistence-modules/spring-boot-persistence/README.md b/persistence-modules/spring-boot-persistence/README.md
index a9fe3905c2..88526cdb89 100644
--- a/persistence-modules/spring-boot-persistence/README.md
+++ b/persistence-modules/spring-boot-persistence/README.md
@@ -7,5 +7,4 @@
 - [Resolving “Failed to Configure a DataSource” Error](https://www.baeldung.com/spring-boot-failed-to-configure-data-source)
 - [Hibernate Field Naming with Spring Boot](https://www.baeldung.com/hibernate-field-naming-spring-boot)
 - [Spring Boot with Hibernate](https://www.baeldung.com/spring-boot-hibernate)
-- [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source)
-- More articles: [[more -->]](../spring-boot-persistence-2)
\ No newline at end of file
+- More articles: [[more -->]](../spring-boot-persistence-2)

From 446cc2beb90ced8044fd7394b7d01f50e5dff9d1 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 19:41:35 +0800
Subject: [PATCH 328/551] Delete README.md

---
 .../src/test/java/com/baeldung/hexToAscii/README.md             | 2 --
 1 file changed, 2 deletions(-)
 delete mode 100644 core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/hexToAscii/README.md

diff --git a/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/hexToAscii/README.md b/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/hexToAscii/README.md
deleted file mode 100644
index c6d5826333..0000000000
--- a/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/hexToAscii/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### Relevant Articles:
-- [Convert Hex to ASCII in Java](http://www.baeldung.com/java-convert-hex-to-ascii)

From 0673bc708b08bbc5c47afb355ef5f5db08d7e39b Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Sat, 4 Dec 2021 19:44:36 +0800
Subject: [PATCH 329/551] Update README.md

---
 spring-boot-modules/spring-boot-runtime/README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/spring-boot-modules/spring-boot-runtime/README.md b/spring-boot-modules/spring-boot-runtime/README.md
index 94822af09e..6f21efe793 100644
--- a/spring-boot-modules/spring-boot-runtime/README.md
+++ b/spring-boot-modules/spring-boot-runtime/README.md
@@ -10,4 +10,3 @@ This module contains articles about administering a Spring Boot runtime
  - [Project Configuration with Spring](https://www.baeldung.com/project-configuration-with-spring)
  - [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging)
  - [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat)
- - [Max-HTTP-Header-Size in Spring Boot 2](https://www.baeldung.com/spring-boot-max-http-header-size)

From 2c5982f9f9ddcb265674152917853a5694f091a6 Mon Sep 17 00:00:00 2001
From: polomos 
Date: Sun, 5 Dec 2021 03:40:46 +0100
Subject: [PATCH 330/551] BAEL-5060 JMX ports explained (#11505)

---
 .../main/java/com/baeldung/jmx/JMXConfiguration.java   | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/JMXConfiguration.java

diff --git a/core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/JMXConfiguration.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/JMXConfiguration.java
new file mode 100644
index 0000000000..e60ea253ed
--- /dev/null
+++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/JMXConfiguration.java
@@ -0,0 +1,10 @@
+package com.baeldung.jmx;
+
+public class JMXConfiguration {
+
+    public static void main(String[] args) {
+        while (true) {
+            // to ensure application does not terminate
+        }
+    }
+}
\ No newline at end of file

From f97df9e8285059c224d35beaaf66e11e4dc8a21e Mon Sep 17 00:00:00 2001
From: sampadawagde 
Date: Sun, 5 Dec 2021 11:58:14 +0530
Subject: [PATCH 331/551] JAVA-8354: Split or move core-java-collections-3

---
 core-java-modules/core-java-collections-3/README.md |  2 +-
 .../baeldung/collections/stack/StackUnitTest.java   |  2 +-
 core-java-modules/core-java-collections/README.md   |  3 ++-
 core-java-modules/core-java-collections/pom.xml     |  5 +++++
 .../ConvertPrimitivesArrayToList.java               |  8 +++++---
 .../ConvertPrimitivesArrayToListUnitTest.java       | 13 +++++--------
 6 files changed, 19 insertions(+), 14 deletions(-)
 rename core-java-modules/{core-java-collections-3 => core-java-collections}/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java (95%)
 rename core-java-modules/{core-java-collections-3 => core-java-collections}/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java (87%)

diff --git a/core-java-modules/core-java-collections-3/README.md b/core-java-modules/core-java-collections-3/README.md
index 6bc9139856..4249d8ad30 100644
--- a/core-java-modules/core-java-collections-3/README.md
+++ b/core-java-modules/core-java-collections-3/README.md
@@ -11,7 +11,7 @@
 - [Performance of contains() in a HashSet vs ArrayList](https://www.baeldung.com/java-hashset-arraylist-contains-performance)
 - [Fail-Safe Iterator vs Fail-Fast Iterator](https://www.baeldung.com/java-fail-safe-vs-fail-fast-iterator)
 - [Quick Guide to the Java Stack](https://www.baeldung.com/java-stack)
-- [Convert an Array of Primitives to a List](https://www.baeldung.com/java-primitive-array-to-list)
 - [A Guide to BitSet in Java](https://www.baeldung.com/java-bitset)
 - [Get the First Key and Value From a HashMap](https://www.baeldung.com/java-hashmap-get-first-entry)
 - [Performance of removeAll() in a HashSet](https://www.baeldung.com/java-hashset-removeall-performance)
+- More articles: [[<-- prev]](/core-java-modules/core-java-collections-2) [[next -->]](/core-java-modules/core-java-collections-4)
diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/stack/StackUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/stack/StackUnitTest.java
index 6a2feff551..14eafe8924 100644
--- a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/stack/StackUnitTest.java
+++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/stack/StackUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.stack;
+package com.baeldung.collections.stack;
 
 import org.junit.Test;
 
diff --git a/core-java-modules/core-java-collections/README.md b/core-java-modules/core-java-collections/README.md
index 12e3c5ac17..574f61ac6a 100644
--- a/core-java-modules/core-java-collections/README.md
+++ b/core-java-modules/core-java-collections/README.md
@@ -12,4 +12,5 @@ This module contains articles about Java collections
 - [Defining a Char Stack in Java](https://www.baeldung.com/java-char-stack)
 - [Guide to the Java Queue Interface](https://www.baeldung.com/java-queue)
 - [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections)
-- [[More -->]](/core-java-modules/core-java-collections-2)
+- [Convert an Array of Primitives to a List](https://www.baeldung.com/java-primitive-array-to-list)
+- More articles: [[next -->]](/core-java-modules/core-java-collections-2)
diff --git a/core-java-modules/core-java-collections/pom.xml b/core-java-modules/core-java-collections/pom.xml
index 8df0d7cdd3..eab7a35584 100644
--- a/core-java-modules/core-java-collections/pom.xml
+++ b/core-java-modules/core-java-collections/pom.xml
@@ -25,6 +25,11 @@
             jmh-generator-annprocess
             ${jmh-generator.version}
         
+        
+            org.apache.commons
+            commons-lang3
+            ${commons-lang3.version}
+        
     
 
 
\ No newline at end of file
diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java
similarity index 95%
rename from core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java
rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java
index f7be99abdc..1e6efb7840 100644
--- a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java
+++ b/core-java-modules/core-java-collections/src/main/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToList.java
@@ -1,13 +1,15 @@
-package com.baeldung.collections.iterators;
+package com.baeldung.collections.convertarrayprimitives;
 
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
-import com.google.common.primitives.Ints;
+
 import org.apache.commons.lang3.ArrayUtils;
 
+import com.google.common.primitives.Ints;
+
 public class ConvertPrimitivesArrayToList {
 
     public static void failConvert() {
diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java
similarity index 87%
rename from core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java
rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java
index b773baf7d8..f9f5f8ea91 100644
--- a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java
+++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/collections/convertarrayprimitives/ConvertPrimitivesArrayToListUnitTest.java
@@ -1,14 +1,11 @@
-package com.baeldung.collections.iterators;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.stream.Collectors;
-import com.google.common.primitives.Ints;
-import org.junit.Test;
+package com.baeldung.collections.convertarrayprimitives;
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.Arrays;
+
+import org.junit.Test;
+
 public class ConvertPrimitivesArrayToListUnitTest {
 
     @Test

From 40669cc7c682925bba691ca820a19c0fab95a6fc Mon Sep 17 00:00:00 2001
From: ioanadinuit <83220826+ioanadinuit@users.noreply.github.com>
Date: Sun, 5 Dec 2021 10:01:04 +0200
Subject: [PATCH 332/551] Update annotation name (#11531)

---
 .../validation/{Camelcase.java => Capitalized.java}         | 6 +++---
 .../{CamelcaseValidator.java => CapitalizedValidator.java}  | 6 +++---
 .../src/main/resources/openapi/templates/api.mustache       | 2 +-
 .../src/main/resources/openapi/templates/model.mustache     | 2 +-
 .../src/main/resources/petstore.yml                         | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/{Camelcase.java => Capitalized.java} (74%)
 rename spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/{CamelcaseValidator.java => CapitalizedValidator.java} (83%)

diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Capitalized.java
similarity index 74%
rename from spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java
rename to spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Capitalized.java
index b0b0b739e2..de83297c53 100644
--- a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java
+++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Capitalized.java
@@ -5,12 +5,12 @@ import javax.validation.Payload;
 import java.lang.annotation.*;
 
 @Documented
-@Constraint(validatedBy = {CamelcaseValidator.class})
+@Constraint(validatedBy = {CapitalizedValidator.class})
 @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
-public @interface Camelcase {
+public @interface Capitalized {
 
-    String message() default "Name should be uppercase.";
+    String message() default "Name should be capitalized.";
 
     boolean required() default true;
 
diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CapitalizedValidator.java
similarity index 83%
rename from spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java
rename to spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CapitalizedValidator.java
index 2b08e3dd2a..969dc0c56c 100644
--- a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java
+++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CapitalizedValidator.java
@@ -4,11 +4,11 @@ import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
 import java.util.Objects;
 
-public class CamelcaseValidator implements ConstraintValidator {
+public class CapitalizedValidator implements ConstraintValidator {
 
-	private Camelcase uppercaseAnnotation;
+	private Capitalized uppercaseAnnotation;
 
-	public void initialize(Camelcase constraintAnnotation) {
+	public void initialize(Capitalized constraintAnnotation) {
 		this.uppercaseAnnotation = constraintAnnotation;
 	}
 
diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache
index a7a35d43b5..34f4afac3a 100644
--- a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache
+++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache
@@ -8,7 +8,7 @@ package {{package}};
 {{#imports}}import {{import}};
 {{/imports}}
 import io.swagger.annotations.*;
-import com.baeldung.openapi.petstore.validation.Camelcase;
+import com.baeldung.openapi.petstore.validation.Capitalized;
 {{#jdk8-no-delegate}}
 {{#virtualService}}
 import io.virtualan.annotation.ApiVirtual;
diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache
index d9329b40d3..4546a811ef 100644
--- a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache
+++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache
@@ -4,7 +4,7 @@ package {{package}};
 {{/imports}}
 import com.fasterxml.jackson.databind.annotation.*;
 import com.fasterxml.jackson.annotation.*;
-import com.baeldung.openapi.petstore.validation.Camelcase;
+import com.baeldung.openapi.petstore.validation.Capitalized;
 {{^supportJava6}}
 import java.util.Objects;
 import java.util.Arrays;
diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml
index c9884c01e8..c5fbd830bb 100644
--- a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml
+++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml
@@ -37,7 +37,7 @@ paths:
           schema:
             type: string
           description: Tags to filter by
-          x-constraints: "@Camelcase(required = true)"
+          x-constraints: "@Capitalized(required = true)"
       responses:
         '200':
           description: default response
@@ -62,4 +62,4 @@ components:
           format: int64
         name:
           type: string
-          x-constraints: "@Camelcase(required = true)"
\ No newline at end of file
+          x-constraints: "@Capitalized(required = true)"
\ No newline at end of file

From 8fd0ab58b984b9a5538d2d67bc94592c87431a57 Mon Sep 17 00:00:00 2001
From: sharifi 
Date: Sun, 5 Dec 2021 13:57:38 +0330
Subject: [PATCH 333/551] bael-4197: add application-context

---
 .../src/main/resources/application-context.xml           | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 spring-boot-modules/spring-boot-testing/src/main/resources/application-context.xml

diff --git a/spring-boot-modules/spring-boot-testing/src/main/resources/application-context.xml b/spring-boot-modules/spring-boot-testing/src/main/resources/application-context.xml
new file mode 100644
index 0000000000..a436b39a2f
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/main/resources/application-context.xml
@@ -0,0 +1,9 @@
+
+
+	  
+	
+

From 63843c008c055e7d9da3efef2d5773e5316f3722 Mon Sep 17 00:00:00 2001
From: sharifi 
Date: Sun, 5 Dec 2021 13:58:13 +0330
Subject: [PATCH 334/551] bael-4197: add main source

---
 .../XmlBeanApplication.java                   | 15 +++++++++
 .../domain/Employee.java                      | 32 +++++++++++++++++++
 .../service/EmployeeService.java              |  8 +++++
 .../service/EmployeeServiceImpl.java          | 11 +++++++
 .../service/EmployeeServiceTestImpl.java      | 11 +++++++
 5 files changed, 77 insertions(+)
 create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/XmlBeanApplication.java
 create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/domain/Employee.java
 create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeService.java
 create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceImpl.java
 create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceTestImpl.java

diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/XmlBeanApplication.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/XmlBeanApplication.java
new file mode 100644
index 0000000000..4e2af67ab0
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/XmlBeanApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.xmlapplicationcontext;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ImportResource;
+
+@SpringBootApplication
+@ImportResource({"classpath*:application-context.xml"})
+public class XmlBeanApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(XmlBeanApplication.class, args);
+	}
+
+}
diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/domain/Employee.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/domain/Employee.java
new file mode 100644
index 0000000000..f81277f027
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/domain/Employee.java
@@ -0,0 +1,32 @@
+package com.baeldung.xmlapplicationcontext.domain;
+
+public class Employee {
+
+    private String name;
+    private String role;
+
+    public Employee() {
+
+    }
+
+    public Employee(String name, String role) {
+        this.name = name;
+        this.role = role;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getRole() {
+        return this.role;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setRole(String role) {
+        this.role = role;
+    }
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeService.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeService.java
new file mode 100644
index 0000000000..867e9b8c9f
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeService.java
@@ -0,0 +1,8 @@
+package com.baeldung.xmlapplicationcontext.service;
+
+import com.baeldung.xmlapplicationcontext.domain.Employee;
+
+public interface EmployeeService {
+
+    Employee getEmployee();
+}
diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceImpl.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceImpl.java
new file mode 100644
index 0000000000..b541c62dcd
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceImpl.java
@@ -0,0 +1,11 @@
+package com.baeldung.xmlapplicationcontext.service;
+
+import com.baeldung.xmlapplicationcontext.domain.Employee;
+
+public class EmployeeServiceImpl implements EmployeeService {
+
+    @Override
+    public Employee getEmployee() {
+        return new Employee("Baeldung", "Admin");
+    }
+}
diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceTestImpl.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceTestImpl.java
new file mode 100644
index 0000000000..7cebaa399b
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/xmlapplicationcontext/service/EmployeeServiceTestImpl.java
@@ -0,0 +1,11 @@
+package com.baeldung.xmlapplicationcontext.service;
+
+import com.baeldung.xmlapplicationcontext.domain.Employee;
+
+public class EmployeeServiceTestImpl implements EmployeeService {
+
+    @Override
+    public Employee getEmployee() {
+        return new Employee("Baeldung-Test", "Admin");
+    }
+}

From 232bd3080b506b2cfd846f64c2b4b953d08b4bf2 Mon Sep 17 00:00:00 2001
From: sharifi 
Date: Sun, 5 Dec 2021 13:58:28 +0330
Subject: [PATCH 335/551] bael-4197: add test context

---
 .../src/test/resources/test-context.xml                  | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 spring-boot-modules/spring-boot-testing/src/test/resources/test-context.xml

diff --git a/spring-boot-modules/spring-boot-testing/src/test/resources/test-context.xml b/spring-boot-modules/spring-boot-testing/src/test/resources/test-context.xml
new file mode 100644
index 0000000000..664b528b06
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/test/resources/test-context.xml
@@ -0,0 +1,9 @@
+
+
+
+	
+

From 58b01b624a25cb858a46a32d2b857aaf9c4af270 Mon Sep 17 00:00:00 2001
From: sharifi 
Date: Sun, 5 Dec 2021 13:58:51 +0330
Subject: [PATCH 336/551] bael-4197: add test class

---
 ...loyeeServiceAppContextIntegrationTest.java | 21 ++++++++++++++++
 ...oyeeServiceTestContextIntegrationTest.java | 25 +++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java
 create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java

diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java
new file mode 100644
index 0000000000..7a63abf1a3
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java
@@ -0,0 +1,21 @@
+package com.baeldung.xmlapplicationcontext;
+
+import com.baeldung.xmlapplicationcontext.service.EmployeeService;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SpringBootTest(classes = XmlBeanApplication.class)
+public class EmployeeServiceAppContextIntegrationTest {
+
+    @Autowired
+    private EmployeeService service;
+
+    @Test
+    public void whenContextLoads_thenServiceISNotNull() {
+        assertThat(service).isNotNull();
+    }
+
+}
diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java
new file mode 100644
index 0000000000..9880c7c567
--- /dev/null
+++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java
@@ -0,0 +1,25 @@
+package com.baeldung.xmlapplicationcontext;
+
+import com.baeldung.xmlapplicationcontext.service.EmployeeService;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SpringBootTest
+@ContextConfiguration(locations = "/test-context.xml")
+public class EmployeeServiceTestContextIntegrationTest {
+
+    @Autowired
+    @Qualifier("employeeServiceTestImpl")
+    private EmployeeService serviceTest;
+
+    @Test
+    public void whenTestContextLoads_thenServiceTestISNotNull() {
+        assertThat(serviceTest).isNotNull();
+    }
+
+}

From 7f17253b07adc3852967f8ada1c49f51d680a66f Mon Sep 17 00:00:00 2001
From: sharifi 
Date: Sun, 5 Dec 2021 14:28:10 +0330
Subject: [PATCH 337/551] bael-4197: fix bug

---
 .../EmployeeServiceAppContextIntegrationTest.java            | 4 ++++
 .../EmployeeServiceTestContextIntegrationTest.java           | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java
index 7a63abf1a3..0ab157744a 100644
--- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java
@@ -2,11 +2,15 @@ package com.baeldung.xmlapplicationcontext;
 
 import com.baeldung.xmlapplicationcontext.service.EmployeeService;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+
+@RunWith(SpringRunner.class)
 @SpringBootTest(classes = XmlBeanApplication.class)
 public class EmployeeServiceAppContextIntegrationTest {
 
diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java
index 9880c7c567..0182d5dbb1 100644
--- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java
@@ -2,14 +2,17 @@ package com.baeldung.xmlapplicationcontext;
 
 import com.baeldung.xmlapplicationcontext.service.EmployeeService;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-@SpringBootTest
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = XmlBeanApplication.class)
 @ContextConfiguration(locations = "/test-context.xml")
 public class EmployeeServiceTestContextIntegrationTest {
 

From f879ab8cefc36044319874c7b9a57e6c6770c719 Mon Sep 17 00:00:00 2001
From: LiamGve 
Date: Sun, 5 Dec 2021 14:34:24 +0000
Subject: [PATCH 338/551] BAEL-5182 code for webclient status code handling
 article (#11373)

* BAEL-5182 code for webclient status code handling article

* BAEL-5182 code for webclient status code handling article

* BAEL-5182 added different exceptions to make seperate examples clearer

Co-authored-by: Liam Garvie 
---
 .../status/WebClientStatusCodeHandler.java    | 54 ++++++++++
 .../status/exception/BadRequestException.java |  7 ++
 .../exception/ServerErrorException.java       |  7 ++
 ...lientStatusCodeHandlerIntegrationTest.java | 98 +++++++++++++++++++
 4 files changed, 166 insertions(+)
 create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java
 create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java
 create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java
 create mode 100644 spring-5-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java

diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java
new file mode 100644
index 0000000000..9594ca32f1
--- /dev/null
+++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java
@@ -0,0 +1,54 @@
+package com.baeldung.webclient.status;
+
+import com.baeldung.webclient.status.exception.BadRequestException;
+import com.baeldung.webclient.status.exception.ServerErrorException;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.reactive.function.client.ClientResponse;
+import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+public class WebClientStatusCodeHandler {
+
+    public static Mono getResponseBodyUsingExchangeFilterFunction(String uri) {
+        ExchangeFilterFunction errorResponseFilter = ExchangeFilterFunction
+            .ofResponseProcessor(WebClientStatusCodeHandler::exchangeFilterResponseProcessor);
+        return WebClient
+            .builder()
+            .filter(errorResponseFilter)
+            .build()
+            .post()
+            .uri(uri)
+            .retrieve()
+            .bodyToMono(String.class);
+    }
+
+    public static Mono getResponseBodyUsingOnStatus(String uri) {
+        return WebClient
+            .builder()
+            .build()
+            .post()
+            .uri(uri)
+            .retrieve()
+            .onStatus(
+                HttpStatus.INTERNAL_SERVER_ERROR::equals,
+                response -> response.bodyToMono(String.class).map(ServerErrorException::new))
+            .onStatus(
+                HttpStatus.BAD_REQUEST::equals,
+                response -> response.bodyToMono(String.class).map(BadRequestException::new))
+            .bodyToMono(String.class);
+    }
+
+    private static Mono exchangeFilterResponseProcessor(ClientResponse response) {
+        HttpStatus status = response.statusCode();
+        if (HttpStatus.INTERNAL_SERVER_ERROR.equals(status)) {
+            return response.bodyToMono(String.class)
+                .flatMap(body -> Mono.error(new ServerErrorException(body)));
+        }
+        if (HttpStatus.BAD_REQUEST.equals(status)) {
+            return response.bodyToMono(String.class)
+                .flatMap(body -> Mono.error(new BadRequestException(body)));
+        }
+        return Mono.just(response);
+    }
+}
diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java
new file mode 100644
index 0000000000..bf5c599805
--- /dev/null
+++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java
@@ -0,0 +1,7 @@
+package com.baeldung.webclient.status.exception;
+
+public class BadRequestException extends Exception {
+    public BadRequestException(String message) {
+        super(message);
+    }
+}
diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java
new file mode 100644
index 0000000000..7e97f17dff
--- /dev/null
+++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java
@@ -0,0 +1,7 @@
+package com.baeldung.webclient.status.exception;
+
+public class ServerErrorException extends Exception {
+    public ServerErrorException(String message) {
+        super(message);
+    }
+}
diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java
new file mode 100644
index 0000000000..e491baf97a
--- /dev/null
+++ b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java
@@ -0,0 +1,98 @@
+package com.baeldung.webclient;
+
+import com.baeldung.webclient.status.WebClientStatusCodeHandler;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.junit4.SpringRunner;
+import reactor.core.publisher.Mono;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+@RunWith(SpringRunner.class)
+public class WebClientStatusCodeHandlerIntegrationTest {
+    private String baseUrl;
+    private WireMockServer wireMockServer;
+
+    @Before
+    public void setUp() {
+        wireMockServer = new WireMockServer(wireMockConfig().dynamicPort());
+        wireMockServer.start();
+        configureFor("localhost", wireMockServer.port());
+        baseUrl = format("http://localhost:%s", wireMockServer.port());
+    }
+
+    @After
+    public void tearDown() {
+        wireMockServer.stop();
+    }
+
+    @Test
+    public void whenResponseIs2XX_thenBothStatusHandlerAndExchangeFilterReturnEqualResponses() {
+        stubPostResponse("/success", 200, "success");
+
+        Mono responseStatusHandler = WebClientStatusCodeHandler
+            .getResponseBodyUsingOnStatus(baseUrl + "/success");
+
+        Mono responseExchangeFilter = WebClientStatusCodeHandler
+           .getResponseBodyUsingExchangeFilterFunction(baseUrl + "/success");
+
+        assertThat(responseStatusHandler.block())
+            .isEqualTo(responseExchangeFilter.block())
+            .isEqualTo("success");
+    }
+
+    @Test
+    public void whenResponseIs500_thenBothStatusHandlerAndExchangeFilterReturnEqualResponses() {
+        stubPostResponse("/server-error", 500, "Internal Server Error");
+
+        Mono responseStatusHandler = WebClientStatusCodeHandler
+            .getResponseBodyUsingOnStatus(baseUrl + "/server-error");
+
+        Mono responseExchangeFilter = WebClientStatusCodeHandler
+            .getResponseBodyUsingExchangeFilterFunction(baseUrl + "/server-error");
+
+        assertThatThrownBy(responseStatusHandler::block)
+            .isInstanceOf(Exception.class)
+            .hasMessageContaining("Internal Server Error");
+
+        assertThatThrownBy(responseExchangeFilter::block)
+            .isInstanceOf(Exception.class)
+            .hasMessageContaining("Internal Server Error");
+    }
+
+    @Test
+    public void whenResponseIs400_thenBothStatusHandlerAndExchangeFilterReturnEqualResponses() {
+        stubPostResponse("/client-error", 400, "Bad Request");
+
+        Mono responseStatusHandler = WebClientStatusCodeHandler
+            .getResponseBodyUsingOnStatus(baseUrl + "/client-error");
+
+        Mono responseExchangeFilter = WebClientStatusCodeHandler
+            .getResponseBodyUsingExchangeFilterFunction(baseUrl + "/client-error");
+
+        assertThatThrownBy(responseStatusHandler::block)
+            .isInstanceOf(Exception.class)
+            .hasMessageContaining("Bad Request");
+
+        assertThatThrownBy(responseExchangeFilter::block)
+            .isInstanceOf(Exception.class)
+            .hasMessageContaining("Bad Request");
+    }
+
+    private static void stubPostResponse(String url, int statusCode, String response) {
+        stubFor(post(urlEqualTo(url)).willReturn(aResponse()
+            .withStatus(statusCode)
+            .withBody(response)));
+    }
+}
\ No newline at end of file

From 9d62c835c5034cf7e232bfeb7e4eef644178fb2c Mon Sep 17 00:00:00 2001
From: chaos2418 <>
Date: Sun, 5 Dec 2021 20:59:15 +0530
Subject: [PATCH 339/551] JAVA-8649: removing bootstrap.properties in
 spring-cloud-bus module

---
 .../src/main/resources/application.yml               | 12 +++++++++++-
 .../src/main/resources/bootstrap.properties          |  7 -------
 .../src/main/resources/application.properties        |  7 ++++++-
 .../src/main/resources/bootstrap.properties          |  4 ----
 .../client/src/main/resources/application.properties |  2 +-
 5 files changed, 18 insertions(+), 14 deletions(-)
 delete mode 100644 spring-cloud-bus/spring-cloud-config-client/src/main/resources/bootstrap.properties
 delete mode 100644 spring-cloud-bus/spring-cloud-config-server/src/main/resources/bootstrap.properties

diff --git a/spring-cloud-bus/spring-cloud-config-client/src/main/resources/application.yml b/spring-cloud-bus/spring-cloud-config-client/src/main/resources/application.yml
index fbbc6d138f..bb5c9607b8 100644
--- a/spring-cloud-bus/spring-cloud-config-client/src/main/resources/application.yml
+++ b/spring-cloud-bus/spring-cloud-config-client/src/main/resources/application.yml
@@ -1,5 +1,11 @@
 ---
 spring:
+  application:
+    name: config-client
+  profiles:
+    active: development
+  config:
+    import: configserver:http://root:s3cr3t@localhost:8888
   rabbitmq:
     host: localhost
     port: 5672
@@ -10,8 +16,12 @@ spring:
       enabled: true
       refresh:
         enabled: true
+    config:
+      fail-fast: true
 management:
   endpoints:
     web:
       exposure:
-        include: "*"
\ No newline at end of file
+        include: "*"
+  security:
+    enabled: false
\ No newline at end of file
diff --git a/spring-cloud-bus/spring-cloud-config-client/src/main/resources/bootstrap.properties b/spring-cloud-bus/spring-cloud-config-client/src/main/resources/bootstrap.properties
deleted file mode 100644
index 7b362614ba..0000000000
--- a/spring-cloud-bus/spring-cloud-config-client/src/main/resources/bootstrap.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-spring.application.name=config-client
-spring.profiles.active=development
-spring.cloud.config.uri=http://localhost:8888
-spring.cloud.config.username=root
-spring.cloud.config.password=s3cr3t
-spring.cloud.config.fail-fast=true
-management.security.enabled=false
\ No newline at end of file
diff --git a/spring-cloud-bus/spring-cloud-config-server/src/main/resources/application.properties b/spring-cloud-bus/spring-cloud-config-server/src/main/resources/application.properties
index 6d7a945612..00ef9f0217 100644
--- a/spring-cloud-bus/spring-cloud-config-server/src/main/resources/application.properties
+++ b/spring-cloud-bus/spring-cloud-config-server/src/main/resources/application.properties
@@ -6,4 +6,9 @@ spring.security.user.password=s3cr3t
 spring.rabbitmq.host=localhost
 spring.rabbitmq.port=5672
 spring.rabbitmq.username=guest
-spring.rabbitmq.password=guest
\ No newline at end of file
+spring.rabbitmq.password=guest
+
+encrypt.key-store.location=classpath:/config-server.jks
+encrypt.key-store.password=my-s70r3-s3cr3t
+encrypt.key-store.alias=config-server-key
+encrypt.key-store.secret=my-k34-s3cr3t
\ No newline at end of file
diff --git a/spring-cloud-bus/spring-cloud-config-server/src/main/resources/bootstrap.properties b/spring-cloud-bus/spring-cloud-config-server/src/main/resources/bootstrap.properties
deleted file mode 100644
index b0c35c72a6..0000000000
--- a/spring-cloud-bus/spring-cloud-config-server/src/main/resources/bootstrap.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-encrypt.key-store.location=classpath:/config-server.jks
-encrypt.key-store.password=my-s70r3-s3cr3t
-encrypt.key-store.alias=config-server-key
-encrypt.key-store.secret=my-k34-s3cr3t
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties b/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties
index 6366bc515c..a96e6189a1 100644
--- a/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties
+++ b/spring-cloud/spring-cloud-config/client/src/main/resources/application.properties
@@ -1,3 +1,3 @@
 spring.application.name=config-client
 spring.profiles.active=development
-spring.config.import=optional:configserver:http://root:s3cr3t@localhost:8888 
\ No newline at end of file
+spring.config.import=optional:configserver:http://root:s3cr3t@localhost:8888
\ No newline at end of file

From c43b11c0f5107756f6786076bfc52bd54756555b Mon Sep 17 00:00:00 2001
From: chaos2418 <>
Date: Mon, 6 Dec 2021 14:54:20 +0530
Subject: [PATCH 340/551] JAVA-8736: removing unused jaxws* properties

---
 core-java-modules/core-java-11-2/pom.xml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml
index fac23f9bfd..b077373448 100644
--- a/core-java-modules/core-java-11-2/pom.xml
+++ b/core-java-modules/core-java-11-2/pom.xml
@@ -72,8 +72,6 @@
         29.0-jre
         5.11.1
         3.0.1
-        3.0.2
-        3.0.2
         3.0.2
     
 

From 5e02fd897aca7817f2e0087bb52ec29419dbd6ba Mon Sep 17 00:00:00 2001
From: sampadawagde 
Date: Mon, 6 Dec 2021 18:53:41 +0530
Subject: [PATCH 341/551] JAVA-8370: Split or move json module

---
 json-2/README.md                                            | 2 ++
 json-2/pom.xml                                              | 6 ++++++
 .../test/java/com/baeldung/fastjson}/FastJsonUnitTest.java  | 2 +-
 .../src/test/java/com/baeldung/fastjson}/Person.java        | 2 +-
 json/README.md                                              | 2 +-
 json/pom.xml                                                | 6 ------
 6 files changed, 11 insertions(+), 9 deletions(-)
 rename {json/src/test/java/fast_json => json-2/src/test/java/com/baeldung/fastjson}/FastJsonUnitTest.java (99%)
 rename {json/src/test/java/fast_json => json-2/src/test/java/com/baeldung/fastjson}/Person.java (97%)

diff --git a/json-2/README.md b/json-2/README.md
index aebc42c472..ed5a79dd3d 100644
--- a/json-2/README.md
+++ b/json-2/README.md
@@ -8,3 +8,5 @@ This module contains articles about JSON.
 - [Introduction to Moshi Json](https://www.baeldung.com/java-json-moshi)
 - [Hypermedia Serialization With JSON-LD](https://www.baeldung.com/json-linked-data)
 - [Generate a Java Class From JSON](https://www.baeldung.com/java-generate-class-from-json)
+- [A Guide to FastJson](https://www.baeldung.com/fastjson)
+- More Articles: [[<-- prev]](/json)
diff --git a/json-2/pom.xml b/json-2/pom.xml
index 591b7c0883..751199d394 100644
--- a/json-2/pom.xml
+++ b/json-2/pom.xml
@@ -14,6 +14,11 @@
     
 
     
+        
+            com.alibaba
+            fastjson
+            ${fastjson.version}
+        
         
             org.jsonschema2pojo
             jsonschema2pojo-core
@@ -142,6 +147,7 @@
     
         0.9.23
         1.9.2
+        1.2.21
     
 
 
\ No newline at end of file
diff --git a/json/src/test/java/fast_json/FastJsonUnitTest.java b/json-2/src/test/java/com/baeldung/fastjson/FastJsonUnitTest.java
similarity index 99%
rename from json/src/test/java/fast_json/FastJsonUnitTest.java
rename to json-2/src/test/java/com/baeldung/fastjson/FastJsonUnitTest.java
index 6fcf1e398a..eec7a1c95f 100644
--- a/json/src/test/java/fast_json/FastJsonUnitTest.java
+++ b/json-2/src/test/java/com/baeldung/fastjson/FastJsonUnitTest.java
@@ -1,4 +1,4 @@
-package fast_json;
+package com.baeldung.fastjson;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
diff --git a/json/src/test/java/fast_json/Person.java b/json-2/src/test/java/com/baeldung/fastjson/Person.java
similarity index 97%
rename from json/src/test/java/fast_json/Person.java
rename to json-2/src/test/java/com/baeldung/fastjson/Person.java
index 3d772348a4..5e142131a3 100644
--- a/json/src/test/java/fast_json/Person.java
+++ b/json-2/src/test/java/com/baeldung/fastjson/Person.java
@@ -1,4 +1,4 @@
-package fast_json;
+package com.baeldung.fastjson;
 
 import com.alibaba.fastjson.annotation.JSONField;
 
diff --git a/json/README.md b/json/README.md
index 6ad4c8a29d..0a4782cd86 100644
--- a/json/README.md
+++ b/json/README.md
@@ -4,7 +4,6 @@ This module contains articles about JSON.
 
 ### Relevant Articles:
 - [Introduction to JSON Schema in Java](https://www.baeldung.com/introduction-to-json-schema-in-java)
-- [A Guide to FastJson](https://www.baeldung.com/fastjson)
 - [Introduction to JSONForms](https://www.baeldung.com/introduction-to-jsonforms)
 - [Introduction to JsonPath](https://www.baeldung.com/guide-to-jayway-jsonpath)
 - [Introduction to JSON-Java (org.json)](https://www.baeldung.com/java-org-json)
@@ -14,3 +13,4 @@ This module contains articles about JSON.
 - [Iterating Over an Instance of org.json.JSONObject](https://www.baeldung.com/jsonobject-iteration)
 - [Escape JSON String in Java](https://www.baeldung.com/java-json-escaping)
 - [Reducing JSON Data Size](https://www.baeldung.com/json-reduce-data-size)
+- More Articles: [[next -->]](/json-2)
diff --git a/json/pom.xml b/json/pom.xml
index dfe42ee4c1..0d83f523b8 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -26,11 +26,6 @@
                 
             
         
-        
-            com.alibaba
-            fastjson
-            ${fastjson.version}
-        
         
             org.json
             json
@@ -72,7 +67,6 @@
 
     
         1.4.1
-        1.2.21
         1.0
         1.0.1
         20171018

From 5f97c1558f70bd5b7c97f5e43efb41d37afa4475 Mon Sep 17 00:00:00 2001
From: sampadawagde 
Date: Mon, 6 Dec 2021 22:24:37 +0530
Subject: [PATCH 342/551] JAVA-8375: Split or move core-java-regex module

---
 core-java-modules/core-java-regex-2/README.md                   | 2 ++
 .../main/java/com/baeldung/replacetokens/ReplacingTokens.java   | 0
 .../com/baeldung/replacetokens/ReplacingTokensUnitTest.java     | 0
 core-java-modules/core-java-regex/README.md                     | 2 +-
 4 files changed, 3 insertions(+), 1 deletion(-)
 rename core-java-modules/{core-java-regex => core-java-regex-2}/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java (100%)
 rename core-java-modules/{core-java-regex => core-java-regex-2}/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java (100%)

diff --git a/core-java-modules/core-java-regex-2/README.md b/core-java-modules/core-java-regex-2/README.md
index 25656c3cb1..6dafc74d41 100644
--- a/core-java-modules/core-java-regex-2/README.md
+++ b/core-java-modules/core-java-regex-2/README.md
@@ -3,3 +3,5 @@
 - [Non-Capturing Regex Groups in Java](https://www.baeldung.com/java-regex-non-capturing-groups)
 - [Lookahead and Lookbehind in Java Regex](https://www.baeldung.com/java-regex-lookahead-lookbehind)
 - [Converting Camel Case and Title Case to Words in Java](https://www.baeldung.com/java-camel-case-title-case-to-words)
+- [How to Use Regular Expressions to Replace Tokens in Strings in Java](https://www.baeldung.com/java-regex-token-replacement)
+- More articles: [[<-- prev]](/core-java-modules/core-java-regex)
\ No newline at end of file
diff --git a/core-java-modules/core-java-regex/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java b/core-java-modules/core-java-regex-2/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java
similarity index 100%
rename from core-java-modules/core-java-regex/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java
rename to core-java-modules/core-java-regex-2/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java
diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-regex/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java
rename to core-java-modules/core-java-regex-2/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java
diff --git a/core-java-modules/core-java-regex/README.md b/core-java-modules/core-java-regex/README.md
index 4c78f64d75..51c04af6ba 100644
--- a/core-java-modules/core-java-regex/README.md
+++ b/core-java-modules/core-java-regex/README.md
@@ -9,9 +9,9 @@
 - [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char)
 - [Pre-compile Regex Patterns Into Pattern Objects](https://www.baeldung.com/java-regex-pre-compile)
 - [Difference Between Java Matcher find() and matches()](https://www.baeldung.com/java-matcher-find-vs-matches)
-- [How to Use Regular Expressions to Replace Tokens in Strings in Java](https://www.baeldung.com/java-regex-token-replacement)
 - [Regular Expressions \s and \s+ in Java](https://www.baeldung.com/java-regex-s-splus)
 - [Validate Phone Numbers With Java Regex](https://www.baeldung.com/java-regex-validate-phone-numbers)
 - [How to Count the Number of Matches for a Regex?](https://www.baeldung.com/java-count-regex-matches)
 - [Find All Numbers in a String in Java](https://www.baeldung.com/java-find-numbers-in-string)
 - [Understanding the Pattern.quote Method](https://www.baeldung.com/java-pattern-quote)
+- More articles: [[next -->]](/core-java-modules/core-java-regex-2)

From 5c9e48a10f6c3e6136906053610d695e3a4ccee9 Mon Sep 17 00:00:00 2001
From: Olsi Seferi <72546616+olsiseferi@users.noreply.github.com>
Date: Mon, 6 Dec 2021 20:05:13 +0100
Subject: [PATCH 343/551] ExcelUtility Jira issue BAEL-5198 (#11559)

* CODE REFACTOR AND ADDED UNIT TEST

* SMALL CHANGE

* FIXED TESTS TIMEZONE ISSUES

* UPDATED FORMATTING

Co-authored-by: Olsi Seferi 
---
 .../com/baeldung/poi/excel/ExcelUtility.java  | 103 +++++++-------
 .../baeldung/poi/excel/ExcelUtility.java.orig | 128 ++++++++++++++++++
 .../poi/excel/ExcelUtilityUnitTest.java       |  82 ++++++-----
 .../poi/excel/ExcelUtilityUnitTest.java.orig  | 112 +++++++++++++++
 4 files changed, 346 insertions(+), 79 deletions(-)
 create mode 100644 apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java.orig
 create mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java.orig

diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java
index e4a5b791c9..50bbfbbe3c 100644
--- a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java
+++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java
@@ -13,54 +13,63 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 public class ExcelUtility {
-	private static final String ENDLINE = System.getProperty("line.separator");
+    private static final String ENDLINE = System.getProperty("line.separator");
 
-	public static String readExcel(String filePath) throws IOException {
-		File file = new File(filePath);
-		FileInputStream inputStream = null;
-		StringBuilder toReturn = new StringBuilder();
-		try {
-			inputStream = new FileInputStream(file);
-			Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
-			for (Sheet sheet : baeuldungWorkBook) {
-				toReturn.append("--------------------------------------------------------------------").append(ENDLINE);
-				toReturn.append("Worksheet :").append(sheet.getSheetName()).append(ENDLINE);
-				toReturn.append("--------------------------------------------------------------------").append(ENDLINE);
-				int firstRow = sheet.getFirstRowNum();
-				int lastRow = sheet.getLastRowNum();
-				for (int index = firstRow + 1; index <= lastRow; index++) {
-					Row row = sheet.getRow(index);
-					toReturn.append("|| ");
-					for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
-						Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
-						printCellValue(cell, toReturn);
-					}
-					toReturn.append(" ||").append(ENDLINE);
-				}
-			}
-			inputStream.close();
+    public static String readExcel(String filePath) throws IOException {
+        File file = new File(filePath);
+        FileInputStream inputStream = null;
+        StringBuilder toReturn = new StringBuilder();
+        try {
+            inputStream = new FileInputStream(file);
+            Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
+            for (Sheet sheet : baeuldungWorkBook) {
+                toReturn.append("--------------------------------------------------------------------")
+                    .append(ENDLINE);
+                toReturn.append("Worksheet :")
+                    .append(sheet.getSheetName())
+                    .append(ENDLINE);
+                toReturn.append("--------------------------------------------------------------------")
+                    .append(ENDLINE);
+                int firstRow = sheet.getFirstRowNum();
+                int lastRow = sheet.getLastRowNum();
+                for (int index = firstRow + 1; index <= lastRow; index++) {
+                    Row row = sheet.getRow(index);
+                    toReturn.append("|| ");
+                    for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
+                        Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+                        printCellValue(cell, toReturn);
+                    }
+                    toReturn.append(" ||")
+                        .append(ENDLINE);
+                }
+            }
+            inputStream.close();
 
-		} catch (IOException e) {
-			throw e;
-		}
-		return toReturn.toString();
-	}
+        } catch (IOException e) {
+            throw e;
+        }
+        return toReturn.toString();
+    }
 
-	public static void printCellValue(Cell cell, StringBuilder toReturn) {
-		CellType cellType = cell.getCellType().equals(CellType.FORMULA) ? cell.getCachedFormulaResultType()
-				: cell.getCellType();
-		if (cellType.equals(CellType.STRING)) {
-			toReturn.append(cell.getStringCellValue()).append(" | ");
-		}
-		if (cellType.equals(CellType.NUMERIC)) {
-			if (DateUtil.isCellDateFormatted(cell)) {
-				toReturn.append(cell.getDateCellValue()).append(" | ");
-			} else {
-				toReturn.append(cell.getNumericCellValue()).append(" | ");
-			}
-		}
-		if (cellType.equals(CellType.BOOLEAN)) {
-			toReturn.append(cell.getBooleanCellValue()).append(" | ");
-		}
-	}
+    public static void printCellValue(Cell cell, StringBuilder toReturn) {
+        CellType cellType = cell.getCellType()
+            .equals(CellType.FORMULA) ? cell.getCachedFormulaResultType() : cell.getCellType();
+        if (cellType.equals(CellType.STRING)) {
+            toReturn.append(cell.getStringCellValue())
+                .append(" | ");
+        }
+        if (cellType.equals(CellType.NUMERIC)) {
+            if (DateUtil.isCellDateFormatted(cell)) {
+                toReturn.append(cell.getDateCellValue())
+                    .append(" | ");
+            } else {
+                toReturn.append(cell.getNumericCellValue())
+                    .append(" | ");
+            }
+        }
+        if (cellType.equals(CellType.BOOLEAN)) {
+            toReturn.append(cell.getBooleanCellValue())
+                .append(" | ");
+        }
+    }
 }
\ No newline at end of file
diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java.orig b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java.orig
new file mode 100644
index 0000000000..c058f3abcf
--- /dev/null
+++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java.orig
@@ -0,0 +1,128 @@
+package com.baeldung.poi.excel;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+public class ExcelUtility {
+<<<<<<< HEAD
+    private static final String ENDLINE = System.getProperty("line.separator");
+
+    public static String readExcel(String filePath) throws IOException {
+        File file = new File(filePath);
+        FileInputStream inputStream = null;
+        StringBuilder toReturn = new StringBuilder();
+        try {
+            inputStream = new FileInputStream(file);
+            Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
+            for (Sheet sheet : baeuldungWorkBook) {
+                toReturn.append("--------------------------------------------------------------------")
+                    .append(ENDLINE);
+                toReturn.append("Worksheet :")
+                    .append(sheet.getSheetName())
+                    .append(ENDLINE);
+                toReturn.append("--------------------------------------------------------------------")
+                    .append(ENDLINE);
+                int firstRow = sheet.getFirstRowNum();
+                int lastRow = sheet.getLastRowNum();
+                for (int index = firstRow + 1; index <= lastRow; index++) {
+                    Row row = sheet.getRow(index);
+                    toReturn.append("|| ");
+                    for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
+                        Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+                        printCellValue(cell, toReturn);
+                    }
+                    toReturn.append(" ||")
+                        .append(ENDLINE);
+                }
+            }
+            inputStream.close();
+
+        } catch (IOException e) {
+            throw e;
+        }
+        return toReturn.toString();
+    }
+
+    public static void printCellValue(Cell cell, StringBuilder toReturn) {
+        CellType cellType = cell.getCellType()
+            .equals(CellType.FORMULA) ? cell.getCachedFormulaResultType() : cell.getCellType();
+        if (cellType.equals(CellType.STRING)) {
+            toReturn.append(cell.getStringCellValue())
+                .append(" | ");
+        }
+        if (cellType.equals(CellType.NUMERIC)) {
+            if (DateUtil.isCellDateFormatted(cell)) {
+                toReturn.append(cell.getDateCellValue())
+                    .append(" | ");
+            } else {
+                toReturn.append(cell.getNumericCellValue())
+                    .append(" | ");
+            }
+        }
+        if (cellType.equals(CellType.BOOLEAN)) {
+            toReturn.append(cell.getBooleanCellValue())
+                .append(" | ");
+        }
+    }
+=======
+	private static final String ENDLINE = System.getProperty("line.separator");
+
+	public static String readExcel(String filePath) throws IOException {
+		File file = new File(filePath);
+		FileInputStream inputStream = null;
+		StringBuilder toReturn = new StringBuilder();
+		try {
+			inputStream = new FileInputStream(file);
+			Workbook baeuldungWorkBook = new XSSFWorkbook(inputStream);
+			for (Sheet sheet : baeuldungWorkBook) {
+				toReturn.append("--------------------------------------------------------------------").append(ENDLINE);
+				toReturn.append("Worksheet :").append(sheet.getSheetName()).append(ENDLINE);
+				toReturn.append("--------------------------------------------------------------------").append(ENDLINE);
+				int firstRow = sheet.getFirstRowNum();
+				int lastRow = sheet.getLastRowNum();
+				for (int index = firstRow + 1; index <= lastRow; index++) {
+					Row row = sheet.getRow(index);
+					toReturn.append("|| ");
+					for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
+						Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+						printCellValue(cell, toReturn);
+					}
+					toReturn.append(" ||").append(ENDLINE);
+				}
+			}
+			inputStream.close();
+
+		} catch (IOException e) {
+			throw e;
+		}
+		return toReturn.toString();
+	}
+
+	public static void printCellValue(Cell cell, StringBuilder toReturn) {
+		CellType cellType = cell.getCellType().equals(CellType.FORMULA) ? cell.getCachedFormulaResultType()
+				: cell.getCellType();
+		if (cellType.equals(CellType.STRING)) {
+			toReturn.append(cell.getStringCellValue()).append(" | ");
+		}
+		if (cellType.equals(CellType.NUMERIC)) {
+			if (DateUtil.isCellDateFormatted(cell)) {
+				toReturn.append(cell.getDateCellValue()).append(" | ");
+			} else {
+				toReturn.append(cell.getNumericCellValue()).append(" | ");
+			}
+		}
+		if (cellType.equals(CellType.BOOLEAN)) {
+			toReturn.append(cell.getBooleanCellValue()).append(" | ");
+		}
+	}
+>>>>>>> master
+}
\ No newline at end of file
diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java
index 6638d77066..b4d3fdd732 100644
--- a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java
+++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java
@@ -13,42 +13,60 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class ExcelUtilityUnitTest {
-	private static final String FILE_NAME = "baeldung.xlsx";
-	private String fileLocation;
-	private static final String ENDLINE = System.getProperty("line.separator");
-	private StringBuilder output;
+    private static final String FILE_NAME = "baeldung.xlsx";
+    private String fileLocation;
+    private static final String ENDLINE = System.getProperty("line.separator");
+    private StringBuilder output;
 
-	@Before
-	public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
-		output = new StringBuilder();
-		output.append("--------------------------------------------------------------------").append(ENDLINE);
-		output.append("Worksheet :Sheet1").append(ENDLINE);
-		output.append("--------------------------------------------------------------------").append(ENDLINE);
-		output.append("|| Name1 | Surname1 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | ‡ |  ||")
-				.append(ENDLINE);
-		output.append("|| Name2 | Surname2 | 5.646513512E9 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021").toString()).append(" | false |  ||")
-				.append(ENDLINE);
-		output.append("|| Name3 | Surname3 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | 7.17039641738E11 |  ||")
-				.append(ENDLINE);
-		output.append("--------------------------------------------------------------------").append(ENDLINE);
-		output.append("Worksheet :Sheet2").append(ENDLINE);
-		output.append("--------------------------------------------------------------------").append(ENDLINE);
-		output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 |  ||").append(ENDLINE);
+    @Before
+    public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
+        output = new StringBuilder();
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("Worksheet :Sheet1")
+            .append(ENDLINE);
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("|| Name1 | Surname1 | 3.55696564113E11 | ")
+            .append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
+                .toString())
+            .append(" | ‡ |  ||")
+            .append(ENDLINE);
+        output.append("|| Name2 | Surname2 | 5.646513512E9 | ")
+            .append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021")
+                .toString())
+            .append(" | false |  ||")
+            .append(ENDLINE);
+        output.append("|| Name3 | Surname3 | 3.55696564113E11 | ")
+            .append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
+                .toString())
+            .append(" | 7.17039641738E11 |  ||")
+            .append(ENDLINE);
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("Worksheet :Sheet2")
+            .append(ENDLINE);
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 |  ||")
+            .append(ENDLINE);
 
-		fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
-	}
+        fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME)
+            .toURI())
+            .toString();
+    }
 
-	@Test
-	public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
-		assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
+    @Test
+    public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
+        assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
 
-	}
+    }
 
-	@Test
-	public void givenStringPath_whenReadExcel_thenThrowException() {
-		assertThrows(IOException.class, () -> {
-			ExcelUtility.readExcel("baeldung");
-		});
-	}
+    @Test
+    public void givenStringPath_whenReadExcel_thenThrowException() {
+        assertThrows(IOException.class, () -> {
+            ExcelUtility.readExcel("baeldung");
+        });
+    }
 
 }
diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java.orig b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java.orig
new file mode 100644
index 0000000000..cfc3062b5a
--- /dev/null
+++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelUtilityUnitTest.java.orig
@@ -0,0 +1,112 @@
+package com.baeldung.poi.excel;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ExcelUtilityUnitTest {
+<<<<<<< HEAD
+    private static final String FILE_NAME = "baeldung.xlsx";
+    private String fileLocation;
+    private static final String ENDLINE = System.getProperty("line.separator");
+    private StringBuilder output;
+
+    @Before
+    public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
+        output = new StringBuilder();
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("Worksheet :Sheet1")
+            .append(ENDLINE);
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("|| Name1 | Surname1 | 3.55696564113E11 | ")
+            .append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
+                .toString())
+            .append(" | ‡ |  ||")
+            .append(ENDLINE);
+        output.append("|| Name2 | Surname2 | 5.646513512E9 | ")
+            .append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021")
+                .toString())
+            .append(" | false |  ||")
+            .append(ENDLINE);
+        output.append("|| Name3 | Surname3 | 3.55696564113E11 | ")
+            .append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021")
+                .toString())
+            .append(" | 7.17039641738E11 |  ||")
+            .append(ENDLINE);
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("Worksheet :Sheet2")
+            .append(ENDLINE);
+        output.append("--------------------------------------------------------------------")
+            .append(ENDLINE);
+        output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 |  ||")
+            .append(ENDLINE);
+
+        fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME)
+            .toURI())
+            .toString();
+    }
+
+    @Test
+    public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
+        assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
+
+    }
+
+    @Test
+    public void givenStringPath_whenReadExcel_thenThrowException() {
+        assertThrows(IOException.class, () -> {
+            ExcelUtility.readExcel("baeldung");
+        });
+    }
+=======
+	private static final String FILE_NAME = "baeldung.xlsx";
+	private String fileLocation;
+	private static final String ENDLINE = System.getProperty("line.separator");
+	private StringBuilder output;
+
+	@Before
+	public void setupUnitTest() throws IOException, URISyntaxException, ParseException {
+		output = new StringBuilder();
+		output.append("--------------------------------------------------------------------").append(ENDLINE);
+		output.append("Worksheet :Sheet1").append(ENDLINE);
+		output.append("--------------------------------------------------------------------").append(ENDLINE);
+		output.append("|| Name1 | Surname1 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | ‡ |  ||")
+				.append(ENDLINE);
+		output.append("|| Name2 | Surname2 | 5.646513512E9 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/12/2021").toString()).append(" | false |  ||")
+				.append(ENDLINE);
+		output.append("|| Name3 | Surname3 | 3.55696564113E11 | ").append(new SimpleDateFormat("dd/MM/yyyy").parse("4/11/2021").toString()).append(" | 7.17039641738E11 |  ||")
+				.append(ENDLINE);
+		output.append("--------------------------------------------------------------------").append(ENDLINE);
+		output.append("Worksheet :Sheet2").append(ENDLINE);
+		output.append("--------------------------------------------------------------------").append(ENDLINE);
+		output.append("|| Name4 | Surname4 | 3.55675623232E11 | 13/04/2021 |  ||").append(ENDLINE);
+
+		fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString();
+	}
+
+	@Test
+	public void givenStringPath_whenReadExcel_thenReturnStringValue() throws IOException {
+		assertEquals(output.toString(), ExcelUtility.readExcel(fileLocation));
+
+	}
+
+	@Test
+	public void givenStringPath_whenReadExcel_thenThrowException() {
+		assertThrows(IOException.class, () -> {
+			ExcelUtility.readExcel("baeldung");
+		});
+	}
+>>>>>>> master
+
+}

From 1862d8cce24fea1ca3a89d5b638e489380a8c1fd Mon Sep 17 00:00:00 2001
From: anuragkumawat 
Date: Tue, 7 Dec 2021 16:05:59 +0530
Subject: [PATCH 344/551] Adding spring-web-url

---
 .../spring-mvc-basics-3/README.md             |   3 -
 spring-web-modules/spring-web-url/README.md   |   8 +
 spring-web-modules/spring-web-url/pom.xml     | 138 ++++++++++++++++++
 .../exclude_urls_filter/Application.java      |  17 +++
 .../controller/FAQController.java             |  32 ++++
 .../exclude_urls_filter/controller/Ping.java  |  22 +++
 .../filter/FilterRegistrationConfig.java      |  26 ++++
 .../filter/HeaderValidatorFilter.java         |  33 +++++
 .../exclude_urls_filter/filter/LogFilter.java |  25 ++++
 .../service/FAQService.java                   |   5 +
 .../service/FAQServiceImpl.java               |  15 ++
 .../baeldung/form_submission/Application.java |  14 ++
 .../controllers/FeedbackForm.java             |  42 ++++++
 .../form_submission/model/Feedback.java       |  23 +++
 .../src/main/resources/application.properties |   7 +
 .../main/resources/templates/feedback.html    |  41 ++++++
 .../slash/SlashParsingControllerIntTest.java  |  87 +++++++++++
 17 files changed, 535 insertions(+), 3 deletions(-)
 create mode 100644 spring-web-modules/spring-web-url/README.md
 create mode 100644 spring-web-modules/spring-web-url/pom.xml
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/Application.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/Application.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/model/Feedback.java
 create mode 100644 spring-web-modules/spring-web-url/src/main/resources/application.properties
 create mode 100644 spring-web-modules/spring-web-url/src/main/resources/templates/feedback.html
 create mode 100644 spring-web-modules/spring-web-url/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java

diff --git a/spring-web-modules/spring-mvc-basics-3/README.md b/spring-web-modules/spring-mvc-basics-3/README.md
index 074c60152c..86c26d8a60 100644
--- a/spring-web-modules/spring-mvc-basics-3/README.md
+++ b/spring-web-modules/spring-mvc-basics-3/README.md
@@ -7,10 +7,7 @@ This module contains articles about Spring MVC
 - [A Custom Data Binder in Spring MVC](https://www.baeldung.com/spring-mvc-custom-data-binder)
 - [Validating Lists in a Spring Controller](https://www.baeldung.com/spring-validate-list-controller)
 - [Spring Validation Message Interpolation](https://www.baeldung.com/spring-validation-message-interpolation)
-- [Using a Slash Character in Spring URLs](https://www.baeldung.com/spring-slash-character-in-url)
 - [Using Enums as Request Parameters in Spring](https://www.baeldung.com/spring-enum-request-param)
-- [Excluding URLs for a Filter in a Spring Web Application](https://www.baeldung.com/spring-exclude-filter)
 - [Guide to Flash Attributes in a Spring Web Application](https://www.baeldung.com/spring-web-flash-attributes)
-- [Handling URL Encoded Form Data in Spring REST](https://www.baeldung.com/spring-url-encoded-form-data)
 - [Reading HttpServletRequest Multiple Times in Spring](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times)
 - More articles: [[<-- prev]](/spring-mvc-basics-2)[[more -->]](/spring-mvc-basics-4)
diff --git a/spring-web-modules/spring-web-url/README.md b/spring-web-modules/spring-web-url/README.md
new file mode 100644
index 0000000000..41b479337b
--- /dev/null
+++ b/spring-web-modules/spring-web-url/README.md
@@ -0,0 +1,8 @@
+## Spring Web URL
+
+This module contains articles about Spring MVC
+
+## Relevant articles:
+- [Using a Slash Character in Spring URLs](https://www.baeldung.com/spring-slash-character-in-url)
+- [Excluding URLs for a Filter in a Spring Web Application](https://www.baeldung.com/spring-exclude-filter)
+- [Handling URL Encoded Form Data in Spring REST](https://www.baeldung.com/spring-url-encoded-form-data)
diff --git a/spring-web-modules/spring-web-url/pom.xml b/spring-web-modules/spring-web-url/pom.xml
new file mode 100644
index 0000000000..0a10afad08
--- /dev/null
+++ b/spring-web-modules/spring-web-url/pom.xml
@@ -0,0 +1,138 @@
+
+
+    4.0.0
+    spring-web-url
+    spring-web-url
+    war
+    Demo project for Spring Boot
+
+    
+        com.baeldung
+        parent-boot-2
+        0.0.1-SNAPSHOT
+        ../../parent-boot-2
+    
+
+    
+        
+            org.springframework.boot
+            spring-boot-starter-web
+        
+        
+            org.springframework.boot
+            spring-boot-starter-validation
+        
+        
+            org.springframework.boot
+            spring-boot-starter-test
+            test
+        
+        
+            org.springframework.boot
+            spring-boot-starter-thymeleaf
+            provided
+        
+        
+            org.springframework.boot
+            spring-boot-starter-data-jpa
+        
+        
+            org.springframework.boot
+            spring-boot-starter-mail
+        
+        
+            org.springframework.boot
+            spring-boot-starter-actuator
+        
+        
+            com.h2database
+            h2
+            runtime
+        
+        
+            javax.persistence
+            javax.persistence-api
+            ${jpa.version}
+        
+        
+            com.google.guava
+            guava
+            ${guava.version}
+        
+        
+            org.subethamail
+            subethasmtp
+            ${subethasmtp.version}
+            test
+        
+        
+            org.apache.httpcomponents
+            httpclient
+            ${httpclient.version}
+        
+    
+
+    
+        ${project.artifactId}
+        
+            
+                src/main/resources
+                true
+                
+                    **/conf.properties
+                
+            
+        
+    
+
+    
+        
+            autoconfiguration
+            
+                
+                    
+                        org.apache.maven.plugins
+                        maven-surefire-plugin
+                        
+                            
+                                integration-test
+                                
+                                    test
+                                
+                                
+                                    
+                                        **/*LiveTest.java
+                                        **/*IntegrationTest.java
+                                        **/*IntTest.java
+                                    
+                                    
+                                        **/AutoconfigurationTest.java
+                                    
+                                
+                            
+                        
+                        
+                            
+                                json
+                            
+                        
+                    
+                
+            
+        
+    
+
+    
+        
+        com.baeldung.exclude_urls_filter.Application
+        3.1.1
+        3.3.7-1
+        2.2
+        18.0
+        3.1.7
+        4.5.8
+    
+
+
\ No newline at end of file
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/Application.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/Application.java
new file mode 100644
index 0000000000..4fb6938694
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/Application.java
@@ -0,0 +1,17 @@
+package com.baeldung.exclude_urls_filter;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@ComponentScan(basePackages = "com.baeldung.exclude_urls_filter")
+@Configuration
+@SpringBootApplication
+public class Application {
+
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+
+}
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java
new file mode 100644
index 0000000000..1463af6bfd
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java
@@ -0,0 +1,32 @@
+package com.baeldung.exclude_urls_filter.controller;
+
+import com.baeldung.exclude_urls_filter.service.FAQService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class FAQController {
+
+    private final FAQService faqService;
+
+    @Autowired
+    public FAQController(FAQService faqService) {
+        this.faqService = faqService;
+    }
+
+    @RequestMapping(value = "/faq/helpline", method = RequestMethod.GET)
+    public ResponseEntity getHelpLineNumber() {
+        String helplineNumber = faqService.getHelpLineNumber();
+        if (helplineNumber != null) {
+            return new ResponseEntity(helplineNumber, HttpStatus.OK);
+        } else {
+            return new ResponseEntity("Unavailable", HttpStatus.NOT_FOUND);
+        }
+    }
+
+
+}
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java
new file mode 100644
index 0000000000..c8a0723ba6
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java
@@ -0,0 +1,22 @@
+package com.baeldung.exclude_urls_filter.controller;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class Ping {
+
+    @RequestMapping(value = "/health", method = RequestMethod.GET)
+    public ResponseEntity pingGet() {
+        return new ResponseEntity("pong", HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/health", method = RequestMethod.POST)
+    public ResponseEntity pingPost() {
+        return new ResponseEntity("pong", HttpStatus.OK);
+    }
+
+}
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java
new file mode 100644
index 0000000000..ff99b4cc25
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java
@@ -0,0 +1,26 @@
+package com.baeldung.exclude_urls_filter.filter;
+
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class FilterRegistrationConfig {
+
+    @Bean
+    public FilterRegistrationBean logFilter() {
+        FilterRegistrationBean registrationBean = new FilterRegistrationBean<>();
+        registrationBean.setFilter(new LogFilter());
+        registrationBean.addUrlPatterns("/health", "/faq/*");
+        return registrationBean;
+    }
+
+
+    @Bean
+    public FilterRegistrationBean headerValidatorFilter() {
+        FilterRegistrationBean registrationBean = new FilterRegistrationBean<>();
+        registrationBean.setFilter(new HeaderValidatorFilter());
+        registrationBean.addUrlPatterns("*");
+        return registrationBean;
+    }
+}
\ No newline at end of file
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java
new file mode 100644
index 0000000000..d6c1777326
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java
@@ -0,0 +1,33 @@
+package com.baeldung.exclude_urls_filter.filter;
+
+import org.springframework.core.annotation.Order;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Order(1)
+public class HeaderValidatorFilter extends OncePerRequestFilter {
+    @Override
+    protected void doFilterInternal(HttpServletRequest request,
+      HttpServletResponse response,
+      FilterChain filterChain)
+      throws ServletException,
+      IOException {
+        String countryCode = request.getHeader("X-Country-Code");
+        if (!"US".equals(countryCode)) {
+            response.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid Locale");
+            return;
+        }
+        filterChain.doFilter(request, response);
+    }
+
+    @Override
+    protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
+        String path = request.getRequestURI();
+        return "/health".equals(path);
+    }
+}
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java
new file mode 100644
index 0000000000..fcde4f7f8f
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java
@@ -0,0 +1,25 @@
+package com.baeldung.exclude_urls_filter.filter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Order(1)
+public class LogFilter extends OncePerRequestFilter {
+    private final Logger logger = LoggerFactory.getLogger(LogFilter.class);
+
+    @Override
+    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
+      FilterChain filterChain) throws ServletException, IOException {
+        String path = request.getRequestURI();
+        String contentType = request.getContentType();
+        logger.info("Request URL path : {}, Request content type: {}", path, contentType);
+        filterChain.doFilter(request, response);
+    }
+}
\ No newline at end of file
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java
new file mode 100644
index 0000000000..a2949ea0a2
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java
@@ -0,0 +1,5 @@
+package com.baeldung.exclude_urls_filter.service;
+
+public interface FAQService {
+    String getHelpLineNumber();
+}
\ No newline at end of file
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java
new file mode 100644
index 0000000000..6f841e4ec1
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java
@@ -0,0 +1,15 @@
+package com.baeldung.exclude_urls_filter.service;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class FAQServiceImpl implements FAQService {
+
+    private static final String HELPLINE_NUMBER = "+1 888-777-66";
+
+    @Override
+    public String getHelpLineNumber() {
+        return HELPLINE_NUMBER;
+    }
+
+}
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/Application.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/Application.java
new file mode 100644
index 0000000000..34c14141b0
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/Application.java
@@ -0,0 +1,14 @@
+package com.baeldung.form_submission;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer {
+
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+
+}
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java
new file mode 100644
index 0000000000..791fc75cef
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java
@@ -0,0 +1,42 @@
+package com.baeldung.form_submission.controllers;
+
+import com.baeldung.form_submission.model.Feedback;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.*;
+
+@Controller
+public class FeedbackForm {
+
+    @GetMapping(path = "/feedback")
+    public String getFeedbackForm(Model model) {
+        Feedback feedback = new Feedback();
+        model.addAttribute("feedback", feedback);
+        return "feedback";
+    }
+
+    @PostMapping(
+      path = "/web/feedback",
+      consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
+    public String handleBrowserSubmissions(Feedback feedback) throws Exception {
+        // Save feedback data
+        return "redirect:/feedback/success";
+    }
+
+    @GetMapping("/feedback/success")
+    public ResponseEntity getSuccess() {
+        return new ResponseEntity("Thank you for submitting feedback.", HttpStatus.OK);
+    }
+
+    @PostMapping(
+      path = "/feedback",
+      consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
+    public ResponseEntity handleNonBrowserSubmissions(@RequestParam MultiValueMap paramMap) throws Exception {
+        // Save feedback data
+        return new ResponseEntity("Thank you for submitting feedback", HttpStatus.OK);
+    }
+}
\ No newline at end of file
diff --git a/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/model/Feedback.java b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/model/Feedback.java
new file mode 100644
index 0000000000..f8d416460c
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/java/com/baeldung/form_submission/model/Feedback.java
@@ -0,0 +1,23 @@
+package com.baeldung.form_submission.model;
+
+public class Feedback {
+    private String emailId;
+    private String comment;
+
+    public String getEmailId() {
+        return this.emailId;
+    }
+
+    public void setEmailId(String emailId) {
+        this.emailId = emailId;
+    }
+
+    public String getComment() {
+        return this.comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+}
diff --git a/spring-web-modules/spring-web-url/src/main/resources/application.properties b/spring-web-modules/spring-web-url/src/main/resources/application.properties
new file mode 100644
index 0000000000..fcdaabe007
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/resources/application.properties
@@ -0,0 +1,7 @@
+spring.mail.host=localhost
+spring.mail.port=8025
+
+spring.thymeleaf.cache=false
+spring.thymeleaf.enabled=true 
+spring.thymeleaf.prefix=classpath:/templates/
+spring.thymeleaf.suffix=.html
diff --git a/spring-web-modules/spring-web-url/src/main/resources/templates/feedback.html b/spring-web-modules/spring-web-url/src/main/resources/templates/feedback.html
new file mode 100644
index 0000000000..4b6a487fc2
--- /dev/null
+++ b/spring-web-modules/spring-web-url/src/main/resources/templates/feedback.html
@@ -0,0 +1,41 @@
+
+
+
+    Poetry Contest: Submission
+
+
+
+
+ + + + + + + + + + +
+ + + +
+ + +