QPID-8247: Upgrade mockito to version 2.22.0
diff --git a/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/DatabaseTemplateTest.java b/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/DatabaseTemplateTest.java
index 7323804..a06954f 100644
--- a/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/DatabaseTemplateTest.java
+++ b/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/DatabaseTemplateTest.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.server.store.berkeleydb.upgrade;
 
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Matchers.same;
@@ -49,6 +52,8 @@
         _sourceDatabase = mock(Database.class);
         when(_environment.openDatabase(any(Transaction.class), same(SOURCE_DATABASE), isA(DatabaseConfig.class)))
                 .thenReturn(_sourceDatabase);
+        when(_environment.openDatabase(isNull(), same(SOURCE_DATABASE), isA(DatabaseConfig.class)))
+                .thenReturn(_sourceDatabase);
     }
 
     @Test
@@ -80,7 +85,7 @@
         DatabaseRunnable databaseOperation = mock(DatabaseRunnable.class);
         databaseTemplate.run(databaseOperation);
 
-        verify(databaseOperation).run(_sourceDatabase, (Database)null, (Transaction)null);
+        verify(databaseOperation).run(eq(_sourceDatabase), isNull(), isNull());
         verify(_sourceDatabase).close();
     }
 
diff --git a/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java b/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java
index 2634750..e10d1f9 100644
--- a/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java
+++ b/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java
@@ -24,6 +24,8 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeThat;
+import static org.mockito.ArgumentMatchers.isNotNull;
+import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Matchers.anyMap;
@@ -169,8 +171,14 @@
     {
         String remoteReplicationName = getTestName();
         BDBHARemoteReplicationNode remoteReplicationNode = createRemoteReplicationNode(remoteReplicationName);
-        when(_mockAccessControl.authorise(any(SecurityToken.class), eq(Operation.UPDATE), eq(remoteReplicationNode), anyMap())).thenReturn(Result.DENIED);
-
+        when(_mockAccessControl.authorise(any(SecurityToken.class),
+                                          eq(Operation.UPDATE),
+                                          eq(remoteReplicationNode),
+                                          anyMap())).thenReturn(Result.DENIED);
+        when(_mockAccessControl.authorise(isNull(),
+                                          eq(Operation.UPDATE),
+                                          eq(remoteReplicationNode),
+                                          anyMap())).thenReturn(Result.DENIED);
 
         assertNull(remoteReplicationNode.getDescription());
 
@@ -191,7 +199,14 @@
         String remoteReplicationName = getTestName();
         BDBHARemoteReplicationNode remoteReplicationNode = createRemoteReplicationNode(remoteReplicationName);
 
-        when(_mockAccessControl.authorise(any(SecurityToken.class), eq(Operation.DELETE), eq(remoteReplicationNode), anyMap())).thenReturn(Result.DENIED);
+        when(_mockAccessControl.authorise(any(SecurityToken.class),
+                                          eq(Operation.DELETE),
+                                          eq(remoteReplicationNode),
+                                          anyMap())).thenReturn(Result.DENIED);
+        when(_mockAccessControl.authorise(isNull(),
+                                          eq(Operation.DELETE),
+                                          eq(remoteReplicationNode),
+                                          anyMap())).thenReturn(Result.DENIED);
         assertNull(remoteReplicationNode.getDescription());
 
         try
diff --git a/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java b/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java
index 67bf9bd..5f882a3 100644
--- a/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java
+++ b/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java
@@ -392,7 +392,7 @@
         return eventLogger;
     }
 
-    class LogMessageMatcher extends ArgumentMatcher<LogMessage>
+    class LogMessageMatcher implements ArgumentMatcher<LogMessage>
     {
         private String _expectedMessage;
         private String _expectedMessageFailureDescription = null;
@@ -406,10 +406,8 @@
         }
 
         @Override
-        public boolean matches(Object argument)
+        public boolean matches(LogMessage logMessage)
         {
-            LogMessage logMessage = (LogMessage)argument;
-
             boolean expectedMessageMatches = _expectedMessage.equals(logMessage.toString());
             if (!expectedMessageMatches)
             {
@@ -423,22 +421,9 @@
 
             return expectedMessageMatches && expectedHierarchyMatches;
         }
-
-        @Override
-        public void describeTo(Description description)
-        {
-            if (_expectedMessageFailureDescription != null)
-            {
-                description.appendText(_expectedMessageFailureDescription);
-            }
-            if (_expectedHierarchyFailureDescription != null)
-            {
-                description.appendText(_expectedHierarchyFailureDescription);
-            }
-        }
     }
 
-    class LogSubjectMatcher extends ArgumentMatcher<LogSubject>
+    class LogSubjectMatcher implements ArgumentMatcher<LogSubject>
     {
         private LogSubject _logSubject;
         private String _failureDescription = null;
@@ -449,9 +434,8 @@
         }
 
         @Override
-        public boolean matches(Object argument)
+        public boolean matches(LogSubject logSubject)
         {
-            final LogSubject logSubject = (LogSubject)argument;
             final boolean foundAMatch = _logSubject.toLogString().equals(logSubject.toLogString());
             if (!foundAMatch)
             {
@@ -459,14 +443,5 @@
             }
             return foundAMatch;
         }
-
-        @Override
-        public void describeTo(Description description)
-        {
-            if (_failureDescription != null)
-            {
-                description.appendText(_failureDescription);
-            }
-        }
     }
 }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java b/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
index 44b5be5..4c3b5c7 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
@@ -83,8 +83,10 @@
         when(model.getParentType(eq(VirtualHost.class))).thenReturn((Class)Broker.class);
         when(child.getModel()).thenReturn(model);
         when(child.isDurable()).thenReturn(true);
+        final ConfiguredObjectRecord childRecord = mock(ConfiguredObjectRecord.class);
+        when(child.asObjectRecord()).thenReturn(childRecord);
         _listener.childAdded(broker, child);
