io.github.azagniotov.stubby4j.handlers.AbstractHandlerExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stubby4j Show documentation
Show all versions of stubby4j Show documentation
A highly flexible & configurable tool for testing interactions of SOA applications with web services (REST, SOAP, WSDL etc.) over HTTP(S) protocol. It is an actual HTTP server (stubby4j uses embedded Jetty) that acts like a real web service, ready for consumption by your code. Allows stubbing of external systems with ease for integration testing
package io.github.azagniotov.stubby4j.handlers;
import io.github.azagniotov.stubby4j.utils.ConsoleUtils;
import org.eclipse.jetty.server.Request;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface AbstractHandlerExtension {
default boolean logAndCheckIsHandled(final String handlerName,
final Request baseRequest,
final HttpServletRequest request,
final HttpServletResponse response) {
ConsoleUtils.logIncomingRequest(request);
if (baseRequest.isHandled() || response.isCommitted()) {
ConsoleUtils.logIncomingRequestError(request, handlerName, "HTTP response was committed or base request was handled, aborting..");
return true;
}
return false;
}
}