use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class XpathMetadataServiceTest method testDoService_DisableDocType.
@Test
public void testDoService_DisableDocType() throws CoreException {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_DOCTYPE);
XpathMetadataService service = new XpathMetadataService();
// Shouldn't matter what the query actually is.
service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
service.setXmlDocumentFactoryConfig(builder);
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class SimpleSequenceNumberTest method testDoService_FileIsDirectory.
@Test
public void testDoService_FileIsDirectory() throws Exception {
SimpleSequenceNumberService service = new SimpleSequenceNumberService();
service.setMetadataKey(DEFAULT_METADATA_KEY);
File dir = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID());
dir.mkdirs();
service.setSequenceNumberFile(dir.getCanonicalPath());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class StringToHexServiceTest method testService_BadEncodingChoice.
@Test
public void testService_BadEncodingChoice() throws Exception {
StringToHexService service = new StringToHexService();
service.setCharset("RandomEncoding!");
service.setMetadataKeyRegexp(HexToStringServiceTest.SOURCE_METADATA_KEY);
AdaptrisMessage msg = createMessage();
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MetadataBranchingServiceTest method testNoMetadataService.
@Test
public void testNoMetadataService() throws Exception {
MetadataValueBranchingService service = createService();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(DUMMY_PAYLOAD);
try {
execute(service, msg);
fail("no Exc. for null Service ID");
} catch (ServiceException e) {
// expected behaviour
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ReformatDateServiceTest method testServiceWithBadFormat.
@Test
public void testServiceWithBadFormat() throws Exception {
ReformatDateService service = new ReformatDateService();
service.setDestinationFormatBuilder(new DateFormatBuilder(DEST_DATE_FORMAT));
service.setSourceFormatBuilder(new DateFormatBuilder(BAD_SOURCE_DATE_FORMAT));
service.setMetadataKeyRegexp(DATE_METADATA_KEY);
AdaptrisMessage msg = createMessage();
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
Aggregations