-        verify(_store).update(eq(true), any(ConfiguredObjectRecord.class));
+        verify(_store).update(eq(true), eq(childRecord));
     }
 
     @Test
@@ -94,8 +96,10 @@
         Broker broker = mock(Broker.class);
         when(broker.getCategoryClass()).thenReturn(Broker.class);
         when(broker.isDurable()).thenReturn(true);
+        final ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class);
+        when(broker.asObjectRecord()).thenReturn(record);
         _listener.attributeSet(broker, Broker.DESCRIPTION, null, "test description");
-        verify(_store).update(eq(false), any(ConfiguredObjectRecord.class));
+        verify(_store).update(eq(false), eq(record));
     }
 
     @Test
diff --git a/broker-core/src/test/java/org/apache/qpid/server/consumer/AbstractConsumerTargetTest.java b/broker-core/src/test/java/org/apache/qpid/server/consumer/AbstractConsumerTargetTest.java
index 9e0239b..6c2f24a 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/consumer/AbstractConsumerTargetTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/consumer/AbstractConsumerTargetTest.java
@@ -177,7 +177,7 @@
 
         _consumerTarget.sendNextMessage();
         assertTrue("message credit was not restored", _consumerTarget.isCreditRestored());
-        verify(_messageInstance).routeToAlternate(any(Action.class), any(ServerTransaction.class), any());
+        verify(_messageInstance).routeToAlternate(null, null, null);
     }
 
     @Test
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java b/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
index b6f52d1..721c8bc 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/BrokerTestHelper.java
@@ -20,16 +20,14 @@
  */
 package org.apache.qpid.server.model;
 
-import static org.apache.bcel.Const.ACC_INTERFACE;
-import static org.apache.bcel.Const.ACC_PUBLIC;
-import static org.apache.bcel.Const.ACC_SUPER;
+import static org.mockito.ArgumentMatchers.isNotNull;
+import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.withSettings;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -39,13 +37,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.security.auth.Subject;
 
-import org.apache.bcel.classfile.JavaClass;
-import org.apache.bcel.generic.ClassGen;
-
 import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
@@ -80,11 +74,6 @@
                                                               Collections.singleton(SYSTEM_PRINCIPAL),
                                                               Collections.emptySet(),
                                                               Collections.emptySet());
-    private static final Map<Class<? extends ConfiguredObject>, Class<? extends ConfiguredObject>>
-            SYSTEM_PRINCIPAL_SOURCE_MOCKS = new HashMap<>();
-    private static final Map<Class<? extends ConfiguredObject>, Class<? extends ConfiguredObject>>
-            SYSTEM_PRINCIPAL_AND_ACCESS_CONTROL_SOURCE_MOCKS = new HashMap<>();
-    private static final AtomicInteger GENERATED_INTERFACE_COUNTER = new AtomicInteger();
 
 
     private static List<VirtualHost> _createdVirtualHosts = new ArrayList<>();
