Skip to content

Instantly share code, notes, and snippets.

View jonashackt's full-sized avatar
:octocat:
TDD & CI for IaC FTW!

Jonas Hecht jonashackt

:octocat:
TDD & CI for IaC FTW!
View GitHub Profile
@jonashackt
jonashackt / console.log
Created May 7, 2015 09:26
Spring Boot Standard Banner
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.3.RELEASE)
@jonashackt
jonashackt / console.log
Created May 7, 2015 09:38
Custom Spring Boot Banner
______ ______ ______ __ __ __ ______ __ __
/\ ___\ /\ __ \ /\ __ \ /\ \ /\ "-.\ \ /\ ___\ /\ \ _ \ \
\ \ \____ \ \ \/\ \ \ \ \/\ \ \ \ \____ \ \ \-. \ \ \ __\ \ \ \/ ".\ \
\ \_____\ \ \_____\ \ \_____\ \ \_____\ \ \_\\"\_\ \ \_____\ \ \__/".~\_\
\/_____/ \/_____/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/
__ __ __ ______ ______ ______ ______ ______ ______ __ __ __ ______ ______
/\ "-./ \ /\ \ /\ ___\ /\ == \ /\ __ \ /\ ___\ /\ ___\ /\ == \ /\ \ / / /\ \ /\ ___\ /\ ___
@jonashackt
jonashackt / Service.wsdl
Created May 12, 2015 08:45
Define Custom Exception in WSDL (import the Exception Definition from another XSD - not included here)
<!-- ... -->
<wsdl:message name="WeatherException">
<wsdl:part name="parameters" element="datatypes:WeatherException" />
</wsdl:message>
<!-- ... -->
<wsdl:portType name="WeatherSoap">
<wsdl:operation name="GetWeatherInformation">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Gets Information for each WeatherID</wsdl:documentation>
<wsdl:input message="tns:GetWeatherInformationSoapIn"/>
<wsdl:output message="tns:GetWeatherInformationSoapOut"/>
@jonashackt
jonashackt / WeatherServiceXmlValidationInterceptor.java
Created May 13, 2015 15:28
Apache CXF Interceptor for Custom SoapFaults
public class WeatherServiceXmlValidationInterceptor extends AbstractSoapInterceptor {
//...
public WeatherServiceXmlValidationInterceptor() {
super(Phase.PRE_STREAM);
}
@Override
public void handleMessage(SoapMessage soapMessage) throws Fault {
Fault fault = (Fault) soapMessage.getContent(Exception.class);
@jonashackt
jonashackt / WeatherServiceXmlValidationInterceptor.java
Created May 13, 2015 15:44
Apache CXF Interceptor for Custom SoapFaults Part 2. - Checking for relevant Exceptions
//...
private boolean containsFaultIndicatingNotSchemeCompliantXml(Throwable faultCause, String faultMessage) {
if(faultCause instanceof UnmarshalException
// 1.) If the root-Element of the SoapBody is syntactically correct, but not scheme-compliant,
// there is no UnmarshalException and we have to look for
// 2.) Missing / lead to Faults without Causes, but to Messages like "Unexpected wrapper element XYZ found. Expected"
// One could argue, that this is syntactically incorrect, but here we just take it as Non-Scheme-compliant
|| isNotNull(faultMessage) && faultMessage.contains("Unexpected wrapper element")) {
return true;
}
@jonashackt
jonashackt / MarhallJaxbElement.java
Last active August 29, 2015 14:21
Marhall an JAXBObject into org.w3c.dom.Document
public static Document marhallJaxbElement(Object jaxbElement) throws BusinessException {
Document jaxbDoc = null;
try {
Marshaller marshaller = setUpMarshaller(jaxbElement.getClass());
jaxbDoc = createNewDocument();
marshaller.marshal(jaxbElement, jaxbDoc);
} catch (Exception exception) {
throw new BusinessException("Problem beim marshallen des JAXBElements in ein Document: " + exception.getMessage());
}
return jaxbDoc;
@jonashackt
jonashackt / gist:d6c062b1263559d4da13
Created May 19, 2015 09:33
doing parameter validation in methods and constructors
Objects.requireNonNull(after);
@jonashackt
jonashackt / pom.xml
Created July 7, 2015 06:09
Maven dependency to local project
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
@jonashackt
jonashackt / settings.xml
Created July 7, 2015 08:34
Maven configure Download of Sources and Javadoc once and for all
<profiles>
<profile>
<id>downloadSources</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
@jonashackt
jonashackt / settings.xml
Created July 7, 2015 08:36
Maven configure another Repo
<mirrors>
<mirror>
<id>camel-snapshots</id>
<name>Apache Camel Snapshots</name>
<url>https://repository.apache.org/content/repositories/snapshots</url>
<mirrorOf>camel-snapshots</mirrorOf>
</mirror>
<mirror>
<id>jitpack.io</id>
<name>Jitpack Releases</name>