Skip to content

Commit

Permalink
updates for func tests (#3345)
Browse files Browse the repository at this point in the history
  • Loading branch information
amstevenson authored Oct 25, 2024
1 parent 543b593 commit 9476829
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
/bin/create-env-file.sh
/bin/setup-env.sh
/bin/substitutions.json
/bin/setup-azurite.sh
/bin/setup-sftp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void sendProcessedEnvelopeMessage(UUID envelopeId, String ccdId, String c
}

public ConnectionFactory getTestFactory() {
String connection = String.format("amqp://localhost:%1s?amqp.idleTimeout=%2d", "5672", 30000);
String connection = "tcp://localhost:61616";
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(connection);
activeMQConnectionFactory.setUserName("admin");
activeMQConnectionFactory.setPassword("admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import static uk.gov.hmcts.reform.bulkscanprocessor.config.TestConfiguration.STORAGE_CONTAINER_NAME;
import static uk.gov.hmcts.reform.bulkscanprocessor.config.TestConfiguration.TEST_URL;

/**
* Use these tests when running locally.
* For AAT + upwards, run ProcessedEnvelopeMessageHandlingTest :- )
* Swap the @Disable according to what needs to be run.
*/
@Disabled
public class JmsProcessedEnvelopeMessageHandlingTest extends BaseFunctionalTest {

Expand Down Expand Up @@ -118,6 +123,4 @@ private String uploadEnvelope(List<String> documents, String fileName) {
private EnvelopeResponse getEnvelope(String zipFilename) {
return testHelper.getEnvelopeByContainerAndFileName(TEST_URL, STORAGE_CONTAINER_NAME, zipFilename);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import static uk.gov.hmcts.reform.bulkscanprocessor.config.TestConfiguration.STORAGE_CONTAINER_NAME;
import static uk.gov.hmcts.reform.bulkscanprocessor.config.TestConfiguration.TEST_URL;

/**
* If running locally (local machine), use the JmsProcessedEnvelopeHandlingTest.
*/
public class ProcessedEnvelopeMessageHandlingTest extends BaseFunctionalTest {

private static final long MESSAGE_PROCESSING_TIMEOUT_MILLIS = 60_000;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package uk.gov.hmcts.reform.bulkscanprocessor.config.jms;

import jakarta.jms.JMSException;
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.JmsListener;
import uk.gov.hmcts.reform.bulkscanprocessor.tasks.jms.JmsProcessedEnvelopeNotificationHandler;

import javax.jms.JMSException;
import javax.jms.Message;

/**
* JMS receivers configuration.
*/
Expand Down Expand Up @@ -37,8 +37,8 @@ public JmsReceivers(
* @throws JMSException JMSException
*/
@JmsListener(destination = "processed-envelopes", containerFactory = "processedEnvelopesQueueConnectionFactory")
public void receiveJmsMessage(Message message) throws JMSException {
String messageBody = ((javax.jms.TextMessage) message).getText();
public void receiveJmsMessage(ActiveMQMessage message) throws JMSException {
String messageBody = ((ActiveMQTextMessage) message).getText();
log.info("Received processed-envelopes message {}. Delivery count is: {}",
messageBody, message.getStringProperty("JMSXDeliveryCount")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.jms.JMSException;
import org.apache.activemq.command.ActiveMQMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
Expand All @@ -17,8 +19,6 @@

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import javax.jms.JMSException;
import javax.jms.Message;

/**
* Handler of messages form processed envelopes queue.
Expand Down Expand Up @@ -56,7 +56,7 @@ public JmsProcessedEnvelopeNotificationHandler(
* @param messageBody The message body
* @throws JMSException If an error occurs
*/
public void processMessage(Message messageContext, String messageBody) throws JMSException {
public void processMessage(ActiveMQMessage messageContext, String messageBody) throws JMSException {
//var message = messageContext.getMessage();
var processingResult = tryProcessMessage(messageContext, messageBody);
finaliseMessage(messageContext, processingResult);
Expand All @@ -77,7 +77,7 @@ public void processException(ServiceBusErrorContext context) {
* @throws JMSException If an error occurs
*/
private void finaliseMessage(
Message messageContext,
ActiveMQMessage messageContext,
MessageProcessingResult processingResult
) throws JMSException {
switch (processingResult.resultType) {
Expand Down Expand Up @@ -108,7 +108,7 @@ private void finaliseMessage(
* @return The processing result
* @throws JMSException If an error occurs
*/
private MessageProcessingResult tryProcessMessage(Message message, String messageBody) throws JMSException {
private MessageProcessingResult tryProcessMessage(ActiveMQMessage message, String messageBody) throws JMSException {
try {
log.info(
"Started processing 'processed envelope' message with ID {} (delivery {})",
Expand Down

0 comments on commit 9476829

Please sign in to comment.