@@ -116,9 +105,12 @@
     public static AccessControl createAccessControlMock()
     {
         AccessControl mock = mock(AccessControl.class);
-        when(mock.authorise(any(SecurityToken.class), any(Operation.class), any(ConfiguredObject.class))).thenReturn(
+        when(mock.authorise(any(SecurityToken.class), any(Operation.class), any(PermissionedObject.class))).thenReturn(
                 Result.DEFER);
-        when(mock.authorise(any(SecurityToken.class), any(Operation.class), any(ConfiguredObject.class), any(Map.class))).thenReturn(Result.DEFER);
+        when(mock.authorise(isNull(), any(Operation.class), any(PermissionedObject.class))).thenReturn(
+                Result.DEFER);
+        when(mock.authorise(any(SecurityToken.class), any(Operation.class), any(PermissionedObject.class), any(Map.class))).thenReturn(Result.DEFER);
+        when(mock.authorise(isNull(), any(Operation.class), any(PermissionedObject.class), any(Map.class))).thenReturn(Result.DEFER);
         when(mock.getDefault()).thenReturn(Result.ALLOWED);
         return mock;
     }
@@ -318,110 +310,22 @@
 
     public static <X extends ConfiguredObject> X mockWithSystemPrincipal(Class<X> clazz, Principal principal)
     {
-        synchronized (SYSTEM_PRINCIPAL_SOURCE_MOCKS)
-        {
-            Class<?> mockedClass = SYSTEM_PRINCIPAL_SOURCE_MOCKS.get(clazz);
-            if(mockedClass == null)
-            {
-                mockedClass = generateTestableInterface(clazz, TestableSystemPrincipalSource.class);
-                SYSTEM_PRINCIPAL_SOURCE_MOCKS.put(clazz, (Class<? extends X>) mockedClass);
-            }
-            X mock = mock((Class<? extends X>)mockedClass);
-            when(((SystemPrincipalSource)mock).getSystemPrincipal()).thenReturn(principal);
-
-            return mock;
-        }
+        X mock = mock(clazz, withSettings().extraInterfaces(TestableSystemPrincipalSource.class));
+        when(((SystemPrincipalSource)mock).getSystemPrincipal()).thenReturn(principal);
+        return mock;
     }
 
     public static <X extends ConfiguredObject> X mockWithSystemPrincipalAndAccessControl(Class<X> clazz,
                                                                                          Principal principal,
                                                                                          AccessControl accessControl)
     {
-        synchronized (SYSTEM_PRINCIPAL_AND_ACCESS_CONTROL_SOURCE_MOCKS)
-        {
-            Class<?> mockedClass = SYSTEM_PRINCIPAL_AND_ACCESS_CONTROL_SOURCE_MOCKS.get(clazz);
-            if(mockedClass == null)
-            {
-                mockedClass = generateTestableInterface(clazz, TestableSystemPrincipalSource.class, TestableAccessControlSource.class);
-                SYSTEM_PRINCIPAL_AND_ACCESS_CONTROL_SOURCE_MOCKS.put(clazz, (Class<? extends X>) mockedClass);
-            }
-            X mock = mock((Class<? extends X>)mockedClass);
-            when(((SystemPrincipalSource)mock).getSystemPrincipal()).thenReturn(principal);
-            when(((AccessControlSource)mock).getAccessControl()).thenReturn(accessControl);
+        X mock = mock(clazz,
+                      withSettings().extraInterfaces(TestableSystemPrincipalSource.class,
+                                                     TestableAccessControlSource.class));
+        when(((SystemPrincipalSource) mock).getSystemPrincipal()).thenReturn(principal);
+        when(((AccessControlSource) mock).getAccessControl()).thenReturn(accessControl);
 
-            return mock;
-        }
-    }
-
-
-    private static Class<?> generateTestableInterface(final Class<?>... interfaces)
-    {
-        final String fqcn = BrokerTestHelper.class.getPackage().getName() + ".Testable" + interfaces[0].getSimpleName() + "_" + GENERATED_INTERFACE_COUNTER.incrementAndGet();
-        final byte[] classBytes = createSubClassByteCode(fqcn, interfaces);
-
-        try
-        {
-            final ClassLoader classLoader = new TestableMockDelegatingClassloader(fqcn, classBytes);
-            Class<?> clazz = classLoader.loadClass(fqcn);
-            return clazz;
-        }
-        catch (ClassNotFoundException cnfe)
-        {
-            throw new IllegalArgumentException("Could not resolve dynamically generated class " + fqcn, cnfe);
-        }
-    }
-
-    private static byte[] createSubClassByteCode(final String className, final Class<?>[] interfaces)
-    {
-        String[] ifnames = new String[interfaces.length];
-        for(int i = 0; i<interfaces.length; i++)
-        {
-            ifnames[i] = interfaces[i].getName();
-        }
-        ClassGen classGen = new ClassGen(className,
-                                         "java.lang.Object",
-                                         "<generated>",
-                                         ACC_PUBLIC | ACC_SUPER | ACC_INTERFACE,
-                                         ifnames);
-
-
-        JavaClass javaClass = classGen.getJavaClass();
-
-        try(ByteArrayOutputStream out = new ByteArrayOutputStream())
-        {
-            javaClass.dump(out);
-            return out.toByteArray();
-        }
-        catch (IOException ioex)
-        {
-            throw new IllegalStateException("Could not write to a ByteArrayOutputStream - should not happen", ioex);
-        }
-    }
-
-    private static final class TestableMockDelegatingClassloader extends ClassLoader
-    {
-        private final String _className;
-        private final Class<? extends ConfiguredObject> _clazz;
-
-        private TestableMockDelegatingClassloader(String className, byte[] classBytes)
-        {
-            super(ConfiguredObject.class.getClassLoader());
-            _className = className;
-            _clazz = (Class<? extends ConfiguredObject>) defineClass(className, classBytes, 0, classBytes.length);
-        }
-
-        @Override
-        protected Class<?> findClass(String fqcn) throws ClassNotFoundException
-        {
-            if (fqcn.equals(_className))
-            {
-                return _clazz;
-            }
-            else
-            {
-                return getParent().loadClass(fqcn);
-            }
-        }
+        return mock;
     }
 
 }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java b/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
index e69addf..1be4505 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
@@ -839,7 +839,7 @@
         return argThat(new MinimalConfiguredObjectRecordMatcher(id, type));
     }
 
-    private static class MinimalConfiguredObjectRecordMatcher extends ArgumentMatcher<ConfiguredObjectRecord>
+    private static class MinimalConfiguredObjectRecordMatcher implements ArgumentMatcher<ConfiguredObjectRecord>
     {
         private final UUID _id;
         private final String _type;
@@ -851,9 +851,8 @@
         }
 
         @Override
-        public boolean matches(Object argument)
+        public boolean matches(ConfiguredObjectRecord rhs)
         {
-            ConfiguredObjectRecord rhs = (ConfiguredObjectRecord) argument;
             return (_id.equals(rhs.getId()) || _type.equals(rhs.getType()));
         }
     }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/model/preferences/UserPreferencesTest.java b/broker-core/src/test/java/org/apache/qpid/server/model/preferences/UserPreferencesTest.java
index 634e087..eff3017 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/model/preferences/UserPreferencesTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/model/preferences/UserPreferencesTest.java
@@ -222,7 +222,7 @@
         return queryPreference;
     }
 
-    private class UUIDCollectionMatcher extends ArgumentMatcher<Collection<UUID>>
+    private class UUIDCollectionMatcher implements ArgumentMatcher<Collection<UUID>>
     {
         private Collection<UUID> _expected;
         private String _failureDescription;
@@ -233,32 +233,16 @@
         }
 
         @Override
-        public boolean matches(final Object o)
+        public boolean matches(final Collection<UUID> o)
         {
-            if (!(o instanceof Collection))
-            {
-                _failureDescription = "Not a collection";
-                return false;
-            }
-
             _failureDescription = "Items do not match: expected " + _expected + " actual: " + o;
-            return new TreeSet<>(_expected).equals(new TreeSet<>((Collection<UUID>) o));
-        }
-
-        @Override
-        public void describeTo(Description description)
-        {
-            if (_failureDescription != null)
-            {
-                description.appendText(_failureDescription);
-            }
+            return new TreeSet<>(_expected).equals(new TreeSet<>(o));
         }
     }
 
