Use Java text blocks for scripts in code
* Fix `WebServiceInboundGatewayParserTests` for reply timeout for replies which never come accoridn the test logic
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
* Copyright 2016-2023 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.
|
||||
@@ -78,22 +78,43 @@ public class DefaultLockRepository
|
||||
|
||||
private String region = "DEFAULT";
|
||||
|
||||
private String deleteQuery = "DELETE FROM %sLOCK WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=?";
|
||||
private String deleteQuery = """
|
||||
DELETE FROM %sLOCK
|
||||
WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=?
|
||||
""";
|
||||
|
||||
private String deleteExpiredQuery = "DELETE FROM %sLOCK WHERE REGION=? AND CREATED_DATE<?";
|
||||
private String deleteExpiredQuery = """
|
||||
DELETE FROM %sLOCK
|
||||
WHERE REGION=? AND CREATED_DATE<?
|
||||
""";
|
||||
|
||||
private String deleteAllQuery = "DELETE FROM %sLOCK WHERE REGION=? AND CLIENT_ID=?";
|
||||
private String deleteAllQuery = """
|
||||
DELETE FROM %sLOCK
|
||||
WHERE REGION=? AND CLIENT_ID=?
|
||||
""";
|
||||
|
||||
private String updateQuery =
|
||||
"UPDATE %sLOCK SET CLIENT_ID=?, CREATED_DATE=? WHERE REGION=? AND LOCK_KEY=? " +
|
||||
"AND (CLIENT_ID=? OR CREATED_DATE<?)";
|
||||
private String updateQuery = """
|
||||
UPDATE %sLOCK
|
||||
SET CLIENT_ID=?, CREATED_DATE=?
|
||||
WHERE REGION=? AND LOCK_KEY=? AND (CLIENT_ID=? OR CREATED_DATE<?)
|
||||
""";
|
||||
|
||||
private String insertQuery = "INSERT INTO %sLOCK (REGION, LOCK_KEY, CLIENT_ID, CREATED_DATE) VALUES (?, ?, ?, ?)";
|
||||
private String insertQuery = """
|
||||
INSERT INTO %sLOCK (REGION, LOCK_KEY, CLIENT_ID, CREATED_DATE)
|
||||
VALUES (?, ?, ?, ?)
|
||||
""";
|
||||
|
||||
private String countQuery =
|
||||
"SELECT COUNT(REGION) FROM %sLOCK WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=? AND CREATED_DATE>=?";
|
||||
private String countQuery = """
|
||||
SELECT COUNT(REGION)
|
||||
FROM %sLOCK
|
||||
WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=? AND CREATED_DATE>=?
|
||||
""";
|
||||
|
||||
private String renewQuery = "UPDATE %sLOCK SET CREATED_DATE=? WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=?";
|
||||
private String renewQuery = """
|
||||
UPDATE %sLOCK
|
||||
SET CREATED_DATE=?
|
||||
WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=?
|
||||
""";
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019 the original author or authors.
|
||||
* Copyright 2017-2023 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.
|
||||
@@ -58,22 +58,40 @@ public class JdbcMetadataStore implements ConcurrentMetadataStore, InitializingB
|
||||
|
||||
private String lockHint = "FOR UPDATE";
|
||||
|
||||
private String getValueQuery = "SELECT METADATA_VALUE FROM %sMETADATA_STORE WHERE METADATA_KEY=? AND REGION=?";
|
||||
private String getValueQuery = """
|
||||
SELECT METADATA_VALUE FROM %sMETADATA_STORE
|
||||
WHERE METADATA_KEY=? AND REGION=?
|
||||
""";
|
||||
|
||||
private String getValueForUpdateQuery =
|
||||
"SELECT METADATA_VALUE FROM %sMETADATA_STORE WHERE METADATA_KEY=? AND REGION=? %s";
|
||||
private String getValueForUpdateQuery = """
|
||||
SELECT METADATA_VALUE FROM %sMETADATA_STORE
|
||||
WHERE METADATA_KEY=? AND REGION=? %s
|
||||
""";
|
||||
|
||||
private String replaceValueQuery =
|
||||
"UPDATE %sMETADATA_STORE SET METADATA_VALUE=? WHERE METADATA_KEY=? AND METADATA_VALUE=? AND REGION=?";
|
||||
private String replaceValueQuery = """
|
||||
UPDATE %sMETADATA_STORE
|
||||
SET METADATA_VALUE=?
|
||||
WHERE METADATA_KEY=? AND METADATA_VALUE=? AND REGION=?
|
||||
""";
|
||||
|
||||
private String replaceValueByKeyQuery =
|
||||
"UPDATE %sMETADATA_STORE SET METADATA_VALUE=? WHERE METADATA_KEY=? AND REGION=?";
|
||||
private String replaceValueByKeyQuery = """
|
||||
UPDATE %sMETADATA_STORE
|
||||
SET METADATA_VALUE=?
|
||||
WHERE METADATA_KEY=? AND REGION=?
|
||||
""";
|
||||
|
||||
private String removeValueQuery = "DELETE FROM %sMETADATA_STORE WHERE METADATA_KEY=? AND REGION=?";
|
||||
private String removeValueQuery = """
|
||||
DELETE FROM %sMETADATA_STORE
|
||||
WHERE METADATA_KEY=? AND REGION=?
|
||||
""";
|
||||
|
||||
private String putIfAbsentValueQuery =
|
||||
"INSERT INTO %sMETADATA_STORE(METADATA_KEY, METADATA_VALUE, REGION) "
|
||||
+ "SELECT ?, ?, ? FROM %sMETADATA_STORE WHERE METADATA_KEY=? AND REGION=? HAVING COUNT(*)=0";
|
||||
private String putIfAbsentValueQuery = """
|
||||
INSERT INTO %sMETADATA_STORE(METADATA_KEY, METADATA_VALUE, REGION)
|
||||
SELECT ?, ?, ?
|
||||
FROM %sMETADATA_STORE
|
||||
WHERE METADATA_KEY=? AND REGION=?
|
||||
HAVING COUNT(*)=0
|
||||
""";
|
||||
|
||||
/**
|
||||
* Instantiate a {@link JdbcMetadataStore} using provided dataSource {@link DataSource}.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -85,72 +85,137 @@ public class JdbcMessageStore extends AbstractMessageGroupStore implements Messa
|
||||
public static final String DEFAULT_TABLE_PREFIX = "INT_";
|
||||
|
||||
private enum Query {
|
||||
CREATE_MESSAGE_GROUP("INSERT into %PREFIX%MESSAGE_GROUP" +
|
||||
"(GROUP_KEY, REGION, COMPLETE, LAST_RELEASED_SEQUENCE, CREATED_DATE, UPDATED_DATE)"
|
||||
+ " values (?, ?, 0, 0, ?, ?)"),
|
||||
CREATE_MESSAGE_GROUP("""
|
||||
INSERT into %PREFIX%MESSAGE_GROUP(
|
||||
GROUP_KEY, REGION, COMPLETE, LAST_RELEASED_SEQUENCE, CREATED_DATE, UPDATED_DATE)
|
||||
values (?, ?, 0, 0, ?, ?)
|
||||
"""),
|
||||
|
||||
UPDATE_MESSAGE_GROUP("UPDATE %PREFIX%MESSAGE_GROUP set UPDATED_DATE=?, GROUP_CONDITION=? " +
|
||||
"where GROUP_KEY=? and REGION=?"),
|
||||
UPDATE_MESSAGE_GROUP("""
|
||||
UPDATE %PREFIX%MESSAGE_GROUP
|
||||
set UPDATED_DATE=?, GROUP_CONDITION=?
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
REMOVE_MESSAGE_FROM_GROUP("DELETE from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY=? and MESSAGE_ID=? and " +
|
||||
"REGION=?"),
|
||||
REMOVE_MESSAGE_FROM_GROUP("""
|
||||
DELETE from %PREFIX%GROUP_TO_MESSAGE
|
||||
where GROUP_KEY=? and MESSAGE_ID=? and REGION=?
|
||||
"""),
|
||||
|
||||
REMOVE_GROUP_TO_MESSAGE_JOIN("DELETE from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY=? and REGION=?"),
|
||||
REMOVE_GROUP_TO_MESSAGE_JOIN("""
|
||||
DELETE from %PREFIX%GROUP_TO_MESSAGE
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
COUNT_ALL_MESSAGES_IN_GROUPS("SELECT COUNT(MESSAGE_ID) from %PREFIX%GROUP_TO_MESSAGE where REGION=?"),
|
||||
COUNT_ALL_MESSAGES_IN_GROUPS("""
|
||||
SELECT COUNT(MESSAGE_ID)
|
||||
from %PREFIX%GROUP_TO_MESSAGE
|
||||
where REGION=?
|
||||
"""),
|
||||
|
||||
COUNT_ALL_MESSAGES_IN_GROUP("SELECT COUNT(MESSAGE_ID) from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY=? and " +
|
||||
"REGION=?"),
|
||||
COUNT_ALL_MESSAGES_IN_GROUP("""
|
||||
SELECT COUNT(MESSAGE_ID)
|
||||
from %PREFIX%GROUP_TO_MESSAGE
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
LIST_MESSAGES_BY_GROUP_KEY("SELECT MESSAGE_ID, MESSAGE_BYTES, CREATED_DATE " +
|
||||
"from %PREFIX%MESSAGE where MESSAGE_ID in " +
|
||||
"(SELECT MESSAGE_ID from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY = ? and REGION = ?) and REGION = ? " +
|
||||
"ORDER BY CREATED_DATE"),
|
||||
LIST_MESSAGES_BY_GROUP_KEY("""
|
||||
SELECT MESSAGE_ID, MESSAGE_BYTES, CREATED_DATE
|
||||
from %PREFIX%MESSAGE
|
||||
where MESSAGE_ID in (SELECT MESSAGE_ID from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY = ? and REGION = ?)
|
||||
and REGION = ?
|
||||
ORDER BY CREATED_DATE
|
||||
"""),
|
||||
|
||||
POLL_FROM_GROUP("SELECT %PREFIX%MESSAGE.MESSAGE_ID, %PREFIX%MESSAGE.MESSAGE_BYTES from %PREFIX%MESSAGE " +
|
||||
"where %PREFIX%MESSAGE.MESSAGE_ID = " +
|
||||
"(SELECT min(m.MESSAGE_ID) from %PREFIX%MESSAGE m " +
|
||||
"join %PREFIX%GROUP_TO_MESSAGE on m.MESSAGE_ID = %PREFIX%GROUP_TO_MESSAGE.MESSAGE_ID " +
|
||||
"where CREATED_DATE = " +
|
||||
"(SELECT min(CREATED_DATE) from %PREFIX%MESSAGE, %PREFIX%GROUP_TO_MESSAGE " +
|
||||
"where %PREFIX%MESSAGE.MESSAGE_ID = %PREFIX%GROUP_TO_MESSAGE.MESSAGE_ID " +
|
||||
"and %PREFIX%GROUP_TO_MESSAGE.GROUP_KEY = ? " +
|
||||
"and %PREFIX%MESSAGE.REGION = ?) " +
|
||||
"and %PREFIX%GROUP_TO_MESSAGE.GROUP_KEY = ? " +
|
||||
"and m.REGION = ?)"),
|
||||
POLL_FROM_GROUP("""
|
||||
SELECT %PREFIX%MESSAGE.MESSAGE_ID, %PREFIX%MESSAGE.MESSAGE_BYTES
|
||||
from %PREFIX%MESSAGE
|
||||
where %PREFIX%MESSAGE.MESSAGE_ID = (
|
||||
SELECT min(m.MESSAGE_ID)
|
||||
from %PREFIX%MESSAGE m
|
||||
join %PREFIX%GROUP_TO_MESSAGE
|
||||
on m.MESSAGE_ID = %PREFIX%GROUP_TO_MESSAGE.MESSAGE_ID
|
||||
where CREATED_DATE = (
|
||||
SELECT min(CREATED_DATE)
|
||||
from %PREFIX%MESSAGE, %PREFIX%GROUP_TO_MESSAGE
|
||||
where %PREFIX%MESSAGE.MESSAGE_ID = %PREFIX%GROUP_TO_MESSAGE.MESSAGE_ID
|
||||
and %PREFIX%GROUP_TO_MESSAGE.GROUP_KEY = ? and %PREFIX%MESSAGE.REGION = ?)
|
||||
and %PREFIX%GROUP_TO_MESSAGE.GROUP_KEY = ? and m.REGION = ?)
|
||||
"""),
|
||||
|
||||
GET_GROUP_INFO("SELECT COMPLETE, LAST_RELEASED_SEQUENCE, CREATED_DATE, UPDATED_DATE, GROUP_CONDITION" +
|
||||
" from %PREFIX%MESSAGE_GROUP where GROUP_KEY=? and REGION=?"),
|
||||
GET_GROUP_INFO("""
|
||||
SELECT COMPLETE, LAST_RELEASED_SEQUENCE, CREATED_DATE, UPDATED_DATE, GROUP_CONDITION
|
||||
from %PREFIX%MESSAGE_GROUP
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
GET_MESSAGE("SELECT MESSAGE_ID, CREATED_DATE, MESSAGE_BYTES from %PREFIX%MESSAGE where MESSAGE_ID=? and " +
|
||||
"REGION=?"),
|
||||
GET_MESSAGE("""
|
||||
SELECT MESSAGE_ID, CREATED_DATE, MESSAGE_BYTES
|
||||
from %PREFIX%MESSAGE
|
||||
where MESSAGE_ID=? and REGION=?
|
||||
"""),
|
||||
|
||||
GET_MESSAGE_COUNT("SELECT COUNT(MESSAGE_ID) from %PREFIX%MESSAGE where REGION=?"),
|
||||
GET_MESSAGE_COUNT("""
|
||||
SELECT COUNT(MESSAGE_ID)
|
||||
from %PREFIX%MESSAGE
|
||||
where REGION=?
|
||||
"""),
|
||||
|
||||
DELETE_MESSAGE("DELETE from %PREFIX%MESSAGE where MESSAGE_ID=? and REGION=?"),
|
||||
DELETE_MESSAGE("""
|
||||
DELETE from %PREFIX%MESSAGE
|
||||
where MESSAGE_ID=? and REGION=?
|
||||
"""),
|
||||
|
||||
CREATE_MESSAGE("INSERT into %PREFIX%MESSAGE(MESSAGE_ID, REGION, CREATED_DATE, MESSAGE_BYTES)"
|
||||
+ " values (?, ?, ?, ?)"),
|
||||
CREATE_MESSAGE("""
|
||||
INSERT into %PREFIX%MESSAGE(MESSAGE_ID, REGION, CREATED_DATE, MESSAGE_BYTES)
|
||||
values (?, ?, ?, ?)
|
||||
"""),
|
||||
|
||||
COUNT_ALL_GROUPS("SELECT COUNT(GROUP_KEY) from %PREFIX%MESSAGE_GROUP where REGION=?"),
|
||||
COUNT_ALL_GROUPS("""
|
||||
SELECT COUNT(GROUP_KEY)
|
||||
from %PREFIX%MESSAGE_GROUP
|
||||
where REGION=?
|
||||
"""),
|
||||
|
||||
COMPLETE_GROUP("UPDATE %PREFIX%MESSAGE_GROUP set UPDATED_DATE=?, COMPLETE=1 where GROUP_KEY=? and REGION=?"),
|
||||
COMPLETE_GROUP("""
|
||||
UPDATE %PREFIX%MESSAGE_GROUP
|
||||
set UPDATED_DATE=?, COMPLETE=1
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
UPDATE_LAST_RELEASED_SEQUENCE("UPDATE %PREFIX%MESSAGE_GROUP set UPDATED_DATE=?, LAST_RELEASED_SEQUENCE=? where " +
|
||||
"GROUP_KEY=? and REGION=?"),
|
||||
UPDATE_LAST_RELEASED_SEQUENCE("""
|
||||
UPDATE %PREFIX%MESSAGE_GROUP
|
||||
set UPDATED_DATE=?, LAST_RELEASED_SEQUENCE=?
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
DELETE_MESSAGES_FROM_GROUP("DELETE from %PREFIX%MESSAGE where MESSAGE_ID in " +
|
||||
"(SELECT MESSAGE_ID from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY = ? and REGION = ?) and REGION = ?"),
|
||||
DELETE_MESSAGES_FROM_GROUP("""
|
||||
DELETE from %PREFIX%MESSAGE
|
||||
where MESSAGE_ID in (SELECT MESSAGE_ID from %PREFIX%GROUP_TO_MESSAGE where GROUP_KEY = ? and REGION = ?)
|
||||
and REGION = ?
|
||||
"""),
|
||||
|
||||
DELETE_MESSAGE_GROUP("DELETE from %PREFIX%MESSAGE_GROUP where GROUP_KEY=? and REGION=?"),
|
||||
DELETE_MESSAGE_GROUP("""
|
||||
DELETE from %PREFIX%MESSAGE_GROUP
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
CREATE_GROUP_TO_MESSAGE("INSERT into %PREFIX%GROUP_TO_MESSAGE" +
|
||||
"(GROUP_KEY, MESSAGE_ID, REGION)"
|
||||
+ " values (?, ?, ?)"),
|
||||
CREATE_GROUP_TO_MESSAGE("""
|
||||
INSERT into %PREFIX%GROUP_TO_MESSAGE (GROUP_KEY, MESSAGE_ID, REGION)
|
||||
values (?, ?, ?)
|
||||
"""),
|
||||
|
||||
UPDATE_GROUP("UPDATE %PREFIX%MESSAGE_GROUP set UPDATED_DATE=? where GROUP_KEY=? and REGION=?"),
|
||||
UPDATE_GROUP("""
|
||||
UPDATE %PREFIX%MESSAGE_GROUP
|
||||
set UPDATED_DATE=?
|
||||
where GROUP_KEY=? and REGION=?
|
||||
"""),
|
||||
|
||||
LIST_GROUP_KEYS("SELECT distinct GROUP_KEY as CREATED from %PREFIX%MESSAGE_GROUP where REGION=?");
|
||||
LIST_GROUP_KEYS("""
|
||||
SELECT distinct GROUP_KEY as CREATED
|
||||
from %PREFIX%MESSAGE_GROUP
|
||||
where REGION=?
|
||||
""");
|
||||
|
||||
private final String sql;
|
||||
|
||||
|
||||
@@ -287,16 +287,17 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl
|
||||
|
||||
private abstract class RedisLock implements Lock {
|
||||
|
||||
private static final String OBTAIN_LOCK_SCRIPT =
|
||||
"local lockClientId = redis.call('GET', KEYS[1]) " +
|
||||
"if lockClientId == ARGV[1] then " +
|
||||
" redis.call('PEXPIRE', KEYS[1], ARGV[2]) " +
|
||||
" return true " +
|
||||
"elseif not lockClientId then " +
|
||||
" redis.call('SET', KEYS[1], ARGV[1], 'PX', ARGV[2]) " +
|
||||
" return true " +
|
||||
"end " +
|
||||
"return false";
|
||||
private static final String OBTAIN_LOCK_SCRIPT = """
|
||||
local lockClientId = redis.call('GET', KEYS[1])
|
||||
if lockClientId == ARGV[1] then
|
||||
redis.call('PEXPIRE', KEYS[1], ARGV[2])
|
||||
return true
|
||||
elseif not lockClientId then
|
||||
redis.call('SET', KEYS[1], ARGV[1], 'PX', ARGV[2])
|
||||
return true
|
||||
end
|
||||
return false
|
||||
""";
|
||||
|
||||
protected static final RedisScript<Boolean>
|
||||
OBTAIN_LOCK_REDIS_SCRIPT = new DefaultRedisScript<>(OBTAIN_LOCK_SCRIPT, Boolean.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -28,7 +28,7 @@ import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
|
||||
import jakarta.xml.soap.MessageFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -60,6 +60,7 @@ import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@@ -74,24 +75,26 @@ public class SimpleWebServiceOutboundGatewayTests {
|
||||
|
||||
private static final String response = "<response><name>Test Name</name></response>";
|
||||
|
||||
public static final String responseSoapMessage =
|
||||
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
|
||||
"<soap:Body> " +
|
||||
response +
|
||||
"</soap:Body> " +
|
||||
"</soap:Envelope>";
|
||||
public static final String responseSoapMessage = """
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
$response
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
||||
""".replace("$response", response);
|
||||
|
||||
public static final String responseEmptyBodySoapMessage =
|
||||
"<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
||||
"<SOAP:Header/>\n" +
|
||||
"<SOAP:Body/>\n" +
|
||||
"</SOAP:Envelope>";
|
||||
public static final String responseEmptyBodySoapMessage = """
|
||||
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<SOAP:Header/>
|
||||
<SOAP:Body/>
|
||||
</SOAP:Envelope>
|
||||
""";
|
||||
|
||||
@Test // INT-1051
|
||||
@Test
|
||||
public void soapActionAndCustomCallback() {
|
||||
String uri = "https://www.example.org";
|
||||
SimpleWebServiceOutboundGateway gateway = new SimpleWebServiceOutboundGateway(new TestDestinationProvider(uri));
|
||||
final AtomicReference<String> soapActionFromCallback = new AtomicReference<String>();
|
||||
final AtomicReference<String> soapActionFromCallback = new AtomicReference<>();
|
||||
gateway.setRequestCallback(message -> {
|
||||
SoapMessage soapMessage = (SoapMessage) message;
|
||||
soapActionFromCallback.set(soapMessage.getSoapAction());
|
||||
@@ -126,13 +129,14 @@ public class SimpleWebServiceOutboundGatewayTests {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test(expected = ReplyRequiredException.class)
|
||||
@Test
|
||||
public void testInt3022EmptyResponseBody() throws Exception {
|
||||
SimpleWebServiceOutboundGateway gateway = new SimpleWebServiceOutboundGateway("http://testInt3022");
|
||||
gateway.setRequiresReply(true);
|
||||
WebServiceMessageSender messageSender = createMockMessageSender(responseEmptyBodySoapMessage);
|
||||
gateway.setMessageSenders(messageSender);
|
||||
gateway.handleMessage(new GenericMessage<String>("<test>foo</test>"));
|
||||
assertThatExceptionOfType(ReplyRequiredException.class)
|
||||
.isThrownBy(() -> gateway.handleMessage(new GenericMessage<>("<test>foo</test>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -247,8 +251,7 @@ public class SimpleWebServiceOutboundGatewayTests {
|
||||
Mockito.when(messageSender.supports(Mockito.any(URI.class))).thenReturn(true);
|
||||
|
||||
Mockito.doAnswer(invocation -> {
|
||||
Object[] args = invocation.getArguments();
|
||||
WebServiceMessageFactory factory = (WebServiceMessageFactory) args[0];
|
||||
WebServiceMessageFactory factory = invocation.getArgument(0);
|
||||
return factory.createWebServiceMessage(new ByteArrayInputStream(mockResponseMessage.getBytes()));
|
||||
}).when(wsConnection).receive(Mockito.any(WebServiceMessageFactory.class));
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:ws="http://www.springframework.org/schema/integration/ws"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:ws="http://www.springframework.org/schema/integration/ws"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
@@ -22,12 +22,18 @@
|
||||
|
||||
<si:channel id="requestsVerySimple"/>
|
||||
|
||||
<ws:inbound-gateway id="extractsPayload" request-channel="requestsSimple" extract-payload="false"/>
|
||||
<ws:inbound-gateway id="extractsPayload"
|
||||
request-channel="requestsSimple"
|
||||
extract-payload="false"
|
||||
reply-timeout="0"/>
|
||||
|
||||
<ws:inbound-gateway id="marshalling" request-channel="requestsMarshalling" error-channel="customErrorChannel"
|
||||
marshaller="marshaller" unmarshaller="marshaller"
|
||||
mapped-request-headers="testRequest"
|
||||
mapped-reply-headers="testReply"/>
|
||||
<ws:inbound-gateway id="marshalling"
|
||||
request-channel="requestsMarshalling"
|
||||
error-channel="customErrorChannel"
|
||||
marshaller="marshaller"
|
||||
mapped-request-headers="testRequest"
|
||||
mapped-reply-headers="testReply"
|
||||
reply-timeout="0"/>
|
||||
|
||||
<si:channel id="requestsMarshalling">
|
||||
<si:queue/>
|
||||
@@ -42,19 +48,20 @@
|
||||
</si:channel>
|
||||
|
||||
<ws:inbound-gateway id="headerMappingGateway" request-channel="headerMappingRequests"
|
||||
header-mapper="testHeaderMapper"/>
|
||||
header-mapper="testHeaderMapper"/>
|
||||
|
||||
<bean id="marshaller" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.oxm.support.AbstractMarshaller" type="java.lang.Class"/>
|
||||
</bean>
|
||||
|
||||
<bean id="testHeaderMapper" class="org.springframework.integration.ws.config.WebServiceInboundGatewayParserTests$TestHeaderMapper"/>
|
||||
<bean id="testHeaderMapper"
|
||||
class="org.springframework.integration.ws.config.WebServiceInboundGatewayParserTests$TestHeaderMapper"/>
|
||||
|
||||
<si:channel id="replyTimeoutRequests">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<ws:inbound-gateway id="replyTimeoutGateway" request-channel="replyTimeoutRequests"
|
||||
reply-timeout="1234"/>
|
||||
reply-timeout="1234"/>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user