ScriptingService extends ScriptingServiceImp { public void setScriptFilename(String s) { scriptFilename = Args.notBlank(s, "scriptFilename"); } ScriptingService();  ScriptingService(String uniqueId); String getScriptFilename(); void setScriptFilename(String s); @Override void prepare();  }
@Test public void testService() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); msg.addMetadata(MY_METADATA_KEY, MY_METADATA_VALUE); ScriptingService service = createService(); File script = writeScript(true); service.setScriptFilename(script.getCanonicalPath()); execute(service, msg); assertTrue(msg.containsKey(MY_METADATA_KEY)); assertNotSame(MY_METADATA_VALUE, msg.getMetadataValue(MY_METADATA_KEY)); assertEquals(new StringBuffer(MY_METADATA_VALUE).reverse().toString(), msg.getMetadataValue(MY_METADATA_KEY)); delete(script); }
@Test public void testInit() throws Exception { ScriptingService service = new ScriptingService(); try { service.init(); fail("Service initialised w/o a language"); } catch (Exception expected) { ; } service.setLanguage("jruby"); service.setScriptFilename("/BLAHBLAHBLAHBLAHBLAH/BLAHBLAHBLAHBLAH"); try { service.init(); fail("Service initialised with no idiotic filename"); } catch (Exception expected) { ; } File script = writeScript(false); service.setScriptFilename(script.getCanonicalPath()); LifecycleHelper.init(service); LifecycleHelper.close(service); delete(script); }
@Test public void testDoServiceWithFailingScript() throws Exception { ScriptingService service = createService(); File script = writeScript(false); service.setScriptFilename(script.getCanonicalPath()); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); try { execute(service, msg); fail("Service failure expected"); } catch (ServiceException expected) { } delete(script); }