-    private class PreferenceRecordMatcher extends ArgumentMatcher<Collection<PreferenceRecord>>
+    private class PreferenceRecordMatcher implements ArgumentMatcher<Collection<PreferenceRecord>>
     {
         private final Preference _preference;
-        private String _failureDescription;
 
         public PreferenceRecordMatcher(final Preference preference)
         {
@@ -266,31 +250,25 @@
         }
 
         @Override
-        public boolean matches(final Object records)
+        public boolean matches(final Collection<PreferenceRecord> preferenceRecords)
         {
-            _failureDescription = "Unexpected arguments type";
-            Collection<PreferenceRecord> preferenceRecords = (Collection<PreferenceRecord>) records;
             if (preferenceRecords.size() != 1)
             {
                 return false;
             }
 
-            _failureDescription = "Unexpected preference id";
             PreferenceRecord record = preferenceRecords.iterator().next();
             if (!record.getId().equals(_preference.getId()))
             {
                 return false;
             }
 
-            _failureDescription = "Attributes is null";
             Map<String, Object> recordAttributes = record.getAttributes();
             if (recordAttributes == null)
             {
                 return false;
             }
-            ;
 
-            _failureDescription = "Expected attributes are not found: " + recordAttributes;
             for (Map.Entry entry : _preference.getAttributes().entrySet())
             {
                 if (!Objects.equals(entry.getValue(), recordAttributes.get(entry.getKey())))
@@ -302,13 +280,5 @@
             return true;
         }
 
-        @Override
-        public void describeTo(Description description)
-        {
-            if (_failureDescription != null)
-            {
-                description.appendText(_failureDescription);
-            }
-        }
     }
 }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/queue/ProducerFlowControlOverflowPolicyHandlerTest.java b/broker-core/src/test/java/org/apache/qpid/server/queue/ProducerFlowControlOverflowPolicyHandlerTest.java
index 691a65e..0fa6024 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/queue/ProducerFlowControlOverflowPolicyHandlerTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/queue/ProducerFlowControlOverflowPolicyHandlerTest.java
@@ -38,6 +38,7 @@
 import org.hamcrest.Description;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.ArgumentMatcher;
 
 import org.apache.qpid.server.connection.SessionPrincipal;
 import org.apache.qpid.server.logging.EventLogger;
@@ -196,10 +197,9 @@
                            Collections.EMPTY_SET);
     }
 
-    public static class LogMessageMatcher extends BaseMatcher<LogMessage>
+    public static class LogMessageMatcher implements ArgumentMatcher<LogMessage>
     {
         private final LogMessage _expected;
-        private Object _actual;
 
         LogMessageMatcher(final LogMessage expected)
         {
@@ -207,20 +207,9 @@
         }
 
         @Override
-        public void describeTo(final Description description)
+        public boolean matches(final LogMessage argument)
         {
-            description.appendText("Expected '");
-            description.appendText(_expected.toString());
-            description.appendText("' but got '");
-            description.appendText(String.valueOf(_actual));
-            description.appendText("'");
-        }
-
-        @Override
-        public boolean matches(final Object argument)
-        {
-            _actual = argument;
-            return argument instanceof LogMessage && _expected.toString().equals((argument).toString());
+            return _expected.toString().equals((argument).toString());
         }
     }
 }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaKeyStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaKeyStoreTest.java
index 583ba8b..3d9dca7 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaKeyStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaKeyStoreTest.java
@@ -304,12 +304,11 @@
     }
 
 
-    private static class LogMessageArgumentMatcher extends ArgumentMatcher<LogMessage>
+    private static class LogMessageArgumentMatcher implements ArgumentMatcher<LogMessage>
     {
         @Override
-        public boolean matches(final Object argument)
+        public boolean matches(final LogMessage arg)
         {
-            LogMessage arg = (LogMessage)argument;
             return arg.getLogHierarchy().equals(KeyStoreMessages.EXPIRING_LOG_HIERARCHY);
         }
     }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index 4951b71..34cce96 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -215,7 +215,7 @@
         return argThat(new ConfiguredObjectMatcher(id, type, attributes, parents));
     }
 
-    private static class ConfiguredObjectMatcher extends ArgumentMatcher<ConfiguredObjectRecord>
+    private static class ConfiguredObjectMatcher implements ArgumentMatcher<ConfiguredObjectRecord>
     {
         private final Map<String,Object> _matchingMap;
         private final UUID _id;
@@ -231,23 +231,17 @@
         }
 
         @Override
-        public boolean matches(final Object argument)
+        public boolean matches(final ConfiguredObjectRecord binding)
         {
-            if(argument instanceof ConfiguredObjectRecord)
-            {
-                ConfiguredObjectRecord binding = (ConfiguredObjectRecord) argument;
-
-                Map<String,Object> arg = new HashMap<>(binding.getAttributes());
-                arg.remove("createdBy");
-                arg.remove("createdTime");
-                arg.remove("lastUpdatedTime");
-                arg.remove("lastUpdatedBy");
-                return (_id == ANY_UUID || _id.equals(binding.getId()))
-                       && _name.equals(binding.getType())
-                       && (_matchingMap == ANY_MAP || arg.equals(_matchingMap))
-                       && (_parents == ANY_MAP || matchesParents(binding));
-            }
-            return false;
+            Map<String,Object> arg = new HashMap<>(binding.getAttributes());
+            arg.remove("createdBy");
+            arg.remove("createdTime");
+            arg.remove("lastUpdatedTime");
+            arg.remove("lastUpdatedBy");
+            return (_id == ANY_UUID || _id.equals(binding.getId()))
+                   && _name.equals(binding.getType())
+                   && (_matchingMap == ANY_MAP || arg.equals(_matchingMap))
+                   && (_parents == ANY_MAP || matchesParents(binding));
         }
 
         private boolean matchesParents(ConfiguredObjectRecord binding)
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
index 2320610..38a508e 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
@@ -468,7 +468,7 @@
     }
 
 
-    private static class ConfiguredObjectMatcher extends ArgumentMatcher<ConfiguredObjectRecord>
+    private static class ConfiguredObjectMatcher implements ArgumentMatcher<ConfiguredObjectRecord>
     {
         private final Map<String,Object> _expectedAttributes;
         private final UUID _expectedId;
@@ -482,21 +482,14 @@
         }
 
         @Override
