use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsMessageProducerTest method testSetFilenameCreator.
@Test
public void testSetFilenameCreator() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsProducer producer = createProducer(subdir);
try {
producer.setFilenameCreator(null);
fail();
} catch (IllegalArgumentException | NullPointerException expected) {
}
producer.setFilenameCreator(new EmptyFileNameCreator());
assertEquals(EmptyFileNameCreator.class, producer.getFilenameCreator().getClass());
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testFsMonitor.
@Test
public void testFsMonitor() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsConsumerImpl fs = createConsumer(subdir);
fs.setUniqueId(getName());
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
Channel channel = new Channel();
channel.setUniqueId(getName());
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId(getName());
wf.setConsumer(fs);
channel.getWorkflowList().add(wf);
adapter.getChannelList().add(channel);
AdapterManager am = new AdapterManager(adapter);
try {
am.registerMBean();
am.requestInit();
String objectNameString = String.format("com.adaptris:type=ConsumerMonitor,adapter=%s,channel=%s,workflow=%s,id=%s", getName(), getName(), getName(), getName());
MBeanServer mBeanServer = JmxHelper.findMBeanServer();
FsConsumerMonitorMBean mbean = JMX.newMBeanProxy(mBeanServer, ObjectName.getInstance(objectNameString), FsConsumerMonitorMBean.class);
assertEquals(0, mbean.messagesRemaining());
} finally {
am.requestClose();
am.unregisterMBean();
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testInitWithoutMkdirs.
@Test
public void testInitWithoutMkdirs() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsConsumerImpl fs = createConsumer(subdir);
fs.setCreateDirs(false);
try {
LifecycleHelper.init(fs);
fail("Should fail since dir can't exist");
} catch (CoreException e) {
// Expected
;
} finally {
LifecycleHelper.close(fs);
FileUtils.deleteQuietly(new File(PROPERTIES.getProperty(BASE_KEY), subdir));
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testInitWithMkdirs.
@Test
public void testInitWithMkdirs() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsConsumerImpl fs = createConsumer(subdir);
try {
fs.setCreateDirs(true);
LifecycleHelper.init(fs);
} finally {
LifecycleHelper.close(fs);
FileUtils.deleteQuietly(new File(PROPERTIES.getProperty(BASE_KEY), subdir));
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testBasicInit.
@Test
public void testBasicInit() throws Exception {
String subDir = new GuidGenerator().safeUUID();
FsConsumerImpl consumer = createConsumer(subDir);
try {
FsConsumerImpl consumer2 = createConsumer();
try {
LifecycleHelper.init(consumer2);
fail("no destination - should throw Exception");
} catch (CoreException e) {
// expected
}
// test creation of file filter imp...
consumer.setFilterExpression(".*\\.xml");
consumer.setFileFilterImp(Perl5FilenameFilter.class.getName());
try {
LifecycleHelper.init(consumer);
} catch (CoreException e) {
fail("Exception calling init with valid FileFilter " + e);
}
LifecycleHelper.close(consumer);
// test creation of invalid FF Imp
consumer.setFileFilterImp("com.class.does.not.exist.FileFilter");
try {
LifecycleHelper.init(consumer);
fail("Calling init with invalid FileFilter ");
} catch (CoreException e) {
}
} finally {
FileUtils.deleteQuietly(new File(PROPERTIES.getProperty(BASE_KEY), subDir));
}
}
Aggregations