use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class BlobMessageTranslatorTest method testMoveMetadataJmsMessageToAdaptrisMessage.
@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage() throws Exception {
MessageTypeTranslatorImp trans = new BlobMessageTranslator();
JmsConnection conn = null;
try {
conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
start(conn);
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Message jmsMsg = createMessage(session);
addProperties(jmsMsg);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
start(trans);
AdaptrisMessage msg = trans.translate(jmsMsg);
assertMetadata(msg);
} finally {
stop(trans);
stop(conn);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class XmlRuleValidatorTest method testListContentValidation_DataNotInList.
@Test
public void testListContentValidation_DataNotInList() throws Exception {
XmlRuleValidator validator = new XmlRuleValidator();
validator.addValidationStage(new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_DEMETER, new SimpleListContentValidation(CHILDREN_OF_HERA)));
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
XmlValidationService service = new XmlValidationService(validator);
try {
ExampleServiceCase.execute(service, msg);
fail("RuleValidationService success when expecting exception");
} catch (ServiceException e) {
// expected
;
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class LargeFsConsumerTest method testConsumeWithAlternateFactory.
@Test
public void testConsumeWithAlternateFactory() throws Exception {
String subDir = GUID.safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setResetWipFiles(false);
fs.setMessageFactory(new DefaultMessageFactory());
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 10;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
baseDir.mkdirs();
super.createFiles(baseDir, ".xml", count);
start(sc);
waitForMessages(stub, count);
assertEquals(count, stub.getMessages().size());
super.assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
assertDefaultMessageType(stub.getMessages());
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class LineCountSplitterTest method testSetMessageFactory.
@Override
public void testSetMessageFactory() throws Exception {
MessageSplitterImp splitter = createSplitterForTests();
assertNull(splitter.getMessageFactory());
assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
splitter.setMessageFactory(new StubMessageFactory());
assertEquals(StubMessageFactory.class, splitter.getMessageFactory().getClass());
assertEquals(StubMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
splitter.setMessageFactory(null);
assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class SplitterCase method testSetMessageFactory.
@Test
public void testSetMessageFactory() throws Exception {
MessageSplitterImp splitter = createSplitterForTests();
assertNull(splitter.getMessageFactory());
assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
splitter.setMessageFactory(new StubMessageFactory());
assertEquals(StubMessageFactory.class, splitter.getMessageFactory().getClass());
assertEquals(StubMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
splitter.setMessageFactory(new DefaultMessageFactory());
assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
splitter.setMessageFactory(null);
assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
}
Aggregations