-        public boolean matches(final Object argument)
+        public boolean matches(final ConfiguredObjectRecord binding)
         {
-            if(argument instanceof ConfiguredObjectRecord)
-            {
-                ConfiguredObjectRecord binding = (ConfiguredObjectRecord) argument;
-
-                Map<String,Object> arg = new HashMap<String, Object>(binding.getAttributes());
-                arg.remove("createdBy");
-                arg.remove("createdTime");
-                return (_expectedId == ANY_UUID || _expectedId.equals(binding.getId()))
-                       && _expectedType.equals(binding.getType())
-                       && (_expectedAttributes == ANY_MAP || arg.equals(_expectedAttributes));
-
-            }
-            return false;
+            Map<String,Object> arg = new HashMap<>(binding.getAttributes());
+            arg.remove("createdBy");
+            arg.remove("createdTime");
+            return (_expectedId == ANY_UUID || _expectedId.equals(binding.getId()))
+                   && _expectedType.equals(binding.getType())
+                   && (_expectedAttributes == ANY_MAP || arg.equals(_expectedAttributes));
         }
     }
 
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java b/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
index 441b153..496e42e 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
@@ -479,37 +479,29 @@
         return enqueueableMessage1;
     }
 
-    private class MessageMetaDataMatcher extends ArgumentMatcher<StoredMessage<?>>
+    private class MessageMetaDataMatcher implements ArgumentMatcher<StoredMessage<?>>
     {
         private long _messageNumber;
 
-        public MessageMetaDataMatcher(long messageNumber)
+        MessageMetaDataMatcher(long messageNumber)
         {
             super();
             _messageNumber = messageNumber;
         }
 
         @Override
-        public boolean matches(Object obj)
+        public boolean matches(StoredMessage<?> obj)
         {
-            return obj instanceof StoredMessage && ((StoredMessage<?>)obj).getMessageNumber() == _messageNumber;
+            return obj.getMessageNumber() == _messageNumber;
         }
-
-        @Override
-        public void describeTo(final Description description)
-        {
-            description.appendText("Expected messageNumber:");
-            description.appendValue(_messageNumber);
-        }
-
     }
 
     private class QueueFilteringMessageInstanceHandler implements MessageInstanceHandler
     {
         private final UUID _queueId;
-        private final Set<Long> _enqueuedIds = new HashSet<Long>();
+        private final Set<Long> _enqueuedIds = new HashSet<>();
 
-        public QueueFilteringMessageInstanceHandler(UUID queueId)
+        QueueFilteringMessageInstanceHandler(UUID queueId)
         {
             _queueId = queueId;
         }
@@ -529,109 +521,93 @@
             return true;
         }
 
-        public Set<Long> getEnqueuedIds()
+        Set<Long> getEnqueuedIds()
         {
             return _enqueuedIds;
         }
     }
 
-    private class EnqueueRecordMatcher extends ArgumentMatcher<MessageEnqueueRecord>
+    private class EnqueueRecordMatcher implements ArgumentMatcher<MessageEnqueueRecord>
     {
         private final UUID _queueId;
         private final long _messageId;
 
-        public EnqueueRecordMatcher(final UUID queueId, final long messageId)
+        EnqueueRecordMatcher(final UUID queueId, final long messageId)
         {
             _queueId = queueId;
             _messageId = messageId;
         }
 
         @Override
-        public boolean matches(final Object argument)
+        public boolean matches(final MessageEnqueueRecord record)
         {
-            if(argument instanceof MessageEnqueueRecord)
-            {
-                MessageEnqueueRecord record = (MessageEnqueueRecord)argument;
-                return record.getQueueId().equals(_queueId) && record.getMessageNumber() == _messageId;
-            }
-            return false;
+            return record.getQueueId().equals(_queueId) && record.getMessageNumber() == _messageId;
         }
     }
 
 
-    private class RecordMatcher extends ArgumentMatcher<Transaction.EnqueueRecord[]>
+    private class RecordMatcher implements ArgumentMatcher<Transaction.EnqueueRecord[]>
     {
 
         private final EnqueueRecord[] _expect;
 
-        public RecordMatcher(Transaction.EnqueueRecord[] expect)
+        RecordMatcher(Transaction.EnqueueRecord[] expect)
         {
             _expect = expect;
         }
 
         @Override
-        public boolean matches(final Object argument)
+        public boolean matches(final Transaction.EnqueueRecord[] actual)
         {
-            if(argument.getClass().isArray() && Transaction.EnqueueRecord.class.isAssignableFrom(argument.getClass().getComponentType()))
+            if(actual.length == _expect.length)
             {
-                Transaction.EnqueueRecord[] actual = (Transaction.EnqueueRecord[]) argument;
-                if(actual.length == _expect.length)
+                for(int i = 0; i < actual.length; i++)
                 {
-                    for(int i = 0; i < actual.length; i++)
+                    if(!actual[i].getResource().getId().equals(_expect[i].getResource().getId())
+                       || actual[i].getMessage().getMessageNumber() != _expect[i].getMessage().getMessageNumber())
                     {
-                        if(!actual[i].getResource().getId().equals(_expect[i].getResource().getId())
-                                || actual[i].getMessage().getMessageNumber() != _expect[i].getMessage().getMessageNumber())
-                        {
-                            return false;
-                        }
+                        return false;
                     }
-                    return true;
                 }
-                else
-                {
-                    return false;
-                }
-
+                return true;
             }
-            return false;
+            else
+            {
+                return false;
+            }
+
         }
     }
 
