@Test( expected = SdiException.class ) public void testGetResolvedBodyInvalidCharset() throws Throwable { TestUtils.addToEnvironment( myEnv, MailProperties.KEY_BODY_TEMPLATE, "template.txt" ); TestUtils.addToEnvironment( myEnv, MailProperties.KEY_BODY_TEMPLATE_CHARSET, "invalid" ); myClassUnderTest.init(); }
public void init() throws SdiException { myBodyKey = MailProperties.KEY_BODY; if ( myEnv.containsProperty( MailProperties.KEY_BODY_TEMPLATE ) ) { String charsetName; try { charsetName = myEnv.getRequiredProperty( MailProperties.KEY_BODY_TEMPLATE_CHARSET ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE + " is defined but " + "not " + MailProperties.KEY_BODY_TEMPLATE_CHARSET, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } Charset charset; try { charset = Charset.forName( charsetName ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE_CHARSET + " (" + charsetName + ") is invalid", t, SdiException.EXIT_CODE_CONFIG_ERROR ); } String fileName = myEnv.getProperty( MailProperties.KEY_BODY_TEMPLATE ); String body = loadFile( charset, fileName ); myBodyKey = KEY_BODY_BY_TEMPLATE_FILE; ConfigUtils.addToEnvironment( myEnv, myBodyKey, body ); } }
MailTextResolver { public void init() throws SdiException { myBodyKey = MailProperties.KEY_BODY; if ( myEnv.containsProperty( MailProperties.KEY_BODY_TEMPLATE ) ) { String charsetName; try { charsetName = myEnv.getRequiredProperty( MailProperties.KEY_BODY_TEMPLATE_CHARSET ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE + " is defined but " + "not " + MailProperties.KEY_BODY_TEMPLATE_CHARSET, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } Charset charset; try { charset = Charset.forName( charsetName ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE_CHARSET + " (" + charsetName + ") is invalid", t, SdiException.EXIT_CODE_CONFIG_ERROR ); } String fileName = myEnv.getProperty( MailProperties.KEY_BODY_TEMPLATE ); String body = loadFile( charset, fileName ); myBodyKey = KEY_BODY_BY_TEMPLATE_FILE; ConfigUtils.addToEnvironment( myEnv, myBodyKey, body ); } } }
MailTextResolver { public void init() throws SdiException { myBodyKey = MailProperties.KEY_BODY; if ( myEnv.containsProperty( MailProperties.KEY_BODY_TEMPLATE ) ) { String charsetName; try { charsetName = myEnv.getRequiredProperty( MailProperties.KEY_BODY_TEMPLATE_CHARSET ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE + " is defined but " + "not " + MailProperties.KEY_BODY_TEMPLATE_CHARSET, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } Charset charset; try { charset = Charset.forName( charsetName ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE_CHARSET + " (" + charsetName + ") is invalid", t, SdiException.EXIT_CODE_CONFIG_ERROR ); } String fileName = myEnv.getProperty( MailProperties.KEY_BODY_TEMPLATE ); String body = loadFile( charset, fileName ); myBodyKey = KEY_BODY_BY_TEMPLATE_FILE; ConfigUtils.addToEnvironment( myEnv, myBodyKey, body ); } }  }
MailTextResolver { public void init() throws SdiException { myBodyKey = MailProperties.KEY_BODY; if ( myEnv.containsProperty( MailProperties.KEY_BODY_TEMPLATE ) ) { String charsetName; try { charsetName = myEnv.getRequiredProperty( MailProperties.KEY_BODY_TEMPLATE_CHARSET ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE + " is defined but " + "not " + MailProperties.KEY_BODY_TEMPLATE_CHARSET, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } Charset charset; try { charset = Charset.forName( charsetName ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE_CHARSET + " (" + charsetName + ") is invalid", t, SdiException.EXIT_CODE_CONFIG_ERROR ); } String fileName = myEnv.getProperty( MailProperties.KEY_BODY_TEMPLATE ); String body = loadFile( charset, fileName ); myBodyKey = KEY_BODY_BY_TEMPLATE_FILE; ConfigUtils.addToEnvironment( myEnv, myBodyKey, body ); } }  void init(); String getResolvedBody( Person<?> aPerson ); String getResolvedSubject( Person<?> aPerson ); }
MailTextResolver { public void init() throws SdiException { myBodyKey = MailProperties.KEY_BODY; if ( myEnv.containsProperty( MailProperties.KEY_BODY_TEMPLATE ) ) { String charsetName; try { charsetName = myEnv.getRequiredProperty( MailProperties.KEY_BODY_TEMPLATE_CHARSET ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE + " is defined but " + "not " + MailProperties.KEY_BODY_TEMPLATE_CHARSET, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } Charset charset; try { charset = Charset.forName( charsetName ); } catch ( Throwable t ) { throw new SdiException( "Property " + MailProperties.KEY_BODY_TEMPLATE_CHARSET + " (" + charsetName + ") is invalid", t, SdiException.EXIT_CODE_CONFIG_ERROR ); } String fileName = myEnv.getProperty( MailProperties.KEY_BODY_TEMPLATE ); String body = loadFile( charset, fileName ); myBodyKey = KEY_BODY_BY_TEMPLATE_FILE; ConfigUtils.addToEnvironment( myEnv, myBodyKey, body ); } }  void init(); String getResolvedBody( Person<?> aPerson ); String getResolvedSubject( Person<?> aPerson ); static final String KEY_EXTRA_MAIL_BODY_FILE; static final String KEY_EXTRA_MAIL_BODY_TEXT; }