use of org.apache.activemq.artemis.core.config.FileDeploymentManager in project activemq-artemis by apache.
the class FileConfigurationParserTest method testDivertRoutingNameIsNotRequired.
@Test
public void testDivertRoutingNameIsNotRequired() throws Exception {
String filename = "divertRoutingNameNotRequired.xml";
FileConfiguration fc = new FileConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager(filename);
deploymentManager.addDeployable(fc);
deploymentManager.readConfiguration();
}
use of org.apache.activemq.artemis.core.config.FileDeploymentManager in project activemq-artemis by apache.
the class FileConfigurationTest method testSecuritySettingPlugin.
@Test
public void testSecuritySettingPlugin() throws Exception {
FileConfiguration fc = new FileConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager("securitySettingPlugin.xml");
deploymentManager.addDeployable(fc);
deploymentManager.readConfiguration();
List<SecuritySettingPlugin> securitySettingPlugins = fc.getSecuritySettingPlugins();
SecuritySettingPlugin securitySettingPlugin = securitySettingPlugins.get(0);
assertTrue(securitySettingPlugin instanceof LegacyLDAPSecuritySettingPlugin);
LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = (LegacyLDAPSecuritySettingPlugin) securitySettingPlugin;
assertEquals(legacyLDAPSecuritySettingPlugin.getInitialContextFactory(), "testInitialContextFactory");
assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionURL(), "testConnectionURL");
assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionUsername(), "testConnectionUsername");
assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionPassword(), "testConnectionPassword");
assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionProtocol(), "testConnectionProtocol");
assertEquals(legacyLDAPSecuritySettingPlugin.getAuthentication(), "testAuthentication");
assertEquals(legacyLDAPSecuritySettingPlugin.getDestinationBase(), "testDestinationBase");
assertEquals(legacyLDAPSecuritySettingPlugin.getFilter(), "testFilter");
assertEquals(legacyLDAPSecuritySettingPlugin.getRoleAttribute(), "testRoleAttribute");
assertEquals(legacyLDAPSecuritySettingPlugin.getAdminPermissionValue(), "testAdminPermissionValue");
assertEquals(legacyLDAPSecuritySettingPlugin.getReadPermissionValue(), "testReadPermissionValue");
assertEquals(legacyLDAPSecuritySettingPlugin.getWritePermissionValue(), "testWritePermissionValue");
assertEquals(legacyLDAPSecuritySettingPlugin.isEnableListener(), false);
}
use of org.apache.activemq.artemis.core.config.FileDeploymentManager in project activemq-artemis by apache.
the class FileConfigurationTest method testContextClassLoaderUsage.
@Test
public void testContextClassLoaderUsage() throws Exception {
final File customConfiguration = File.createTempFile("hornetq-unittest", ".xml");
try {
// copy working configuration to a location where the standard classloader cannot find it
final Path workingConfiguration = new File(getClass().getResource("/" + getConfigurationName()).toURI()).toPath();
final Path targetFile = customConfiguration.toPath();
Files.copy(workingConfiguration, targetFile, StandardCopyOption.REPLACE_EXISTING);
// build a custom classloader knowing the location of the config created above (used as context class loader)
final URL customConfigurationDirUrl = customConfiguration.getParentFile().toURI().toURL();
final ClassLoader testWebappClassLoader = new URLClassLoader(new URL[] { customConfigurationDirUrl });
final class ThrowableHolder {
volatile Exception t;
}
final ThrowableHolder holder = new ThrowableHolder();
final Thread webappContextThread = new Thread(new Runnable() {
@Override
public void run() {
FileConfiguration fileConfiguration = new FileConfiguration();
try {
FileDeploymentManager deploymentManager = new FileDeploymentManager(customConfiguration.getName());
deploymentManager.addDeployable(fileConfiguration);
deploymentManager.readConfiguration();
} catch (Exception e) {
holder.t = e;
}
}
});
webappContextThread.setContextClassLoader(testWebappClassLoader);
webappContextThread.start();
webappContextThread.join();
if (holder.t != null) {
fail("Exception caught while loading configuration with the context class loader: " + holder.t.getMessage());
}
} finally {
customConfiguration.delete();
}
}
use of org.apache.activemq.artemis.core.config.FileDeploymentManager in project activemq-artemis by apache.
the class FileConfigurationTest method testSecurityRoleMapping.
@Test
public void testSecurityRoleMapping() throws Exception {
FileConfiguration fc = new FileConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager("securityRoleMappings.xml");
deploymentManager.addDeployable(fc);
deploymentManager.readConfiguration();
Map<String, Set<Role>> securityRoles = fc.getSecurityRoles();
Set<Role> roles = securityRoles.get("#");
// cn=mygroup,dc=local,dc=com = amq1
Role testRole1 = new Role("cn=mygroup,dc=local,dc=com", false, false, false, false, true, false, false, false, false, false);
// myrole1 = amq1 + amq2
Role testRole2 = new Role("myrole1", false, false, false, false, true, true, false, false, false, false);
// myrole3 = amq3 + amq4
Role testRole3 = new Role("myrole3", false, false, true, true, false, false, false, false, false, false);
// myrole4 = amq5 + amq!@#$%^&*() + amq6
Role testRole4 = new Role("myrole4", true, true, false, false, false, false, false, true, true, true);
// myrole5 = amq4 = amq3 + amq4
Role testRole5 = new Role("myrole5", false, false, true, true, false, false, false, false, false, false);
Role testRole6 = new Role("amq1", false, false, false, false, true, false, false, false, false, false);
Role testRole7 = new Role("amq2", false, false, false, false, false, true, false, false, false, false);
Role testRole8 = new Role("amq3", false, false, true, false, false, false, false, false, false, false);
Role testRole9 = new Role("amq4", false, false, true, true, false, false, false, false, false, false);
Role testRole10 = new Role("amq5", false, false, false, false, false, false, false, false, true, true);
Role testRole11 = new Role("amq6", false, true, false, false, false, false, false, true, false, false);
Role testRole12 = new Role("amq7", false, false, false, false, false, false, true, false, false, false);
Role testRole13 = new Role("amq!@#$%^&*()", true, false, false, false, false, false, false, false, false, false);
assertEquals(13, roles.size());
assertTrue(roles.contains(testRole1));
assertTrue(roles.contains(testRole2));
assertTrue(roles.contains(testRole3));
assertTrue(roles.contains(testRole4));
assertTrue(roles.contains(testRole5));
assertTrue(roles.contains(testRole6));
assertTrue(roles.contains(testRole7));
assertTrue(roles.contains(testRole8));
assertTrue(roles.contains(testRole9));
assertTrue(roles.contains(testRole10));
assertTrue(roles.contains(testRole11));
assertTrue(roles.contains(testRole12));
assertTrue(roles.contains(testRole13));
}
use of org.apache.activemq.artemis.core.config.FileDeploymentManager in project activemq-artemis by apache.
the class FileConfigurationTest method createConfiguration.
@Override
protected Configuration createConfiguration() throws Exception {
FileConfiguration fc = new FileConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager(getConfigurationName());
deploymentManager.addDeployable(fc);
deploymentManager.readConfiguration();
return fc;
}
Aggregations