-    private class DequeueRecordMatcher extends ArgumentMatcher<Transaction.DequeueRecord[]>
+    private class DequeueRecordMatcher implements ArgumentMatcher<Transaction.DequeueRecord[]>
     {
 
         private final Transaction.DequeueRecord[] _expect;
 
-        public DequeueRecordMatcher(Transaction.DequeueRecord[] expect)
+        DequeueRecordMatcher(Transaction.DequeueRecord[] expect)
         {
             _expect = expect;
         }
 
         @Override
-        public boolean matches(final Object argument)
+        public boolean matches(final Transaction.DequeueRecord[] actual)
         {
-            if(argument.getClass().isArray() && Transaction.DequeueRecord.class.isAssignableFrom(argument.getClass().getComponentType()))
+            if(actual.length == _expect.length)
             {
-                Transaction.DequeueRecord[] actual = (Transaction.DequeueRecord[]) argument;
-                if(actual.length == _expect.length)
+                for(int i = 0; i < actual.length; i++)
                 {
-                    for(int i = 0; i < actual.length; i++)
+                    if(!actual[i].getEnqueueRecord().getQueueId().equals(_expect[i].getEnqueueRecord().getQueueId())
+                       || actual[i].getEnqueueRecord().getMessageNumber() != _expect[i].getEnqueueRecord().getMessageNumber())
                     {
-                        if(!actual[i].getEnqueueRecord().getQueueId().equals(_expect[i].getEnqueueRecord().getQueueId())
-                           || actual[i].getEnqueueRecord().getMessageNumber() != _expect[i].getEnqueueRecord().getMessageNumber())
-                        {
-                            return false;
-                        }
+                        return false;
                     }
-                    return true;
                 }
-                else
-                {
-                    return false;
-                }
-
+                return true;
             }
-            return false;
+            else
+            {
+                return false;
+            }
         }
     }
 }
diff --git a/broker-core/src/test/java/org/apache/qpid/server/virtualhost/AsynchronousMessageStoreRecovererTest.java b/broker-core/src/test/java/org/apache/qpid/server/virtualhost/AsynchronousMessageStoreRecovererTest.java
index deef1e6..830ee9f 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/virtualhost/AsynchronousMessageStoreRecovererTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/virtualhost/AsynchronousMessageStoreRecovererTest.java
@@ -145,19 +145,9 @@
 
         verify(orphanedMessage, times(1)).remove();
         verify(newMessage, times(0)).remove();
-        verify(queue).recover(argThat(new ArgumentMatcher<ServerMessage>()
-        {
-            @Override
-            public boolean matches(final Object argument)
-            {
-                if (argument instanceof ServerMessage)
-                {
-                    ServerMessage serverMessage = (ServerMessage)argument;
-                    return serverMessage.getMessageNumber() == storedMessage.getMessageNumber();
-                }
-                return false;
-            }
-        }), same(messageEnqueueRecord));
+        verify(queue).recover(argThat((ArgumentMatcher<ServerMessage>) serverMessage -> serverMessage.getMessageNumber()
+                                                                                        == storedMessage.getMessageNumber()),
+                              same(messageEnqueueRecord));
     }
 
     private StoredMessage<?> createTestMessage(final long messageNumber)
diff --git a/broker-core/src/test/java/org/apache/qpid/server/virtualhost/SynchronousMessageStoreRecovererTest.java b/broker-core/src/test/java/org/apache/qpid/server/virtualhost/SynchronousMessageStoreRecovererTest.java
index 666ad0e..1cf562f 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/virtualhost/SynchronousMessageStoreRecovererTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/virtualhost/SynchronousMessageStoreRecovererTest.java
@@ -300,7 +300,7 @@
         branch.commit();
 
         ServerMessage<?> message = storedMessage.getMetaData().getType().createMessage(storedMessage);
-        verify(queue, times(1)).enqueue(eq(message), (Action<? super MessageInstance>)isNull(), any(MessageEnqueueRecord.class));
+        verify(queue, times(1)).enqueue(eq(message), isNull(), isNull());
         verify(transaction).commitTran();
     }
 
@@ -450,7 +450,7 @@
     }
 
 
-    private final class MessageEnqueueRecordMatcher extends ArgumentMatcher<MessageEnqueueRecord>
+    private final class MessageEnqueueRecordMatcher implements ArgumentMatcher<MessageEnqueueRecord>
     {
         private final long _messageId;
         private final UUID _queueId;
@@ -462,11 +462,10 @@
         }
 
         @Override
-        public boolean matches(Object argument)
+        public boolean matches(MessageEnqueueRecord argument)
         {
-            return argument instanceof MessageEnqueueRecord
-                    && ((MessageEnqueueRecord)argument).getMessageNumber() == _messageId
-                    && ((MessageEnqueueRecord)argument).getQueueId().equals(_queueId);
+            return argument.getMessageNumber() == _messageId
+                    && argument.getQueueId().equals(_queueId);
         }
     }
 
@@ -475,7 +474,7 @@
         private final UUID _queueId;
         private final long _messageId;
 
