diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-04-20 17:00:46 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-04-20 17:00:46 +0000 |
| commit | 130ff22d820d9c20a1bc7545031954ae59dad0ef (patch) | |
| tree | bfe88e4d58c61d9f5c0a4e56dc9c5a51f39579d6 /qpid/java/broker-plugins/access-control/src | |
| parent | 3d34526bc2fe159b265d5a7c58ffd687ba00c499 (diff) | |
| download | qpid-python-130ff22d820d9c20a1bc7545031954ae59dad0ef.tar.gz | |
QPID-5713 : [Java Broker] Remove non-test references to model singleton, and instead treat as an instance variable
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1588794 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/access-control/src')
| -rw-r--r-- | qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java index 102cfb4be1..fab6ad1750 100644 --- a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java +++ b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java @@ -20,6 +20,9 @@ */ package org.apache.qpid.server.security.access.plugins; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.File; import java.util.HashMap; import java.util.Map; @@ -27,19 +30,32 @@ import java.util.UUID; import java.util.regex.Pattern; import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.logging.EventLoggerProvider; import org.apache.qpid.server.model.AccessControlProvider; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.BrokerModel; +import org.apache.qpid.server.model.ConfiguredObjectFactory; +import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl; import org.apache.qpid.server.model.GroupProvider; -import org.apache.qpid.server.security.AccessControl; import org.apache.qpid.server.security.access.FileAccessControlProviderConstants; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.test.utils.TestFileUtils; -import static org.mockito.Mockito.mock; - public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase { + private Broker _broker; + + @Override + public void setUp() throws Exception + { + super.setUp(); + _broker = mock(Broker.class); + ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance()); + + when(_broker.getObjectFactory()).thenReturn(objectFactory); + when(_broker.getModel()).thenReturn(objectFactory.getModel()); + when(_broker.getCategoryClass()).thenReturn(Broker.class); + } + public void testCreateInstanceWhenAclFileIsNotPresent() { ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory(); @@ -48,7 +64,7 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase attributes.put(AccessControlProvider.NAME, "acl"); try { - AccessControlProvider acl = factory.create(attributes, mock(Broker.class)); + AccessControlProvider acl = factory.create(null, attributes, _broker); fail("ACL was created without a configuration file path specified"); } catch(IllegalArgumentException e) @@ -66,7 +82,7 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase attributes.put(AccessControlProvider.NAME, "acl"); attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE); attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath()); - AccessControlProvider acl = factory.create(attributes, mock(Broker.class)); + AccessControlProvider acl = factory.create(null, attributes, _broker); acl.getAccessControl().open(); assertNotNull("ACL was not created from acl file: " + aclFile.getAbsolutePath(), acl); @@ -84,7 +100,7 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath()); try { - AccessControlProvider control = factory.create(attributes, mock(Broker.class)); + AccessControlProvider control = factory.create(null, attributes, _broker); control.getAccessControl().open(); fail("It should not be possible to create and initialise ACL with non existing file"); } |
