You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2017/04/10 14:11:36 UTC
[04/14] logging-log4j2 git commit: Merge branch 'master' into
log4j-server
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/AbstractSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/AbstractSocketServerTest.java
index 0000000,0000000..dfc44ea
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/AbstractSocketServerTest.java
@@@ -1,0 -1,0 +1,237 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.Serializable;
++import java.util.Arrays;
++import java.util.List;
++import java.util.Map;
++
++import org.apache.logging.log4j.Level;
++import org.apache.logging.log4j.core.Appender;
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.Logger;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.appender.AppenderLoggingException;
++import org.apache.logging.log4j.core.appender.ConsoleAppender;
++import org.apache.logging.log4j.core.appender.SocketAppender;
++import org.apache.logging.log4j.core.layout.JsonLayout;
++import org.apache.logging.log4j.core.layout.PatternLayout;
++import org.apache.logging.log4j.core.layout.XmlLayout;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.apache.logging.log4j.test.AvailablePortFinder;
++import org.apache.logging.log4j.test.appender.ListAppender;
++import org.junit.After;
++import org.junit.Ignore;
++import org.junit.Test;
++
++import static org.junit.Assert.*;
++
++/**
++ *
++ */
++public abstract class AbstractSocketServerTest {
++
++ protected static Thread thread;
++
++ private static final String MESSAGE = "This is test message";
++
++ private static final String MESSAGE_2 = "This is test message 2";
++
++ private static final String MESSAGE_WITH_SPECIAL_CHARS = "{This}\n[is]\"n\"a\"\r\ntrue:\n\ttest,\nmessage";
++
++ static final int PORT_NUM = AvailablePortFinder.getNextAvailable();
++
++ static final int PORT = PORT_NUM;
++
++ private final LoggerContext ctx = LoggerContext.getContext(false);
++
++ private final boolean expectLengthException;
++
++ protected final int port;
++
++ protected final Protocol protocol;
++
++ private final Logger rootLogger = ctx.getLogger(AbstractSocketServerTest.class.getSimpleName());
++
++ protected AbstractSocketServerTest(final Protocol protocol, final int port, final boolean expectLengthException) {
++ this.protocol = protocol;
++ this.port = port;
++ this.expectLengthException = expectLengthException;
++ }
++
++ protected Layout<String> createJsonLayout() {
++ // @formatter: off
++ return JsonLayout.newBuilder()
++ .setLocationInfo(true)
++ .setProperties(true)
++ .setPropertiesAsList(false)
++ .setComplete(false)
++ .setCompact(false)
++ .setEventEol(false)
++ .setIncludeStacktrace(true)
++ .build();
++ // @formatter: on
++
++ //return JsonLayout.createLayout(null, true, true, false, false, false, false, null, null, null, true);
++ }
++
++ protected abstract Layout<? extends Serializable> createLayout();
++
++ protected Layout<? extends Serializable> createSerializedLayout() {
++ return null;
++ }
++
++ protected Layout<String> createXmlLayout() {
++ return XmlLayout.createLayout(true, true, false, false, null, true);
++ }
++
++ @After
++ public void tearDown() {
++ final Map<String, Appender> map = rootLogger.getAppenders();
++ for (final Map.Entry<String, Appender> entry : map.entrySet()) {
++ final Appender appender = entry.getValue();
++ rootLogger.removeAppender(appender);
++ appender.stop();
++ }
++ }
++
++ @Test
++ @Ignore("Broken test?")
++ public void test1000ShortMessages() throws Exception {
++ testServer(1000);
++ }
++
++ @Test
++ @Ignore("Broken test?")
++ public void test100ShortMessages() throws Exception {
++ testServer(100);
++ }
++
++ @Test
++ public void test10ShortMessages() throws Exception {
++ testServer(10);
++ }
++
++ @Test
++ public void test1ShortMessages() throws Exception {
++ testServer(1);
++ }
++
++ @Test
++ public void test2ShortMessages() throws Exception {
++ testServer(2);
++ }
++
++ @Test
++ public void test64KBMessages() throws Exception {
++ final char[] a64K = new char[1024 * 64];
++ Arrays.fill(a64K, 'a');
++ final String m1 = new String(a64K);
++ final String m2 = MESSAGE_2 + m1;
++ if (expectLengthException) {
++ try {
++ testServer(m1, m2);
++ } catch (final AppenderLoggingException are) {
++ assertTrue("", are.getCause() != null && are.getCause() instanceof IOException);
++ // Failure expected.
++ }
++ } else {
++ testServer(m1, m2);
++ }
++ }
++
++
++ @Test
++ public void testMessagesWithSpecialChars() throws Exception {
++ testServer(MESSAGE_WITH_SPECIAL_CHARS);
++ }
++
++
++ private void testServer(final int size) throws Exception {
++ final String[] messages = new String[size];
++ for (int i = 0; i < messages.length; i++) {
++ messages[i] = MESSAGE + " " + i;
++ }
++ testServer(messages);
++ }
++
++ protected void testServer(final String... messages) throws Exception {
++ final Filter socketFilter = new ThreadNameFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
++ final Filter serverFilter = new ThreadNameFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
++ final Layout<? extends Serializable> socketLayout = createLayout();
++ final SocketAppender socketAppender = createSocketAppender(socketFilter, socketLayout);
++ socketAppender.start();
++ final ListAppender listAppender = new ListAppender("Events", serverFilter, null, false, false);
++ listAppender.start();
++ final PatternLayout layout = PatternLayout.newBuilder().withPattern("%m %ex%n").build();
++ final ConsoleAppender console = ConsoleAppender.createDefaultAppenderForLayout(layout);
++ final Logger serverLogger = ctx.getLogger(this.getClass().getName());
++ serverLogger.addAppender(console);
++ serverLogger.setAdditive(false);
++
++ // set appender on root and set level to debug
++ rootLogger.addAppender(socketAppender);
++ rootLogger.addAppender(listAppender);
++ rootLogger.setAdditive(false);
++ rootLogger.setLevel(Level.DEBUG);
++ for (final String message : messages) {
++ rootLogger.debug(message);
++ }
++ final int MAX_TRIES = 400;
++ for (int i = 0; i < MAX_TRIES; i++) {
++ if (listAppender.getEvents().size() < messages.length) {
++ try {
++ // Let the server-side read the messages.
++ Thread.sleep(50);
++ } catch (final Exception e) {
++ e.printStackTrace();
++ }
++ } else {
++ break;
++ }
++ }
++ final List<LogEvent> events = listAppender.getEvents();
++ assertNotNull("No event retrieved", events);
++ assertEquals("Incorrect number of events received", messages.length, events.size());
++ for (int i = 0; i < messages.length; i++) {
++ assertTrue("Incorrect event", events.get(i).getMessage().getFormattedMessage().equals(messages[i]));
++ }
++ }
++
++ protected SocketAppender createSocketAppender(final Filter socketFilter,
++ final Layout<? extends Serializable> socketLayout) {
++ // @formatter:off
++ return SocketAppender.newBuilder()
++ .withProtocol(this.protocol)
++ .withHost("localhost")
++ .withPort(this.port)
++ .withReconnectDelayMillis(-1)
++ .withName("test")
++ .withImmediateFlush(true)
++ .withImmediateFail(false)
++ .withIgnoreExceptions(false)
++ .withLayout(socketLayout)
++ .withFilter(socketFilter)
++ .build();
++ // @formatter:on
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/SslXmlSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/SslXmlSocketServerTest.java
index 0000000,0000000..1a51244
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/SslXmlSocketServerTest.java
@@@ -1,0 -1,0 +1,104 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.Serializable;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.appender.SocketAppender;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration;
++import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
++import org.apache.logging.log4j.core.net.ssl.StoreConfigurationException;
++import org.apache.logging.log4j.core.net.ssl.TestConstants;
++import org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class SslXmlSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<InputStream> server;
++
++ private static SslConfiguration sslConfiguration;
++
++ private static void initServerSocketFactory() throws StoreConfigurationException {
++ final KeyStoreConfiguration ksc = new KeyStoreConfiguration(TestConstants.KEYSTORE_FILE,
++ TestConstants.KEYSTORE_PWD, TestConstants.KEYSTORE_TYPE, null);
++ final TrustStoreConfiguration tsc = new TrustStoreConfiguration(TestConstants.TRUSTSTORE_FILE,
++ TestConstants.TRUSTSTORE_PWD, null, null);
++ sslConfiguration = SslConfiguration.createSSLConfiguration(null, ksc, tsc);
++ }
++
++ @Override
++ protected SocketAppender createSocketAppender(final Filter socketFilter,
++ final Layout<? extends Serializable> socketLayout) {
++ // @formatter:off
++ return SocketAppender.newBuilder()
++ .withProtocol(this.protocol)
++ .withHost("localhost")
++ .withPort(this.port)
++ .withReconnectDelayMillis(-1)
++ .withName("test")
++ .withImmediateFlush(true)
++ .withImmediateFail(false)
++ .withIgnoreExceptions(false)
++ .withLayout(socketLayout)
++ .withFilter(socketFilter)
++ .withSslConfiguration(sslConfiguration)
++ .build();
++ // @formatter:on
++ }
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ initServerSocketFactory();
++ // Use a large buffer just to test the code, the UDP test uses a tiny buffer
++ server = new SecureTcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
++ Charset.defaultCharset()), sslConfiguration);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public SslXmlSocketServerTest() {
++ super(Protocol.SSL, PORT, false);
++ }
++
++ @Override
++ protected Layout<String> createLayout() {
++ return super.createXmlLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/TcpJsonSocketServerTest.java
index 0000000,0000000..f12c908
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpJsonSocketServerTest.java
@@@ -1,0 -1,0 +1,62 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class TcpJsonSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = TcpSocketServer.createJsonSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public TcpJsonSocketServerTest() {
++ super(Protocol.TCP, PORT, false);
++ }
++
++ @Override
++ protected Layout<String> createLayout() {
++ return super.createJsonLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/TcpSerializedSocketServerTest.java
index 0000000,0000000..275af20
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpSerializedSocketServerTest.java
@@@ -1,0 -1,0 +1,63 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.ObjectInputStream;
++import java.io.Serializable;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class TcpSerializedSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<ObjectInputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = TcpSocketServer.createSerializedSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public TcpSerializedSocketServerTest() {
++ super(Protocol.TCP, PORT, false);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createSerializedLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/TcpXmlSocketServerTest.java
index 0000000,0000000..2b2cfd7
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpXmlSocketServerTest.java
@@@ -1,0 -1,0 +1,65 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class TcpXmlSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ // Use a large buffer just to test the code, the UDP test uses a tiny buffer
++ server = new TcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
++ Charset.defaultCharset()));
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public TcpXmlSocketServerTest() {
++ super(Protocol.TCP, PORT, false);
++ }
++
++ @Override
++ protected Layout<String> createLayout() {
++ return super.createXmlLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadIdFilter.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadIdFilter.java
index 0000000,0000000..d98e3f4
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadIdFilter.java
@@@ -1,0 -1,0 +1,40 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.filter.AbstractFilter;
++
++/**
++ * TODO Should use thread ID cache?
++ * @since 2.6
++ */
++public class ThreadIdFilter extends AbstractFilter {
++
++ private static final long serialVersionUID = 1L;
++
++ public ThreadIdFilter(final Result onMatch, final Result onMismatch) {
++ super(onMatch, onMismatch);
++ }
++
++ @Override
++ public Filter.Result filter(final LogEvent event) {
++ return event.getThreadId() == Thread.currentThread().getId() ? onMatch : onMismatch;
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadNameFilter.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadNameFilter.java
index 0000000,0000000..4204ac1
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadNameFilter.java
@@@ -1,0 -1,0 +1,39 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.filter.AbstractFilter;
++
++/**
++ * TODO Should use thread name cache?
++ */
++public class ThreadNameFilter extends AbstractFilter {
++
++ private static final long serialVersionUID = 1L;
++
++ public ThreadNameFilter(final Result onMatch, final Result onMismatch) {
++ super(onMatch, onMismatch);
++ }
++
++ @Override
++ public Filter.Result filter(final LogEvent event) {
++ return event.getThreadName().equals(Thread.currentThread().getName()) ? onMatch : onMismatch;
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadPriorityFilter.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadPriorityFilter.java
index 0000000,0000000..6074f86
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadPriorityFilter.java
@@@ -1,0 -1,0 +1,40 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.filter.AbstractFilter;
++
++/**
++ * TODO Should use thread priority cache?
++ * @since 2.6
++ */
++public class ThreadPriorityFilter extends AbstractFilter {
++
++ private static final long serialVersionUID = 1L;
++
++ public ThreadPriorityFilter(final Result onMatch, final Result onMismatch) {
++ super(onMatch, onMismatch);
++ }
++
++ @Override
++ public Filter.Result filter(final LogEvent event) {
++ return event.getThreadPriority() == Thread.currentThread().getPriority() ? onMatch : onMismatch;
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/UdpJsonSocketServerTest.java
index 0000000,0000000..7bd36f9
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpJsonSocketServerTest.java
@@@ -1,0 -1,0 +1,58 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.InputStream;
++import java.io.Serializable;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class UdpJsonSocketServerTest extends AbstractSocketServerTest {
++
++ private static UdpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = UdpSocketServer.createJsonSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ server.shutdown();
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public UdpJsonSocketServerTest() {
++ super(Protocol.UDP, PORT, true);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createJsonLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/UdpSerializedSocketServerTest.java
index 0000000,0000000..9c806af
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpSerializedSocketServerTest.java
@@@ -1,0 -1,0 +1,60 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.ObjectInputStream;
++import java.io.Serializable;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++import org.junit.Ignore;
++
++@Ignore
++public class UdpSerializedSocketServerTest extends AbstractSocketServerTest {
++
++ private static UdpSocketServer<ObjectInputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = UdpSocketServer.createSerializedSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ server.shutdown();
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public UdpSerializedSocketServerTest() {
++ super(Protocol.UDP, PORT, true);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createSerializedLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/UdpXmlSocketServerTest.java
index 0000000,0000000..0299312
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpXmlSocketServerTest.java
@@@ -1,0 -1,0 +1,61 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.InputStream;
++import java.io.Serializable;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class UdpXmlSocketServerTest extends AbstractSocketServerTest {
++
++ private static UdpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ // Use a tiny buffer just to test the code, the TCP test uses a large buffer
++ server = new UdpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(100,
++ Charset.defaultCharset()));
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ server.shutdown();
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public UdpXmlSocketServerTest() {
++ super(Protocol.UDP, PORT, true);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createXmlLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/client.log4j2-keystore.jks
----------------------------------------------------------------------
diff --cc log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/client.log4j2-keystore.jks
index 0000000,0000000..36f11b6
new file mode 100644
Binary files differ
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/truststore.jks
----------------------------------------------------------------------
diff --cc log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/truststore.jks
index 0000000,0000000..0e6aaf2
new file mode 100644
Binary files differ