-        public TestMessageEnqueueRecord(final UUID queueId, final long messageId)
+        TestMessageEnqueueRecord(final UUID queueId, final long messageId)
         {
             _queueId = queueId;
             _messageId = messageId;
diff --git a/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java b/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
index f7d3f31..45a20c0 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
@@ -87,12 +87,11 @@
     @Before
     public void setUp() throws Exception
     {
-
+        _taskExecutor = new CurrentThreadTaskExecutor();
         _broker = BrokerTestHelper.createBrokerMock();
         SystemConfig<?> systemConfig = (SystemConfig<?>) _broker.getParent();
         when(systemConfig.getObjectFactory()).thenReturn(new ConfiguredObjectFactoryImpl(mock(Model.class)));
 
-        _taskExecutor = new CurrentThreadTaskExecutor();
         _taskExecutor.start();
         when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
         when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
diff --git a/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/ClientActionTest.java b/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/ClientActionTest.java
index 2135688..e4f33c8 100644
--- a/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/ClientActionTest.java
+++ b/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/ClientActionTest.java
@@ -45,6 +45,7 @@
     {
         when(_action.matches(any(Action.class))).thenReturn(true);
         when(_ruleAction.getFirewallRule()).thenReturn(null);
+        when(_ruleAction.getAction()).thenReturn(mock(Action.class));
 
         assertTrue(_clientAction.matches(_ruleAction, _addressOfClient));
     }
@@ -57,6 +58,7 @@
 
         when(_action.matches(any(Action.class))).thenReturn(false);
         when(_ruleAction.getFirewallRule()).thenReturn(firewallRule);
+        when(_ruleAction.getAction()).thenReturn(mock(Action.class));
 
         assertFalse(_clientAction.matches(_ruleAction, _addressOfClient));
     }
@@ -69,6 +71,7 @@
 
         when(_action.matches(any(Action.class))).thenReturn(true);
         when(_ruleAction.getFirewallRule()).thenReturn(firewallRule);
+        when(_ruleAction.getAction()).thenReturn(mock(Action.class));
 
         assertTrue(_clientAction.matches(_ruleAction, _addressOfClient));
     }
@@ -80,6 +83,7 @@
 
         when(_action.matches(any(Action.class))).thenReturn(true);
         when(_ruleAction.getFirewallRule()).thenReturn(firewallRule);
+        when(_ruleAction.getAction()).thenReturn(mock(Action.class));
 
         assertTrue(_clientAction.matches(_ruleAction, null));
 
diff --git a/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegateTest.java b/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegateTest.java
index ada7004..f731822 100644
--- a/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegateTest.java
+++ b/broker-plugins/amqp-0-10-protocol/src/test/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegateTest.java
@@ -69,16 +69,10 @@
         final ExchangeDelete method = new ExchangeDelete(getTestName(), Option.IF_UNUSED);
         _delegate.exchangeDelete(_session, method);
 
-        verify(_session).invoke(argThat(new ArgumentMatcher<ExecutionException>()
-        {
-            @Override
-            public boolean matches(Object object)
-            {
-                ExecutionException exception = (ExecutionException)object;
-                return exception.getErrorCode() == ExecutionErrorCode.PRECONDITION_FAILED
-                        && "Exchange has bindings".equals(exception.getDescription());
-            }
-        }));
+        verify(_session).invoke(argThat((ArgumentMatcher<ExecutionException>) exception -> exception.getErrorCode()
+                                                                                           == ExecutionErrorCode.PRECONDITION_FAILED
+                                                                                           && "Exchange has bindings".equals(
+                exception.getDescription())));
     }
 
     @Test
diff --git a/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Test.java b/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Test.java
index 509ad8b..d235b4b 100644
--- a/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Test.java
+++ b/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Test.java
@@ -163,6 +163,7 @@
         _network = mock(ServerNetworkConnection.class);
         when(_network.getSender()).thenReturn(_sender);
         when(_network.getLocalAddress()).thenReturn(new InetSocketAddress("localhost", 12345));
+        when(_network.getSelectedHost()).thenReturn("localhost");
 
         _transport = Transport.TCP;
         _protocol = Protocol.AMQP_0_8;
diff --git a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0Test.java b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0Test.java
index 5cd74f5..d91a5ac 100644
--- a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0Test.java
+++ b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0Test.java
@@ -95,6 +95,7 @@
     {
         _networkConnection = mock(ServerNetworkConnection.class);
         when(_networkConnection.getLocalAddress()).thenReturn(new InetSocketAddress(0));
+        when(_networkConnection.getSelectedHost()).thenReturn("localhost");
         _broker = mock(Broker.class);
         when(_broker.getModel()).thenReturn(BrokerModel.getInstance());
         when(_broker.getNetworkBufferSize()).thenReturn(256*1026);
diff --git a/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/RollingPolicyDecoratorTest.java b/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/RollingPolicyDecoratorTest.java
index d6d798e..e2c54ac 100644
--- a/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/RollingPolicyDecoratorTest.java
+++ b/broker-plugins/logging-logback/src/test/java/org/apache/qpid/server/logging/logback/RollingPolicyDecoratorTest.java
@@ -48,6 +48,7 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.ArgumentMatcher;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.slf4j.Logger;
@@ -144,7 +145,7 @@
         _policy.rollover();
         verify(_delegate).rollover();
 
-        Matcher<String[]> matcher = getMatcher(new String[]{_testFile.getName()});
+        ArgumentMatcher<String[]> matcher = getMatcher(new String[]{_testFile.getName()});
         verify(_listener).onRollover(eq(_baseFolder.toPath()), argThat(matcher));
     }
 
@@ -153,7 +154,7 @@
     {
         _policy.rollover();
         verify(_delegate).rollover();
-        Matcher<String[]> matcher = getMatcher(new String[]{_testFile.getName()});
+        ArgumentMatcher<String[]> matcher = getMatcher(new String[]{_testFile.getName()});
         verify(_listener).onRollover(eq(_baseFolder.toPath()), argThat(matcher));
         _policy.rollover();
         verify(_delegate, times(2)).rollover();
@@ -166,32 +167,20 @@
         _policy.rollover();
         verify(_delegate).rollover();
 
-        Matcher<String[]> matcher = getMatcher(new String[]{ _testFile.getName() });
+        ArgumentMatcher<String[]> matcher = getMatcher(new String[]{ _testFile.getName() });
         verify(_listener).onRollover(eq(_baseFolder.toPath()), argThat(matcher));
 
         File secondFile = createTestFile("test.2015-06-25.1.gz");
         _policy.rollover();
         verify(_delegate, times(2)).rollover();
-        Matcher<String[]> matcher2 = getMatcher(new String[]{_testFile.getName(), secondFile.getName()});
+        ArgumentMatcher<String[]> matcher2 = getMatcher(new String[]{_testFile.getName(), secondFile.getName()});
         verify(_listener).onRollover(eq(_baseFolder.toPath()), argThat(matcher2));
     }
 
 
