summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/access-control/src/test
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-04-30 01:22:13 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-04-30 01:22:13 +0000
commitae71aa7102a41735e49ec5c98409bc69fffd9a8f (patch)
treef0709ee8c5993d6995e5de59c0cdc855a540614e /qpid/java/broker-plugins/access-control/src/test
parent0d49f2fa419a414e1c9548001fcbde03d442f5c1 (diff)
downloadqpid-python-ae71aa7102a41735e49ec5c98409bc69fffd9a8f.tar.gz
QPID-5578 : [Java Broker] Use annotation to allow registration of all ConfiguredObject types at startup. Use this meta data for REST servlets. Remove unnecessary pluggable factory interfaces
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1591170 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/access-control/src/test')
-rw-r--r--qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java25
-rw-r--r--qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java2
2 files changed, 13 insertions, 14 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 fab6ad1750..01da01eb97 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
@@ -33,9 +33,7 @@ import org.apache.qpid.server.configuration.IllegalConfigurationException;
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.access.FileAccessControlProviderConstants;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
@@ -43,28 +41,30 @@ import org.apache.qpid.test.utils.TestFileUtils;
public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase
{
private Broker _broker;
+ private ConfiguredObjectFactoryImpl _objectFactory;
@Override
public void setUp() throws Exception
{
super.setUp();
_broker = mock(Broker.class);
- ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
+ _objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
- when(_broker.getObjectFactory()).thenReturn(objectFactory);
- when(_broker.getModel()).thenReturn(objectFactory.getModel());
+ when(_broker.getObjectFactory()).thenReturn(_objectFactory);
+ when(_broker.getModel()).thenReturn(_objectFactory.getModel());
when(_broker.getCategoryClass()).thenReturn(Broker.class);
}
public void testCreateInstanceWhenAclFileIsNotPresent()
{
- ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(AccessControlProvider.ID, UUID.randomUUID());
attributes.put(AccessControlProvider.NAME, "acl");
+ attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
+
try
{
- AccessControlProvider acl = factory.create(null, attributes, _broker);
+ AccessControlProvider acl = _objectFactory.create(AccessControlProvider.class, attributes, _broker);
fail("ACL was created without a configuration file path specified");
}
catch(IllegalArgumentException e)
@@ -73,16 +73,16 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase
}
}
+
public void testCreateInstanceWhenAclFileIsSpecified()
{
File aclFile = TestFileUtils.createTempFile(this, ".acl", "ACL ALLOW all all");
- ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(AccessControlProvider.ID, UUID.randomUUID());
attributes.put(AccessControlProvider.NAME, "acl");
- attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
+ attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath());
- AccessControlProvider acl = factory.create(null, attributes, _broker);
+ AccessControlProvider acl = _objectFactory.create(AccessControlProvider.class, attributes, _broker);
acl.getAccessControl().open();
assertNotNull("ACL was not created from acl file: " + aclFile.getAbsolutePath(), acl);
@@ -92,15 +92,14 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase
{
File aclFile = new File(TMP_FOLDER, "my-non-existing-acl-" + System.currentTimeMillis());
assertFalse("ACL file " + aclFile.getAbsolutePath() + " actually exists but should not", aclFile.exists());
- ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(AccessControlProvider.ID, UUID.randomUUID());
attributes.put(AccessControlProvider.NAME, "acl");
- attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
+ attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath());
try
{
- AccessControlProvider control = factory.create(null, attributes, _broker);
+ AccessControlProvider control = _objectFactory.create(AccessControlProvider.class, attributes, _broker);
control.getAccessControl().open();
fail("It should not be possible to create and initialise ACL with non existing file");
}
diff --git a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java
index 523640adad..0ce2555bcf 100644
--- a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java
+++ b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java
@@ -192,7 +192,7 @@ public class RuleSetTest extends QpidTestCase
ExchangeImpl<?> exchange = mock(ExchangeImpl.class);
when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost);
- when(exchange.getTypeName()).thenReturn(_exchangeType);
+ when(exchange.getType()).thenReturn(_exchangeType);
when(_virtualHost.getName()).thenReturn(ALLOWED_VH);
assertEquals(Result.ALLOWED, _ruleSet.check(_testSubject, Operation.CREATE, ObjectType.EXCHANGE, new ObjectProperties(exchange)));