use of com.adaptris.core.CoreException 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.core.CoreException 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));
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ConfigPreProcessorsTest method testProcessURL.
@Test
public void testProcessURL() throws Exception {
ConfigPreProcessors p = new ConfigPreProcessors(new DummyConfigurationPreProcessor(new KeyValuePairSet()), new DummyConfigurationPreProcessor(new KeyValuePairSet()));
URL onClasspath = this.getClass().getClassLoader().getResource("xstream-standalone.xml");
assertNotNull(p.process(onClasspath));
try {
p.process(new URL("file:///./does/not/exist"));
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class MarshallingItemCache method writePersistentStore.
private void writePersistentStore() {
try {
File store = new File(getPersistentStore());
File parent = store.getParentFile();
if (parent != null) {
parent.mkdirs();
}
marshaller.marshal(convertToList(cache), store);
logR.trace("Persisted " + cache.size() + " entries to disk");
} catch (CoreException e) {
logR.warn("Failed to store cache, cache will be empty upon restart");
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class NonDeletingFsConsumer method processFile.
@Override
protected int processFile(File fileToProcess) throws CoreException {
int result = 0;
try {
if (checkModified(fileToProcess) && isFileAccessible(fileToProcess)) {
ProcessedItem item = new ProcessedItem(fileToProcess.getCanonicalPath(), fileToProcess.lastModified(), fileToProcess.length());
try {
filesDetected.addProcessedItem(item);
if (hasChanged(item)) {
AdaptrisMessage msg = createAdaptrisMessage(fileToProcess);
addStandardMetadata(msg, fileToProcess, fileToProcess);
retrieveAdaptrisMessageListener().onAdaptrisMessage(msg);
result++;
} else {
log.trace("[{}] hasn't changed since last poll", item.getAbsolutePath());
}
} catch (Exception e) {
filesDetected.removeProcessedItem(item);
throw e;
}
}
} catch (Exception e) {
throw new CoreException(e);
}
return result;
}
Aggregations