You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2022/08/29 13:24:17 UTC
[qpid-proton-j] 03/05: PROTON-2595: fixup various uses of deprecated APIs in tests from previous dep updates
This is an automated email from the ASF dual-hosted git repository.
robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton-j.git
commit 36ebaa0cc0318d027e5bea54e25f96bab9678fe0
Author: Robbie Gemmell <ro...@apache.org>
AuthorDate: Mon Aug 29 12:42:29 2022 +0100
PROTON-2595: fixup various uses of deprecated APIs in tests from previous dep updates
---
.../proton/amqp/transport/ErrorConditionTest.java | 2 +-
.../proton/engine/impl/SaslFrameParserTest.java | 11 +++++++++--
.../qpid/proton/engine/impl/TransportImplTest.java | 23 ++++++++++++----------
.../impl/ssl/SimpleSslTransportWrapperTest.java | 5 -----
.../SslHandshakeSniffingTransportWrapperTest.java | 14 ++++++-------
5 files changed, 30 insertions(+), 25 deletions(-)
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 8ebb8cbb..2f8d298e 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 @@ package org.apache.qpid.proton.amqp.transport;
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 8e8a4dcc..c2bba560 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 a40da89c..4d65343b 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.Transport;
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 @@ public class TransportImplTest
private static final int BUFFER_SIZE = 8 * 1024;
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
@Test
public void testInput()
{
@@ -140,9 +135,13 @@ public class TransportImplTest
@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 @@ public class TransportImplTest
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 605046cb..4efb4cc8 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 javax.net.ssl.SSLException;
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 @@ public class SimpleSslTransportWrapperTest
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 4c544be0..5bf97a35 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 @@ package org.apache.qpid.proton.engine.impl.ssl;
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 java.nio.ByteBuffer;
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 @@ public class SslHandshakeSniffingTransportWrapperTest
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 @@ public class SslHandshakeSniffingTransportWrapperTest
_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
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org