Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependencies #77

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ plugins {
id 'org.sonarqube' version '5.1.0.4882'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'org.springframework.boot' version '3.3.4' apply false
id 'org.owasp.dependencycheck' version '10.0.4' apply false
id 'co.com.bancolombia.cleanArchitecture' version '3.17.26'
id 'org.springframework.boot' version '3.3.5' apply false
id 'org.owasp.dependencycheck' version '11.1.0' apply false
id 'co.com.bancolombia.cleanArchitecture' version '3.18.1'
}

apply from: './main.gradle'
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package co.com.bancolombia.commons.jms.api;

import co.com.bancolombia.commons.jms.api.exceptions.InvalidUsageException;
import jakarta.jms.Destination;
import reactor.core.publisher.Mono;

import java.time.Duration;
Expand All @@ -12,4 +14,12 @@ public interface MQRequestReplyBase<T> {
Mono<T> requestReply(MQMessageCreator messageCreator);

Mono<T> requestReply(MQMessageCreator messageCreator, Duration timeout);

default Mono<T> requestReply(String message, Destination request, Destination reply, Duration timeout) {
return Mono.error(() -> new InvalidUsageException("This method is not supported"));
} // For fixed queues only

default Mono<T> requestReply(MQMessageCreator messageCreator, Destination request, Destination reply, Duration timeout) {
return Mono.error(() -> new InvalidUsageException("This method is not supported"));
} // For fixed queues only
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.com.bancolombia.commons.jms.api.exceptions;

public class InvalidUsageException extends RuntimeException {

public InvalidUsageException(String message) {
super(message);
}
}
8 changes: 4 additions & 4 deletions commons-jms-mq/commons-jms-mq.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
dependencies {
api project(':commons-jms-utils')
api 'com.ibm.mq:mq-jms-spring-boot-starter:3.3.3'
api 'com.ibm.mq:mq-jms-spring-boot-starter:3.3.5'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
implementation 'org.springframework.boot:spring-boot-actuator'
}

configurations.configureEach {
resolutionStrategy {
force 'org.json:json:20240303' // to avoid CVE-2023-5072
force 'org.bouncycastle:bcprov-jdk18on:1.78.1'
force 'org.bouncycastle:bcpkix-jdk18on:1.78.1'
force 'org.bouncycastle:bcutil-jdk18on:1.78.1'
force 'org.bouncycastle:bcprov-jdk18on:1.79'
force 'org.bouncycastle:bcpkix-jdk18on:1.79'
force 'org.bouncycastle:bcutil-jdk18on:1.79'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public Mono<Message> requestReply(String message, Destination request, Destinati
.flatMap(id -> listener.getMessageBySelector(selector.buildSelector(id), timeout.toMillis(), reply));
}

public Mono<Message> requestReply(MQMessageCreator messageCreator, Destination request, Destination reply, Duration timeout) {
return sender.send(request, messageCreator)
.flatMap(id -> listener.getMessageBySelector(selector.buildSelector(id), timeout.toMillis(), reply));
}

private MQMessageCreator defaultCreator(String message) {
return ctx -> {
Message jmsMessage = ctx.createTextMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.com.bancolombia.commons.jms.api.MQMessageCreator;
import co.com.bancolombia.commons.jms.api.MQMessageSender;
import co.com.bancolombia.commons.jms.api.MQQueuesContainer;
import co.com.bancolombia.commons.jms.api.exceptions.InvalidUsageException;
import co.com.bancolombia.commons.jms.utils.MQQueuesContainerImp;
import co.com.bancolombia.commons.jms.utils.ReactiveReplyRouter;
import jakarta.jms.Destination;
Expand Down Expand Up @@ -100,4 +101,24 @@ void shouldNotFailWhenNoRelatedMessage() throws JMSException {
// Assert
}

@Test
void shouldFailWhenUsingFixedMethod() throws JMSException {
// Arrange
// Act
Mono<Message> flow = listener.requestReply(context1 -> message, destination, destination, Duration.ofSeconds(1));
// Assert
StepVerifier.create(flow)
.verifyError(InvalidUsageException.class);
}

@Test
void shouldFailWhenUsingFixedMethodStringMessage() throws JMSException {
// Arrange
// Act
Mono<Message> flow = listener.requestReply("message", destination, destination, Duration.ofSeconds(1));
// Assert
StepVerifier.create(flow)
.verifyError(InvalidUsageException.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class MQRequestReplySelectorTest {
@Mock
private Queue destination;
@Mock
private Queue replyDestination;
@Mock
private JMSContext context;
@Mock
private MQMessageSender sender;
Expand Down Expand Up @@ -74,6 +76,32 @@ void shouldSendAndGetReplyFromFixed() {
.verifyComplete();
}

@Test
void shouldSendAndGetReplyFromFixedWithSpecificQueuesFromStringMessage() {
// Arrange
when(sender.send(any(Destination.class), any(MQMessageCreator.class))).thenReturn(Mono.just("id"));
when(listener.getMessageBySelector(anyString(), anyLong(), any(Destination.class))).thenReturn(Mono.just(message));
// Act
Mono<Message> reply = reqReply.requestReply("MyMessage", destination, replyDestination, Duration.ofSeconds(1));
// Assert
StepVerifier.create(reply)
.assertNext(message1 -> assertEquals(message, message1))
.verifyComplete();
}

@Test
void shouldSendAndGetReplyFromFixedWithSpecificQueues() {
// Arrange
when(sender.send(any(Destination.class), any(MQMessageCreator.class))).thenReturn(Mono.just("id"));
when(listener.getMessageBySelector(anyString(), anyLong(), any(Destination.class))).thenReturn(Mono.just(message));
// Act
Mono<Message> reply = reqReply.requestReply(context -> message, destination, replyDestination, Duration.ofSeconds(1));
// Assert
StepVerifier.create(reply)
.assertNext(message1 -> assertEquals(message, message1))
.verifyComplete();
}

@Test
void shouldReplyWithTimeoutFromFixed() {
// Arrange
Expand Down
4 changes: 2 additions & 2 deletions main.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ subprojects {
testAnnotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testImplementation 'io.projectreactor:reactor-test'
testImplementation platform('org.junit:junit-bom:5.11.2')
testImplementation platform('org.junit:junit-bom:5.11.3')
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.1'
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.2'
}

test {
Expand Down