logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1460963 - /logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
Date Tue, 26 Mar 2013 03:35:04 GMT
Author: rgoers
Date: Tue Mar 26 03:35:04 2013
New Revision: 1460963

URL: http://svn.apache.org/r1460963
Log:
Brute force fix for SocketReconnectTest

Modified:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java?rev=1460963&r1=1460962&r2=1460963&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
Tue Mar 26 03:35:04 2013
@@ -20,6 +20,7 @@ import org.apache.logging.log4j.LogManag
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
+import org.apache.logging.log4j.core.helpers.Constants;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -36,6 +37,13 @@ public class SocketReconnectTest {
 
     private static final String CONFIG = "log4j-socket.xml";
 
+    private static final String SHUTDOWN = "Shutdown" + Constants.LINE_SEP +
+        "................................................................" + Constants.LINE_SEP
+
+        "................................................................" + Constants.LINE_SEP
+
+        "................................................................" + Constants.LINE_SEP
+
+        "................................................................" + Constants.LINE_SEP;
+
+
     @BeforeClass
     public static void before() {
         System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
@@ -71,7 +79,7 @@ public class SocketReconnectTest {
         assertNotNull("No message", msg);
         assertEquals(message, msg);
 
-        server.shutdown();
+        logger.error(SHUTDOWN);
         server.join();
 
         list.clear();
@@ -79,7 +87,7 @@ public class SocketReconnectTest {
         message = "Log #2";
         boolean exceptionCaught = false;
 
-        for (int i = 0; i < 5; ++i) {
+        for (int i = 0; i < 100; ++i) {
             try {
                 logger.error(message);
             } catch (final AppenderRuntimeException e) {
@@ -111,7 +119,7 @@ public class SocketReconnectTest {
         assertEquals(expectedHeader, header);
         assertNotNull("No message", msg);
         assertEquals(message, msg);
-        server.shutdown();
+        logger.error(SHUTDOWN);
         server.join();
     }
 
@@ -133,7 +141,12 @@ public class SocketReconnectTest {
                 client = server.accept();
                 while (!shutdown) {
                     BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
-                    list.add(reader.readLine());
+                    String line = reader.readLine();
+                    if (line.equals("Shutdown")) {
+                        shutdown = true;
+                    } else {
+                        list.add(line);
+                    }
                 }
             } catch (Exception ex) {
                 ex.printStackTrace();
@@ -154,14 +167,5 @@ public class SocketReconnectTest {
                 }
             }
         }
-
-        public void shutdown() {
-            shutdown = true;
-            try {
-                client.shutdownInput();
-            } catch (Exception ex) {
-                ex.printStackTrace();
-            }
-        }
     }
 }



Mime
View raw message