use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class ComponentResourceLoaderTest method testXmlLoad.
/**
* Test loading the XML config via the ComponentManager.
* (Assumes a certain components file with particular values in
* jaffa-framework/jaffa-core/target/test-classes/META-INF/components.xml)
*/
@Test
public void testXmlLoad() {
ComponentManager componentManager = xmlLoaderConfig.getBean(ComponentManager.class);
assertNull(componentManager.getComponentDefinition(null));
assertNull(componentManager.getComponentDefinition(""));
IRepository<ComponentDefinition> repository = componentManager.getComponentRepository();
List<ComponentDefinition> values = repository.getAllValues();
assertEquals(4, values.size());
Set<ContextKey> keys = repository.getAllKeys();
String rolesEditorKey = "Jaffa.Admin.RolesEditor";
ContextKey rolesEditorContextKey = new ContextKey(rolesEditorKey, "different-file.xml", "NULL", "100-Highest");
assertTrue(keys.contains(rolesEditorContextKey));
String testFunctionViewerKey = "Jaffa.UnitTest.TestFunctionViewer";
ContextKey testFunctionViewerContextKey = new ContextKey(testFunctionViewerKey, "different-file.xml", "NULL", "100-Highest");
assertTrue(keys.contains(testFunctionViewerContextKey));
ComponentDefinition reComponentDefinition = componentManager.getComponentDefinition(rolesEditorKey);
String reType = reComponentDefinition.getComponentType();
assertEquals("Custom", reType);
String[] optionals = reComponentDefinition.getOptionalFunctions();
assertEquals(0, optionals.length);
assertNull(reComponentDefinition.getParameters());
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class BusinessFunctionXmlLoadTest method testGetBusinessFunctionRegistration.
/**
* Verifies that we can register and unregister specific business functions provided by the client.
*/
@Test
public void testGetBusinessFunctionRegistration() {
BusinessFunctionManager businessFunctionManager = xmlLoaderConfig.getBean(BusinessFunctionManager.class);
assertNull(businessFunctionManager.getBusinessFunction("Jaffa.WebServices.Test"));
BusinessFunction businessFunction = new BusinessFunction();
ContextKey key = new ContextKey("Jaffa.WebServices.Test", "business-functions.xml", VariationContext.NULL_VARIATION, "100-Highest");
businessFunctionManager.registerBusinessFunction(key, businessFunction);
assertNotNull(businessFunctionManager.getBusinessFunction("Jaffa.WebServices.Test"));
businessFunctionManager.unregisterBusinessFunction(key);
assertNull(businessFunctionManager.getBusinessFunction("Jaffa.WebServices.Test"));
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class RoleXmlLoadTest method testRoleRegistration.
/**
* Verifies that we can register and unregsiter specific roles into the role repository.
*/
@Test
public void testRoleRegistration() {
RoleManager roleManager = xmlLoaderConfig.getBean(RoleManager.class);
assertNull(roleManager.getRole("CONTRACTOR"));
Role contractorRole = new Role();
GrantFunctionAccess grantFunctionAccess = new GrantFunctionAccess();
grantFunctionAccess.setName("Function 1");
contractorRole.getGrantFunctionAccess().add(grantFunctionAccess);
ContextKey key = new ContextKey("CONTRACTOR", "roles.xml", VariationContext.NULL_VARIATION, "100-Highest");
roleManager.registerRole(key, contractorRole);
assertNotNull(roleManager.getRole("CONTRACTOR"));
roleManager.unregisterRole(key);
assertNull(roleManager.getRole("CONTRACTOR"));
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class ComponentManagerTest method testGetRepositoryByName.
/**
* Tests the ability of this IManager to retrieve a repository when given its String name
*/
@Test
public void testGetRepositoryByName() throws Exception {
// A componentDefinition must be registered first
Component component = new Component();
String name = "q1";
component.setId(name);
ComponentDefinition definition = new ComponentDefinition(component);
ContextKey key = new ContextKey(name, "components.xml", "DEF", "0-PLATFORM");
manager.registerComponentDefinition(key, definition);
String repo = "ComponentDefinition";
assertEquals(repo, manager.getRepositoryByName(repo).getName());
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class MessagingManagerTest method testGetMessageFilters.
/**
* Tests registering and unregistering of MessageFilters.
* @throws Exception
*/
@Test
public void testGetMessageFilters() throws Exception {
List<MessageFilter> filterNames = messagingManager.getMessageFilters();
assertEquals(0, filterNames.size());
MessageFilter info = new MessageFilter();
String filterName = "q1";
info.setFilterName(filterName);
ContextKey contextKey1 = new ContextKey(filterName, "jaffa-messaging-config.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
messagingManager.registerMessageFilter(contextKey1, info);
filterNames = messagingManager.getMessageFilters();
assertEquals(1, filterNames.size());
MessageFilter info2 = new MessageFilter();
String filterName2 = "q2";
info2.setFilterName(filterName2);
ContextKey contextKey2 = new ContextKey(filterName2, "jaffa-messaging-config.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
messagingManager.registerMessageFilter(contextKey2, info2);
filterNames = messagingManager.getMessageFilters();
assertEquals(2, filterNames.size());
messagingManager.unregisterMessageFilter(contextKey1);
filterNames = messagingManager.getMessageFilters();
assertEquals(1, filterNames.size());
}
Aggregations