Search in sources :

Example 16 with ContextKey

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

the class TransactionManager method unregisterXML.

/**
 * unregisters all the transactions and typeInfo in the xml from the repository
 * @param uri for the xml location
 */
public void unregisterXML(String uri, String context, String variation) throws JAXBException, SAXException, IOException {
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resolver.getResource(uri), CONFIGURATION_SCHEMA_FILE);
    if (config.getTransactionOrType() != null) {
        for (final Object o : config.getTransactionOrType()) {
            if (o.getClass() == TransactionInfo.class) {
                final TransactionInfo transactionInfo = (TransactionInfo) o;
                ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), uri, variation, context);
                unregisterTransactionInfo(contextKey);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), uri, variation, context);
                unregisterTypeInfo(contextKey);
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.transaction.services.configdomain.Config) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Example 17 with ContextKey

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

the class MessagingManagerTest method testCheckForQueueAndTopicNamingConflictsConflict.

/**
 * Test that no conflict is reported when no topics and queues have
 * identical names.
 * @throws Exception
 */
@Test
public void testCheckForQueueAndTopicNamingConflictsConflict() throws Exception {
    String[] queueNames = messagingManager.getQueueNames();
    assertEquals(0, queueNames.length);
    QueueInfo qInfo = new QueueInfo();
    String commonName = "q1";
    qInfo.setName(commonName);
    ContextKey contextKey = new ContextKey(commonName, "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();
    topicInfo.setName(commonName);
    messagingManager.registerTopicInfo(contextKey, topicInfo);
    topicNames = messagingManager.getTopicNames();
    assertEquals(1, topicNames.length);
    try {
        messagingManager.checkForQueueAndTopicNamingConflicts();
        fail("A topic and queue both had names of 'q1'");
    } catch (RuntimeException e) {
    // good - an exception would be thrown if there were identical names
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Test(org.junit.Test)

Example 18 with ContextKey

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

the class MessagingManagerTest method testGetTopicNames.

/**
 * Test that registering TopicInfo objects has the expected results
 * when requesting all topic names
 * @throws Exception
 */
@Test
public void testGetTopicNames() throws Exception {
    String[] topicNames = messagingManager.getTopicNames();
    assertEquals(0, topicNames.length);
    TopicInfo info = new TopicInfo();
    String topicName = "q1";
    info.setName(topicName);
    ContextKey contextKey1 = new ContextKey(topicName, "jaffa-messaging-config.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
    messagingManager.registerTopicInfo(contextKey1, info);
    topicNames = messagingManager.getTopicNames();
    assertEquals(1, topicNames.length);
    TopicInfo info2 = new TopicInfo();
    String topicName2 = "q2";
    info2.setName(topicName2);
    ContextKey contextKey2 = new ContextKey(topicName2, "jaffa-messaging-config.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
    messagingManager.registerTopicInfo(contextKey2, info2);
    topicNames = messagingManager.getTopicNames();
    assertEquals(2, topicNames.length);
    messagingManager.unregisterTopicInfo(contextKey1);
    topicNames = messagingManager.getTopicNames();
    assertEquals(1, topicNames.length);
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Test(org.junit.Test)

Example 19 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)

Example 20 with ContextKey

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

the class MessagingManagerTest method testGetName.

/**
 * Test the ability to retrieve a managed repository name
 */
@Test
public void testGetName() throws Exception {
    // MessageInfoRepository
    MessageInfo info = new MessageInfo();
    String queueName = "q1";
    info.setQueueName(queueName);
    ContextKey contextKey = new ContextKey(queueName, "jaffa-messaging-config.xml", "DEF", "0-PLATFORM");
    messagingManager.registerMessageInfo(contextKey, info);
    assertEquals("MessageInfo", messagingManager.getRepositoryByName("MessageInfo").getName());
    // MessageFilterRepository
    MessageFilter filter = new MessageFilter();
    String name = "q1";
    filter.setFilterName(name);
    contextKey = new ContextKey(name, "jaffa-messaging-config.xml", "DEF", "0-PLATFORM");
    messagingManager.registerMessageFilter(contextKey, filter);
    assertEquals("MessageFilter", messagingManager.getRepositoryByName("MessageFilter").getName());
    // TopicInfoRepository
    TopicInfo topicInfo = new TopicInfo();
    String topicName = "t1";
    topicInfo.setName(topicName);
    contextKey = new ContextKey(topicName, "jaffa-messaging-config.xml", "DEF", "0-PLATFORM");
    messagingManager.registerTopicInfo(contextKey, topicInfo);
    assertEquals("TopicInfo", messagingManager.getRepositoryByName("TopicInfo").getName());
    // QueueInfoRepository
    QueueInfo qInfo = new QueueInfo();
    String commonName = "q1";
    qInfo.setName(commonName);
    contextKey = new ContextKey(commonName, "jaffa-messaging-config.xml", "DEF", "0-PLATFORM");
    messagingManager.registerQueueInfo(contextKey, qInfo);
    assertEquals("QueueInfo", messagingManager.getRepositoryByName("QueueInfo").getName());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Test(org.junit.Test)

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