private void addLoggingHandler(ChannelHandlerContext ctx) { if (mockServerLogger.isEnabled(TRACE)) { loggingHandler.addLoggingHandler(ctx); } }
@Override public void logError(final String matched, final Exception exception) { mockServerLogger.error("SAXParseException while parsing [" + input + "]", exception); } });
private String formatMessage(String eventName, Object msg) { if (msg instanceof ByteBuf) { return formatByteBuf(eventName, (ByteBuf) msg); } else if (msg instanceof ByteBufHolder) { return formatByteBufHolder(eventName, (ByteBufHolder) msg); } else { return formatNonByteBuf(eventName, msg); } }
private static SchemaFactory buildSchemaFactory() { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "all"); schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "all"); } catch (Exception e) { new MockServerLogger(XmlSchemaValidator.class).error("exception configuring schema factory", e); } return schemaFactory; }
@Override public void channelInactive(ChannelHandlerContext ctx) { mockServerLogger.trace("web socket client disconnected"); }
private SSLContext getSSLContextInstance() throws NoSuchAlgorithmException { try { MOCK_SERVER_LOGGER.debug(SERVER_CONFIGURATION, "Using protocol {}", SSL_CONTEXT_PROTOCOL); return SSLContext.getInstance(SSL_CONTEXT_PROTOCOL); } catch (NoSuchAlgorithmException e) { MOCK_SERVER_LOGGER.warn("Protocol {} not available, falling back to {}", SSL_CONTEXT_PROTOCOL, SSL_CONTEXT_FALLBACK_PROTOCOL); return SSLContext.getInstance(SSL_CONTEXT_FALLBACK_PROTOCOL); } }
public void info(final MessageLogEntry.LogMessageType type, final String message, final Object... arguments) { info(type, (HttpRequest) null, message, arguments); }
@Override public void logError(final String matched, final Exception exception) { mockServerLogger.warn(context, "SAXParseException while performing match between [" + matcher + "] and [" + matched + "]", exception); } }), XPathConstants.BOOLEAN);
public void debug(final MessageLogEntry.LogMessageType type, final String message, final Object... arguments) { debug(type, null, message, arguments); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { logMessage(ctx, "RECEIVED", msg); ctx.fireChannelRead(msg); }
public void error(final String message, final Throwable throwable) { error((HttpRequest) null, throwable, message); }
@Override public boolean matches(final HttpRequest context, Boolean matched) { boolean result = false; if (matcher == null) { result = true; } else if (matched != null) { result = matched == matcher; } if (!result) { mockServerLogger.trace(context, "Failed to match [{}] with [{}]", matched, this.matcher); } return result; }
public void run() { httpErrorActionHandler.handle((HttpError) action, ctx); mockServerLogger.info(EXPECTATION_RESPONSE, request, "returning error:{}for request:{}for action:{}", action, request, action); } }, synchronous, action.getDelay());
public void warn(final String message) { warn((HttpRequest) null, message); }
public void error(final String message, final Object... arguments) { error(null, message, arguments); }
public void trace(final String message, final Object... arguments) { trace(null, message, arguments); }
public void run() { mockServerLogger.info(EXPECTATION_RESPONSE, request, "returning response:{}for request:{}for action:{}", response, request, action); responseWriter.writeResponse(request, response, false); } }, synchronous, action.getDelay(), response.getDelay());
public void warn(final String message, final Object... arguments) { warn(null, message, arguments); }
public boolean matches(final HttpRequest context, byte[] matched) { boolean result = false; if (matcher == null || matcher.length == 0 || Arrays.equals(matcher, matched)) { result = true; } if (!result) { mockServerLogger.trace(context, "Failed to perform binary match [{}] with [{}] because {}", (Object) matched); } return not != result; }
public Expectation firstMatchingExpectation(HttpRequest request) { if (mockServerMatcher.isEmpty()) { mockServerLogger.info(EXPECTATION_NOT_MATCHED, request, "no active expectations"); return null; } else { return mockServerMatcher.firstMatchingExpectation(request); } }