GH-2071: Upgrade to S-WS-3.0 and Smack-4.2.1

Fixes: spring-projects/spring-integration#2071

* Clean up `build.gradle` for redundant excludes
* Add `javax.mail` dependency to WS module to avoid WARN about missed providers
* Refactoring for the XMPP module according changes in the latest Smack
* Polishing for the `BackToBackAdapterTests` to avoid extra wait for `null`
on the channel and some race conditions when client is closed during by the
`stop()` during publishing

Polishing `UriVariableTests` according the latest S-WS B-S

Revert excludes removal
This commit is contained in:
Artem Bilan
2017-10-06 14:28:34 -04:00
committed by Gary Russell
parent 1f88e2de7b
commit bc4337ffa8
20 changed files with 158 additions and 131 deletions

View File

@@ -19,6 +19,7 @@ package org.springframework.integration.ws.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.doAnswer;
import java.io.IOException;
@@ -36,7 +37,6 @@ import javax.jms.Queue;
import javax.jms.Session;
import org.hamcrest.Matchers;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Stanza;
import org.junit.Test;
@@ -72,6 +72,7 @@ import org.springframework.ws.transport.mail.MailSenderConnection;
* @author Mark Fisher
* @author Artem Bilan
* @author Andy Wilkinson
*
* @since 2.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -112,7 +113,8 @@ public class UriVariableTests {
@Test
@SuppressWarnings("unchecked")
public void testHttpUriVariables() {
WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(this.httpOutboundGateway, "webServiceTemplate", WebServiceTemplate.class);
WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(this.httpOutboundGateway,
"webServiceTemplate", WebServiceTemplate.class);
webServiceTemplate = Mockito.spy(webServiceTemplate);
final AtomicReference<String> uri = new AtomicReference<>();
doAnswer(invocation -> {
@@ -206,9 +208,10 @@ public class UriVariableTests {
}
@Test
public void testInt2720XmppUriVariables() throws SmackException.NotConnectedException {
public void testInt2720XmppUriVariables() throws Exception {
Mockito.doThrow(new WebServiceIOException("intentional")).when(this.xmppConnection).sendStanza(Mockito.any(Stanza.class));
willThrow(new WebServiceIOException("intentional"))
.given(this.xmppConnection).sendStanza(Mockito.any(Stanza.class));
Message<?> message = MessageBuilder.withPayload("<spring/>").setHeader("to", "user").build();
try {
@@ -222,7 +225,7 @@ public class UriVariableTests {
ArgumentCaptor<Stanza> argument = ArgumentCaptor.forClass(Stanza.class);
Mockito.verify(this.xmppConnection).sendStanza(argument.capture());
assertEquals("user@jabber.org", argument.getValue().getTo());
assertEquals("user@jabber.org", argument.getValue().getTo().toString());
assertEquals("xmpp:user@jabber.org", this.interceptor.getLastUri().toString());
}
@@ -270,12 +273,17 @@ public class UriVariableTests {
public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {
}
}
private static class Int2720EmailTestClientInterceptor extends TestClientInterceptor {
private volatile WebServiceConnection webServiceConnection;
Int2720EmailTestClientInterceptor() {
super();
}
public WebServiceConnection getLastWebServiceConnection() {
return webServiceConnection;
}
@@ -294,6 +302,7 @@ public class UriVariableTests {
super.handleRequest(messageContext);
throw new WebServiceIOException("intentional");
}
}
}

View File

@@ -0,0 +1,8 @@
log4j.rootCategory=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
log4j.category.org.springframework.integration=WARN
log4j.category.org.springframework.integration.ws=WARN