Search in sources :

Example 36 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class NavigationXmlLoadTest method testNavigationRegistration.

/**
 * testNavigationRegistration - Verifies that the navigation.xml has been loaded correctly into the NavigationManager.
 */
@Test
public void testNavigationRegistration() {
    NavigationManager navigationManager = xmlLoaderConfig.getBean(NavigationManager.class);
    ContextKey key = new ContextKey("CONTRACTOR", "roles.xml", "DEF", "100-Highest");
    assertNull(navigationManager.getNavigationRepository().query(key));
    GlobalMenu globalMenu = new GlobalMenu();
    MenuOption menuOption = new MenuOption();
    menuOption.setLabel("Label 1");
    globalMenu.getMenuOption().add(menuOption);
    navigationManager.registerGlobalMenu(key, globalMenu);
    assertNotNull(navigationManager.getNavigationRepository().query(key));
    navigationManager.unregisterGlobalMenu(key);
    assertNull(navigationManager.getNavigationRepository().query(key));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) MenuOption(org.jaffa.components.navigation.domain.MenuOption) GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu) Test(org.junit.Test)

Example 37 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class MessagingManagerTest method testCheckForQueueAndTopicNamingConflictsNoConflict.

/**
 * Test that no conflict is reported when no topics and queues have
 * identical names.
 * @throws Exception
 */
@Test
public void testCheckForQueueAndTopicNamingConflictsNoConflict() throws Exception {
    String[] queueNames = messagingManager.getQueueNames();
    assertEquals(0, queueNames.length);
    QueueInfo qInfo = new QueueInfo();
    String queueName = "q1";
    qInfo.setName(queueName);
    ContextKey contextKey = new ContextKey(queueName, "jaffa-messaging-config.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
    messagingManager.registerQueueInfo(contextKey, qInfo);
    queueNames = messagingManager.getQueueNames();
    assertEquals(1, queueNames.length);
    String[] topicNames = messagingManager.getTopicNames();
    assertEquals(0, topicNames.length);
    TopicInfo topicInfo = new TopicInfo();
    String topicName = "t1";
    topicInfo.setName(topicName);
    contextKey = new ContextKey(topicName, "jaffa-messaging-config.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
    messagingManager.registerTopicInfo(contextKey, topicInfo);
    topicNames = messagingManager.getTopicNames();
    assertEquals(1, topicNames.length);
    messagingManager.checkForQueueAndTopicNamingConflicts();
// an exception would be thrown if there were identical names
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Test(org.junit.Test)

Example 38 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class TransactionManagerTest method testRegisterTypeInfo.

/**
 * tests the registerTypeInfo
 */
@Test
public void testRegisterTypeInfo() {
    // initialize
    TypeInfo typeInfo = new TypeInfo();
    typeInfo.setName("typeInfoName");
    ContextKey key = new ContextKey("typeInfoName", null, "DEF", "cust-code");
    // test
    transactionManager.registerTypeInfo(key, typeInfo);
    // verify
    verify(typeInfoRepoMock).register(eq(key), Matchers.anyObject());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) Test(org.junit.Test)

Example 39 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class JndiJmsManager method registerResource.

/**
 * Unmarshall the contents of the configuration to create and register
 * JmsConfig objects.
 * @param resource the object that contains the xml config file.
 * @param context key with which config file to be registered.
 * @param variation key with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    JndiConfig config = JAXBHelper.unmarshalConfigFile(JndiConfig.class, resource, JMS_JNDI_CONFIGURATION_SCHEMA_FILE);
    JmsConfig jmsConfig = config.getJmsConfig();
    populateJmsConfig(jmsConfig);
    ContextKey contextKey = new ContextKey(jmsConfig.getUser(), resource.getURI().toString(), variation, context);
    jmsRepository.register(contextKey, jmsConfig);
}
Also used : JndiConfig(org.jaffa.modules.messaging.services.configdomain.JndiConfig) ContextKey(org.jaffa.loader.ContextKey) JmsConfig(org.jaffa.modules.messaging.services.configdomain.JmsConfig)

Example 40 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class JndiJmsManager method unregisterResource.

/**
 * Unregister the JmsConfig objects defined by a particular resource.
 * @param resource the object that contains the xml config file.
 * @param context key with which config file to be registered.
 * @param variation key with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    JndiConfig config = JAXBHelper.unmarshalConfigFile(JndiConfig.class, resource, JMS_JNDI_CONFIGURATION_SCHEMA_FILE);
    JmsConfig jmsConfig = config.getJmsConfig();
    ContextKey contextKey = new ContextKey(jmsConfig.getUser(), resource.getURI().toString(), variation, context);
    jmsRepository.unregister(contextKey);
}
Also used : JndiConfig(org.jaffa.modules.messaging.services.configdomain.JndiConfig) ContextKey(org.jaffa.loader.ContextKey) JmsConfig(org.jaffa.modules.messaging.services.configdomain.JmsConfig)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)49 Test (org.junit.Test)21 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 Properties (java.util.Properties)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 InputStream (java.io.InputStream)2 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