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);
}
}
}
}
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
}
}
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);
}
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());
}
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());
}
Aggregations