-    private Matcher<String[]> getMatcher(final String[] expected)
+    private ArgumentMatcher<String[]> getMatcher(final String[] expected)
     {
-        return new BaseMatcher<String[]>()
-        {
-            @Override
-            public boolean matches(Object item)
-            {
-                return Arrays.equals(expected, (String[]) item);
-            }
-            @Override
-            public void describeTo(Description description)
-            {
-                description.appendValueList("[", ",", "]", expected);
-            }
-        };
+        return item -> Arrays.equals(expected, item);
     }
 
     @Test
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java
index 0b5f88a..435b7e0 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java
@@ -399,6 +399,7 @@
         when(mockRequest.getRequestURL()).thenReturn(url);
         when(mockRequest.getRemoteHost()).thenReturn(TEST_REMOTE_HOST);
         when(mockRequest.getRemotePort()).thenReturn(TEST_REMOTE_PORT);
+        when(mockRequest.getServerName()).thenReturn(TEST_REMOTE_HOST);
 
 
         return mockRequest;
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java
index ba8f6ee..5c682d2 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java
@@ -75,6 +75,7 @@
     public void testAttemptAuthenticationSuccessful() throws Exception
     {
         HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+        when(mockRequest.getServerName()).thenReturn("localhost");
         when(mockRequest.getHeader("Authorization")).thenReturn("Bearer " + TEST_VALID_ACCESS_TOKEN);
         Subject subject = _authenticator.attemptAuthentication(mockRequest, _mockConfiguration);
         assertNotNull("Authenticator failed unexpectedly", subject);
@@ -89,6 +90,7 @@
     public void testAttemptAuthenticationUnauthorizedUser() throws Exception
     {
         HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+        when(mockRequest.getServerName()).thenReturn("localhost");
         when(mockRequest.getHeader("Authorization")).thenReturn("Bearer " + TEST_UNAUTHORIZED_ACCESS_TOKEN);
         Subject subject = _authenticator.attemptAuthentication(mockRequest, _mockConfiguration);
         assertNotNull("Authenticator failed unexpectedly", subject);
@@ -102,6 +104,7 @@
     public void testAttemptAuthenticationInvalidToken() throws Exception
     {
         HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+        when(mockRequest.getServerName()).thenReturn("localhost");
         when(mockRequest.getHeader("Authorization")).thenReturn("Bearer " + TEST_INVALID_ACCESS_TOKEN);
         Subject subject = _authenticator.attemptAuthentication(mockRequest, _mockConfiguration);
         assertNull("Authenticator did not fail with invalid access token", subject);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/portunification/TlsOrPlainConnectionFactoryTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/portunification/TlsOrPlainConnectionFactoryTest.java
index a278fac..7ed8134 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/portunification/TlsOrPlainConnectionFactoryTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/portunification/TlsOrPlainConnectionFactoryTest.java
@@ -73,7 +73,7 @@
         when(sslEngine.getSession()).thenReturn(sslSession);
         when(sslSession.getPacketBufferSize()).thenReturn(Integer.MAX_VALUE);
 
-        _factory = new TlsOrPlainConnectionFactory(_sslContextFactory, null);
+        _factory = new TlsOrPlainConnectionFactory(_sslContextFactory, "test");
 
         _actualConnection = mock(AbstractConnection.class);
 
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java
index 1a5277c..cd690dd 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporterTest.java
@@ -74,14 +74,6 @@
 
     private LogMessage isLogMessageWithMessage(final String expectedMessage)
     {
-        return argThat( new ArgumentMatcher<LogMessage>()
-        {
-            @Override
-            public boolean matches(Object argument)
-            {
-                LogMessage actual = (LogMessage) argument;
-                return actual.toString().equals(expectedMessage);
-            }
-        });
+        return argThat(actual -> actual.toString().equals(expectedMessage));
     }
 }
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java b/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
index f508b0d..cfc5fb7 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
@@ -102,12 +102,11 @@
         }
     }
 
-    private static class ResultHasError extends ArgumentMatcher<ParticipantResult>
+    private static class ResultHasError implements ArgumentMatcher<ParticipantResult>
     {
         @Override
-        public boolean matches(Object argument)
+        public boolean matches(ParticipantResult result)
         {
-            ParticipantResult result = (ParticipantResult) argument;
             return result.hasError();
         }
     }
diff --git a/pom.xml b/pom.xml
index 6f30bb3..429cca3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,7 +128,7 @@
 
     <!-- test dependency version numbers -->
     <junit-version>4.11</junit-version>
-    <mockito-version>1.9.5</mockito-version>
+    <mockito-version>2.22.0</mockito-version>
     <netty-version>4.1.28.Final</netty-version>
     <hamcrest-version>1.3</hamcrest-version>
     <maven-core-version>3.5.0</maven-core-version>
@@ -212,7 +212,7 @@
 
     <dependency>
       <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
+      <artifactId>mockito-core</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>
@@ -611,7 +611,7 @@
       </dependency>
       <dependency>
         <groupId>org.mockito</groupId>
-        <artifactId>mockito-all</artifactId>
+        <artifactId>mockito-core</artifactId>
         <version>${mockito-version}</version>
         <scope>test</scope>
       </dependency>
diff --git a/qpid-systests-parent/pom.xml b/qpid-systests-parent/pom.xml
index 6fb8b0d..f63a2fe 100644
--- a/qpid-systests-parent/pom.xml
+++ b/qpid-systests-parent/pom.xml
@@ -45,7 +45,7 @@
 
     <dependency>
       <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
+      <artifactId>mockito-core</artifactId>
       <version>${mockito-version}</version>
       <scope>compile</scope>
     </dependency>