PROTON-2595: fixup various uses of deprecated APIs in tests from previous dep updates
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java
index 8ebb8cb..2f8d298 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java
@@ -21,8 +21,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import java.util.Collections;
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java
index 8e8a4dc..c2bba56 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java
@@ -18,9 +18,16 @@
*/
package org.apache.qpid.proton.engine.impl;
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.nio.ByteBuffer;
import java.util.Arrays;
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
index a40da89..4d65343 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
@@ -79,9 +79,7 @@
import org.apache.qpid.proton.engine.TransportException;
import org.apache.qpid.proton.framing.TransportFrame;
import org.apache.qpid.proton.message.Message;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -95,9 +93,6 @@
private static final int BUFFER_SIZE = 8 * 1024;
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
@Test
public void testInput()
{
@@ -140,9 +135,13 @@
@Test
public void testEmptyInputBeforeBindUsingOldApi_causesTransportException()
{
- _expectedException.expect(TransportException.class);
- _expectedException.expectMessage("Unexpected EOS when remote connection not closed: connection aborted");
- _transport.input(new byte [0], 0, 0);
+ try {
+ _transport.input(new byte [0], 0, 0);
+ fail("Expected an exception to be thrown");
+ } catch (TransportException te) {
+ final String msg = te.getMessage();
+ assertTrue("Unexpected message: " + msg, msg.endsWith("Unexpected EOS when remote connection not closed: connection aborted"));
+ }
}
/**
@@ -287,8 +286,12 @@
assertFalse(_transport.isHandlingFrames());
- _expectedException.expect(IllegalStateException.class);
- _transport.handleFrame(TRANSPORT_FRAME_BEGIN);
+ try {
+ _transport.handleFrame(TRANSPORT_FRAME_BEGIN);
+ fail("Expected an exception to be thrown");
+ } catch (IllegalStateException ise) {
+ // Expected
+ }
}
@Test
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java
index 605046c..4efb4cc 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java
@@ -36,9 +36,7 @@
import org.apache.qpid.proton.engine.Transport;
import org.apache.qpid.proton.engine.TransportException;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
/**
* TODO unit test handshaking
@@ -52,9 +50,6 @@
private SimpleSslTransportWrapper _sslWrapper;
private CapitalisingDummySslEngine _dummySslEngine;
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
@Before
public void setUp()
{
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java
index 4c544be..5bf97a3 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java
@@ -22,6 +22,7 @@
import static org.apache.qpid.proton.engine.impl.TransportTestHelper.assertByteBufferContentEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
@@ -31,9 +32,7 @@
import org.apache.qpid.proton.engine.TransportException;
import org.apache.qpid.proton.engine.impl.TransportWrapper;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
public class SslHandshakeSniffingTransportWrapperTest
{
@@ -44,9 +43,6 @@
private TransportWrapper _plainTransportWrapper = mock(TransportWrapper.class);
private SslTransportWrapper _sniffingWrapper = new SslHandshakeSniffingTransportWrapper(_secureTransportWrapper, _plainTransportWrapper);
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
@Test
public void testGetInputBufferGetOutputBufferWithNonSsl()
{
@@ -110,8 +106,12 @@
_sniffingWrapper.tail().put(sourceBuffer);
_sniffingWrapper.close_tail();
- _expectedException.expect(TransportException.class);
- _sniffingWrapper.process();
+ try {
+ _sniffingWrapper.process();
+ fail("Expected an exception to be thrown");
+ } catch (TransportException te) {
+ // Expected
+ }
}
finally
{