@Test void shouldThrowMessagingExceptionWhenInvalidUrl() throws Exception { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .setProperty("parameterKey", "pKey").setProperty("parameterValue", "pValue") .setProperty("messageKey", "mKey").setProperty("url", "qwerty: .build(); assertThatThrownBy(() -> { new SerialiseToHTTP().init(mailetConfig); }).isExactlyInstanceOf(MessagingException.class) .hasMessageContaining("Unable to contruct URL object from url"); }
@Override public void init() throws MessagingException { passThrough = (getInitParameter("passThrough", "true").compareToIgnoreCase("true") == 0); String targetUrl = getInitParameter("url"); parameterKey = getInitParameter("parameterKey"); parameterValue = getInitParameter("parameterValue"); String m = getInitParameter("MessageKeyName"); if (m != null) { messageKeyName = m; } if (targetUrl == null || targetUrl.equals("")) { throw new MessagingException( "Please configure a targetUrl (\"url\")"); } else { try { url = new URL(targetUrl).toExternalForm(); } catch (MalformedURLException e) { throw new MessagingException( "Unable to contruct URL object from url"); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("I will attempt to deliver serialised messages to " + targetUrl + " as " + messageKeyName + ". " + (parameterKey == null || parameterKey.length() < 2 ? "I will not add any fields to the post. " : "I will prepend: " + parameterKey + "=" + parameterValue + ". ") + (passThrough ? "Messages will pass through." : "Messages will be ghosted.")); } }
SerialiseToHTTP extends GenericMailet { @Override public void init() throws MessagingException { passThrough = (getInitParameter("passThrough", "true").compareToIgnoreCase("true") == 0); String targetUrl = getInitParameter("url"); parameterKey = getInitParameter("parameterKey"); parameterValue = getInitParameter("parameterValue"); String m = getInitParameter("MessageKeyName"); if (m != null) { messageKeyName = m; } if (targetUrl == null || targetUrl.equals("")) { throw new MessagingException( "Please configure a targetUrl (\"url\")"); } else { try { url = new URL(targetUrl).toExternalForm(); } catch (MalformedURLException e) { throw new MessagingException( "Unable to contruct URL object from url"); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("I will attempt to deliver serialised messages to " + targetUrl + " as " + messageKeyName + ". " + (parameterKey == null || parameterKey.length() < 2 ? "I will not add any fields to the post. " : "I will prepend: " + parameterKey + "=" + parameterValue + ". ") + (passThrough ? "Messages will pass through." : "Messages will be ghosted.")); } } }
SerialiseToHTTP extends GenericMailet { @Override public void init() throws MessagingException { passThrough = (getInitParameter("passThrough", "true").compareToIgnoreCase("true") == 0); String targetUrl = getInitParameter("url"); parameterKey = getInitParameter("parameterKey"); parameterValue = getInitParameter("parameterValue"); String m = getInitParameter("MessageKeyName"); if (m != null) { messageKeyName = m; } if (targetUrl == null || targetUrl.equals("")) { throw new MessagingException( "Please configure a targetUrl (\"url\")"); } else { try { url = new URL(targetUrl).toExternalForm(); } catch (MalformedURLException e) { throw new MessagingException( "Unable to contruct URL object from url"); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("I will attempt to deliver serialised messages to " + targetUrl + " as " + messageKeyName + ". " + (parameterKey == null || parameterKey.length() < 2 ? "I will not add any fields to the post. " : "I will prepend: " + parameterKey + "=" + parameterValue + ". ") + (passThrough ? "Messages will pass through." : "Messages will be ghosted.")); } }  }
SerialiseToHTTP extends GenericMailet { @Override public void init() throws MessagingException { passThrough = (getInitParameter("passThrough", "true").compareToIgnoreCase("true") == 0); String targetUrl = getInitParameter("url"); parameterKey = getInitParameter("parameterKey"); parameterValue = getInitParameter("parameterValue"); String m = getInitParameter("MessageKeyName"); if (m != null) { messageKeyName = m; } if (targetUrl == null || targetUrl.equals("")) { throw new MessagingException( "Please configure a targetUrl (\"url\")"); } else { try { url = new URL(targetUrl).toExternalForm(); } catch (MalformedURLException e) { throw new MessagingException( "Unable to contruct URL object from url"); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("I will attempt to deliver serialised messages to " + targetUrl + " as " + messageKeyName + ". " + (parameterKey == null || parameterKey.length() < 2 ? "I will not add any fields to the post. " : "I will prepend: " + parameterKey + "=" + parameterValue + ". ") + (passThrough ? "Messages will pass through." : "Messages will be ghosted.")); } }  @Override void init(); @Override void service(Mail mail); @Override String getMailetInfo(); }
SerialiseToHTTP extends GenericMailet { @Override public void init() throws MessagingException { passThrough = (getInitParameter("passThrough", "true").compareToIgnoreCase("true") == 0); String targetUrl = getInitParameter("url"); parameterKey = getInitParameter("parameterKey"); parameterValue = getInitParameter("parameterValue"); String m = getInitParameter("MessageKeyName"); if (m != null) { messageKeyName = m; } if (targetUrl == null || targetUrl.equals("")) { throw new MessagingException( "Please configure a targetUrl (\"url\")"); } else { try { url = new URL(targetUrl).toExternalForm(); } catch (MalformedURLException e) { throw new MessagingException( "Unable to contruct URL object from url"); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("I will attempt to deliver serialised messages to " + targetUrl + " as " + messageKeyName + ". " + (parameterKey == null || parameterKey.length() < 2 ? "I will not add any fields to the post. " : "I will prepend: " + parameterKey + "=" + parameterValue + ". ") + (passThrough ? "Messages will pass through." : "Messages will be ghosted.")); } }  @Override void init(); @Override void service(Mail mail); @Override String getMailetInfo();  }