Search in sources :

Example 1 with ContextKey

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());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) ComponentDefinition(org.jaffa.presentation.portlet.component.ComponentDefinition) Test(org.junit.Test)

Example 2 with ContextKey

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"));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) BusinessFunction(org.jaffa.security.businessfunctionsdomain.BusinessFunction) Test(org.junit.Test)

Example 3 with ContextKey

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"));
}
Also used : Role(org.jaffa.security.securityrolesdomain.Role) ContextKey(org.jaffa.loader.ContextKey) GrantFunctionAccess(org.jaffa.security.securityrolesdomain.GrantFunctionAccess) Test(org.junit.Test)

Example 4 with ContextKey

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());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Component(org.jaffa.presentation.portlet.component.componentdomain.Component) ComponentDefinition(org.jaffa.presentation.portlet.component.ComponentDefinition) Test(org.junit.Test)

Example 5 with ContextKey

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());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Test(org.junit.Test)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)55 Test (org.junit.Test)21 Properties (java.util.Properties)6 ComponentDefinition (org.jaffa.presentation.portlet.component.ComponentDefinition)6 Component (org.jaffa.presentation.portlet.component.componentdomain.Component)5 TransactionInfo (org.jaffa.transaction.services.configdomain.TransactionInfo)5 TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)5 InputStream (java.io.InputStream)4 Task (org.jaffa.modules.scheduler.services.configdomain.Task)4 GlobalMenu (org.jaffa.components.navigation.domain.GlobalMenu)3 BusinessFunction (org.jaffa.security.businessfunctionsdomain.BusinessFunction)3 Role (org.jaffa.security.securityrolesdomain.Role)3 Config (org.jaffa.transaction.services.configdomain.Config)3 Config (org.jaffa.modules.messaging.services.configdomain.Config)2 JmsConfig (org.jaffa.modules.messaging.services.configdomain.JmsConfig)2 JndiConfig (org.jaffa.modules.messaging.services.configdomain.JndiConfig)2 Config (org.jaffa.modules.scheduler.services.configdomain.Config)2 Components (org.jaffa.presentation.portlet.component.componentdomain.Components)2 BusinessFunctions (org.jaffa.security.businessfunctionsdomain.BusinessFunctions)2 Roles (org.jaffa.security.securityrolesdomain.Roles)2