logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r1345492 [16/18] - in /logging/log4j/branches/log4j12modules: ./ contribs/ contribs/CekiGulcu/ contribs/EirikLygre/ contribs/JamesHouse/ contribs/Jamie Tsao/ contribs/JimMoore/ contribs/KevinSteppe/ contribs/KitchingSimon/ contribs/LeosLite...
Date Sat, 02 Jun 2012 11:41:11 GMT
Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,75 @@
+/*
+ * 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.log4j.lf5.viewer.categoryexplorer;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+
+/**
+ * Default implementation of TreeModelListener which does nothing.
+ *
+ * @author Richard Wan
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class TreeModelAdapter implements TreeModelListener {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+  public void treeNodesChanged(TreeModelEvent e) {
+  }
+
+  public void treeNodesInserted(TreeModelEvent e) {
+  }
+
+  public void treeNodesRemoved(TreeModelEvent e) {
+  }
+
+  public void treeStructureChanged(TreeModelEvent e) {
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,466 @@
+/*
+ * 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.log4j.lf5.viewer.configure;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.tree.TreePath;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.lf5.LogLevel;
+import org.apache.log4j.lf5.LogLevelFormatException;
+import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
+import org.apache.log4j.lf5.viewer.LogTable;
+import org.apache.log4j.lf5.viewer.LogTableColumn;
+import org.apache.log4j.lf5.viewer.LogTableColumnFormatException;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerModel;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerTree;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryNode;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryPath;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * <p>ConfigurationManager handles the storage and retrival of the state of
+ * the CategoryExplorer
+ *
+ * @author Richard Hurst
+ * @author Brad Marlborough
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class ConfigurationManager extends Object {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+  private static final String CONFIG_FILE_NAME = "lf5_configuration.xml";
+  private static final String NAME = "name";
+  private static final String PATH = "path";
+  private static final String SELECTED = "selected";
+  private static final String EXPANDED = "expanded";
+  private static final String CATEGORY = "category";
+  private static final String FIRST_CATEGORY_NAME = "Categories";
+  private static final String LEVEL = "level";
+  private static final String COLORLEVEL = "colorlevel";
+  private static final String RED = "red";
+  private static final String GREEN = "green";
+  private static final String BLUE = "blue";
+  private static final String COLUMN = "column";
+  private static final String NDCTEXTFILTER = "searchtext";
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+  private LogBrokerMonitor _monitor = null;
+  private LogTable _table = null;
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+  public ConfigurationManager(LogBrokerMonitor monitor, LogTable table) {
+    super();
+    _monitor = monitor;
+    _table = table;
+    load();
+  }
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  public void save() {
+    CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
+    CategoryNode root = model.getRootCategoryNode();
+
+    StringBuffer xml = new StringBuffer(2048);
+    openXMLDocument(xml);
+    openConfigurationXML(xml);
+    processLogRecordFilter(_monitor.getNDCTextFilter(), xml);
+    processLogLevels(_monitor.getLogLevelMenuItems(), xml);
+    processLogLevelColors(_monitor.getLogLevelMenuItems(),
+        LogLevel.getLogLevelColorMap(), xml);
+    processLogTableColumns(LogTableColumn.getLogTableColumns(), xml);
+    processConfigurationNode(root, xml);
+    closeConfigurationXML(xml);
+    store(xml.toString());
+  }
+
+  public void reset() {
+    deleteConfigurationFile();
+    collapseTree();
+    selectAllNodes();
+  }
+
+  public static String treePathToString(TreePath path) {
+    // count begins at one so as to not include the 'Categories' - root category
+    StringBuffer sb = new StringBuffer();
+    CategoryNode n = null;
+    Object[] objects = path.getPath();
+    for (int i = 1; i < objects.length; i++) {
+      n = (CategoryNode) objects[i];
+      if (i > 1) {
+        sb.append(".");
+      }
+      sb.append(n.getTitle());
+    }
+    return sb.toString();
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+  protected void load() {
+    File file = new File(getFilename());
+    if (file.exists()) {
+      try {
+        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.
+            newInstance();
+        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+        Document doc = docBuilder.parse(file);
+        processRecordFilter(doc);
+        processCategories(doc);
+        processLogLevels(doc);
+        processLogLevelColors(doc);
+        processLogTableColumns(doc);
+      } catch (Exception e) {
+        // ignore all error and just continue as if there was no
+        // configuration xml file but do report a message
+        System.err.println("Unable process configuration file at " +
+            getFilename() + ". Error Message=" + e.getMessage());
+      }
+    }
+
+  }
+
+  // Added in version 1.2 - reads in the NDC text filter from the
+  // xml configuration file.  If the value of the filter is not null
+  // or an empty string ("") then the manager will set the LogBrokerMonitor's
+  // LogRecordFilter to use the NDC LogRecordFilter.  Otherwise, the
+  // LogBrokerMonitor will use the default LogRecordFilter.
+  protected void processRecordFilter(Document doc) {
+    NodeList nodeList = doc.getElementsByTagName(NDCTEXTFILTER);
+
+    // there is only one value stored
+    Node n = nodeList.item(0);
+    // add check for backwards compatibility  as this feature was added in
+    // version 1.2
+    if (n == null) {
+      return;
+    }
+
+    NamedNodeMap map = n.getAttributes();
+    String text = getValue(map, NAME);
+
+    if (text == null || text.equals("")) {
+      return;
+    }
+    _monitor.setNDCLogRecordFilter(text);
+  }
+
+  protected void processCategories(Document doc) {
+    CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
+    CategoryExplorerModel model = tree.getExplorerModel();
+    NodeList nodeList = doc.getElementsByTagName(CATEGORY);
+
+    // determine where the starting node is
+    NamedNodeMap map = nodeList.item(0).getAttributes();
+    int j = (getValue(map, NAME).equalsIgnoreCase(FIRST_CATEGORY_NAME)) ? 1 : 0;
+    // iterate backwards throught the nodeList so that expansion of the
+    // list can occur
+    for (int i = nodeList.getLength() - 1; i >= j; i--) {
+      Node n = nodeList.item(i);
+      map = n.getAttributes();
+      CategoryNode chnode = model.addCategory(new CategoryPath(getValue(map, PATH)));
+      chnode.setSelected((getValue(map, SELECTED).equalsIgnoreCase("true")) ? true : false);
+      if (getValue(map, EXPANDED).equalsIgnoreCase("true")) ;
+      tree.expandPath(model.getTreePathToRoot(chnode));
+    }
+
+  }
+
+  protected void processLogLevels(Document doc) {
+    NodeList nodeList = doc.getElementsByTagName(LEVEL);
+    Map menuItems = _monitor.getLogLevelMenuItems();
+
+    for (int i = 0; i < nodeList.getLength(); i++) {
+      Node n = nodeList.item(i);
+      NamedNodeMap map = n.getAttributes();
+      String name = getValue(map, NAME);
+      try {
+        JCheckBoxMenuItem item =
+            (JCheckBoxMenuItem) menuItems.get(LogLevel.valueOf(name));
+        item.setSelected(getValue(map, SELECTED).equalsIgnoreCase("true"));
+      } catch (LogLevelFormatException e) {
+        // ignore it will be on by default.
+      }
+    }
+  }
+
+  protected void processLogLevelColors(Document doc) {
+    NodeList nodeList = doc.getElementsByTagName(COLORLEVEL);
+    LogLevel.getLogLevelColorMap();
+
+    for (int i = 0; i < nodeList.getLength(); i++) {
+      Node n = nodeList.item(i);
+      // check for backwards compatibility since this feature was added
+      // in version 1.3
+      if (n == null) {
+        return;
+      }
+
+      NamedNodeMap map = n.getAttributes();
+      String name = getValue(map, NAME);
+      try {
+        LogLevel level = LogLevel.valueOf(name);
+        int red = Integer.parseInt(getValue(map, RED));
+        int green = Integer.parseInt(getValue(map, GREEN));
+        int blue = Integer.parseInt(getValue(map, BLUE));
+        Color c = new Color(red, green, blue);
+        if (level != null) {
+          level.setLogLevelColorMap(level, c);
+        }
+
+      } catch (LogLevelFormatException e) {
+        // ignore it will be on by default.
+      }
+    }
+  }
+
+  protected void processLogTableColumns(Document doc) {
+    NodeList nodeList = doc.getElementsByTagName(COLUMN);
+    Map menuItems = _monitor.getLogTableColumnMenuItems();
+    List selectedColumns = new ArrayList();
+    for (int i = 0; i < nodeList.getLength(); i++) {
+      Node n = nodeList.item(i);
+      // check for backwards compatibility since this feature was added
+      // in version 1.3
+      if (n == null) {
+        return;
+      }
+      NamedNodeMap map = n.getAttributes();
+      String name = getValue(map, NAME);
+      try {
+        LogTableColumn column = LogTableColumn.valueOf(name);
+        JCheckBoxMenuItem item =
+            (JCheckBoxMenuItem) menuItems.get(column);
+        item.setSelected(getValue(map, SELECTED).equalsIgnoreCase("true"));
+
+        if (item.isSelected()) {
+          selectedColumns.add(column);
+        }
+      } catch (LogTableColumnFormatException e) {
+        // ignore it will be on by default.
+      }
+
+      if (selectedColumns.isEmpty()) {
+        _table.setDetailedView();
+      } else {
+        _table.setView(selectedColumns);
+      }
+
+    }
+  }
+
+  protected String getValue(NamedNodeMap map, String attr) {
+    Node n = map.getNamedItem(attr);
+    return n.getNodeValue();
+  }
+
+  protected void collapseTree() {
+    // collapse everything except the first category
+    CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
+    for (int i = tree.getRowCount() - 1; i > 0; i--) {
+      tree.collapseRow(i);
+    }
+  }
+
+  protected void selectAllNodes() {
+    CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
+    CategoryNode root = model.getRootCategoryNode();
+    Enumeration all = root.breadthFirstEnumeration();
+    CategoryNode n = null;
+    while (all.hasMoreElements()) {
+      n = (CategoryNode) all.nextElement();
+      n.setSelected(true);
+    }
+  }
+
+  protected void store(String s) {
+
+    try {
+      PrintWriter writer = new PrintWriter(new FileWriter(getFilename()));
+      writer.print(s);
+      writer.close();
+    } catch (IOException e) {
+      // do something with this error.
+      e.printStackTrace();
+    }
+
+  }
+
+  protected void deleteConfigurationFile() {
+    try {
+      File f = new File(getFilename());
+      if (f.exists()) {
+        f.delete();
+      }
+    } catch (SecurityException e) {
+      System.err.println("Cannot delete " + getFilename() +
+          " because a security violation occured.");
+    }
+  }
+
+  protected String getFilename() {
+    String home = System.getProperty("user.home");
+    String sep = System.getProperty("file.separator");
+
+    return home + sep + "lf5" + sep + CONFIG_FILE_NAME;
+  }
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+  private void processConfigurationNode(CategoryNode node, StringBuffer xml) {
+    CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
+
+    Enumeration all = node.breadthFirstEnumeration();
+    CategoryNode n = null;
+    while (all.hasMoreElements()) {
+      n = (CategoryNode) all.nextElement();
+      exportXMLElement(n, model.getTreePathToRoot(n), xml);
+    }
+
+  }
+
+  private void processLogLevels(Map logLevelMenuItems, StringBuffer xml) {
+    xml.append("\t<loglevels>\r\n");
+    Iterator it = logLevelMenuItems.keySet().iterator();
+    while (it.hasNext()) {
+      LogLevel level = (LogLevel) it.next();
+      JCheckBoxMenuItem item = (JCheckBoxMenuItem) logLevelMenuItems.get(level);
+      exportLogLevelXMLElement(level.getLabel(), item.isSelected(), xml);
+    }
+
+    xml.append("\t</loglevels>\r\n");
+  }
+
+  private void processLogLevelColors(Map logLevelMenuItems, Map logLevelColors, StringBuffer xml) {
+    xml.append("\t<loglevelcolors>\r\n");
+    // iterate through the list of log levels being used (log4j, jdk1.4, custom levels)
+    Iterator it = logLevelMenuItems.keySet().iterator();
+    while (it.hasNext()) {
+      LogLevel level = (LogLevel) it.next();
+      // for each level, get the associated color from the log level color map
+      Color color = (Color) logLevelColors.get(level);
+      exportLogLevelColorXMLElement(level.getLabel(), color, xml);
+    }
+
+    xml.append("\t</loglevelcolors>\r\n");
+  }
+
+
+  private void processLogTableColumns(List logTableColumnMenuItems, StringBuffer xml) {
+    xml.append("\t<logtablecolumns>\r\n");
+    Iterator it = logTableColumnMenuItems.iterator();
+    while (it.hasNext()) {
+      LogTableColumn column = (LogTableColumn) it.next();
+      JCheckBoxMenuItem item = _monitor.getTableColumnMenuItem(column);
+      exportLogTableColumnXMLElement(column.getLabel(), item.isSelected(), xml);
+    }
+
+    xml.append("\t</logtablecolumns>\r\n");
+  }
+
+  // Added in version 1.2 - stores the NDC text filter in the xml file
+  // for future use.
+  private void processLogRecordFilter(String text, StringBuffer xml) {
+    xml.append("\t<").append(NDCTEXTFILTER).append(" ");
+    xml.append(NAME).append("=\"").append(text).append("\"");
+    xml.append("/>\r\n");
+  }
+
+  private void openXMLDocument(StringBuffer xml) {
+    xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
+  }
+
+  private void openConfigurationXML(StringBuffer xml) {
+    xml.append("<configuration>\r\n");
+  }
+
+  private void closeConfigurationXML(StringBuffer xml) {
+    xml.append("</configuration>\r\n");
+  }
+
+  private void exportXMLElement(CategoryNode node, TreePath path, StringBuffer xml) {
+    CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
+
+    xml.append("\t<").append(CATEGORY).append(" ");
+    xml.append(NAME).append("=\"").append(node.getTitle()).append("\" ");
+    xml.append(PATH).append("=\"").append(treePathToString(path)).append("\" ");
+    xml.append(EXPANDED).append("=\"").append(tree.isExpanded(path)).append("\" ");
+    xml.append(SELECTED).append("=\"").append(node.isSelected()).append("\"/>\r\n");
+  }
+
+  private void exportLogLevelXMLElement(String label, boolean selected, StringBuffer xml) {
+    xml.append("\t\t<").append(LEVEL).append(" ").append(NAME);
+    xml.append("=\"").append(label).append("\" ");
+    xml.append(SELECTED).append("=\"").append(selected);
+    xml.append("\"/>\r\n");
+  }
+
+  private void exportLogLevelColorXMLElement(String label, Color color, StringBuffer xml) {
+    xml.append("\t\t<").append(COLORLEVEL).append(" ").append(NAME);
+    xml.append("=\"").append(label).append("\" ");
+    xml.append(RED).append("=\"").append(color.getRed()).append("\" ");
+    xml.append(GREEN).append("=\"").append(color.getGreen()).append("\" ");
+    xml.append(BLUE).append("=\"").append(color.getBlue());
+    xml.append("\"/>\r\n");
+  }
+
+  private void exportLogTableColumnXMLElement(String label, boolean selected, StringBuffer xml) {
+    xml.append("\t\t<").append(COLUMN).append(" ").append(NAME);
+    xml.append("=\"").append(label).append("\" ");
+    xml.append(SELECTED).append("=\"").append(selected);
+    xml.append("\"/>\r\n");
+  }
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces:
+  //--------------------------------------------------------------------------
+
+}
+
+
+
+
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,293 @@
+/*
+ * 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.log4j.lf5.viewer.configure;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+/**
+ * <p>MRUFileManager handles the storage and retrival the most
+ * recently opened log files.
+ *
+ * @author Brad Marlborough
+ * @author Richard Hurst
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class MRUFileManager {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+  private static final String CONFIG_FILE_NAME = "mru_file_manager";
+  private static final int DEFAULT_MAX_SIZE = 3;
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+  private int _maxSize = 0;
+  private LinkedList _mruFileList;
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+  public MRUFileManager() {
+    load();
+    setMaxSize(DEFAULT_MAX_SIZE);
+  }
+
+  public MRUFileManager(int maxSize) {
+    load();
+    setMaxSize(maxSize);
+  }
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Saves a list of MRU files out to a file.
+   */
+  public void save() {
+    File file = new File(getFilename());
+
+    try {
+      ObjectOutputStream oos = new ObjectOutputStream(new
+          FileOutputStream(file));
+      oos.writeObject(_mruFileList);
+      oos.flush();
+      oos.close();
+    } catch (Exception e) {
+      // do nothing
+      e.printStackTrace();
+    }
+  }
+
+  /**
+   * Gets the size of the MRU file list.
+   */
+  public int size() {
+    return _mruFileList.size();
+  }
+
+  /**
+   * Returns a particular file name stored in a MRU file
+   * list based on an index value.
+   */
+  public Object getFile(int index) {
+    if (index < size()) {
+      return _mruFileList.get(index);
+    }
+
+    return null;
+  }
+
+  /**
+   * Returns a input stream to the resource at the specified index
+   */
+  public InputStream getInputStream(int index) throws IOException,
+      FileNotFoundException {
+    if (index < size()) {
+      Object o = getFile(index);
+      if (o instanceof File) {
+        return getInputStream((File) o);
+      } else {
+        return getInputStream((URL) o);
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Adds a file name to the MRU file list.
+   */
+  public void set(File file) {
+    setMRU(file);
+  }
+
+  /**
+   * Adds a url to the MRU file list.
+   */
+  public void set(URL url) {
+    setMRU(url);
+  }
+
+  /**
+   * Gets the list of files stored in the MRU file list.
+   */
+  public String[] getMRUFileList() {
+    if (size() == 0) {
+      return null;
+    }
+
+    String[] ss = new String[size()];
+
+    for (int i = 0; i < size(); i++) {
+      Object o = getFile(i);
+      if (o instanceof File) {
+        ss[i] = ((File) o).getAbsolutePath();
+      } else // must be a url
+      {
+        ss[i] = o.toString();
+      }
+
+    }
+
+    return ss;
+  }
+
+  /**
+   * Moves the the index to the top of the MRU List
+   *
+   * @param index The index to be first in the mru list
+   */
+  public void moveToTop(int index) {
+    _mruFileList.add(0, _mruFileList.remove(index));
+  }
+
+  /**
+   * Creates the directory where the MRU file list will be written.
+   * The "lf5" directory is created in the Documents and Settings
+   * directory on Windows 2000 machines and where ever the user.home
+   * variable points on all other platforms.
+   */
+  public static void createConfigurationDirectory() {
+    String home = System.getProperty("user.home");
+    String sep = System.getProperty("file.separator");
+    File f = new File(home + sep + "lf5");
+    if (!f.exists()) {
+      try {
+        f.mkdir();
+      } catch (SecurityException e) {
+        e.printStackTrace();
+      }
+    }
+
+  }
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+  /**
+   * Gets an input stream for the corresponding file.
+   *
+   * @param file The file to create the input stream from.
+   * @return InputStream
+   */
+  protected InputStream getInputStream(File file) throws IOException,
+      FileNotFoundException {
+    BufferedInputStream reader =
+        new BufferedInputStream(new FileInputStream(file));
+
+    return reader;
+  }
+
+  /**
+   * Gets an input stream for the corresponding URL.
+   *
+   * @param url The url to create the input stream from.
+   * @return InputStream
+   */
+  protected InputStream getInputStream(URL url) throws IOException {
+    return url.openStream();
+  }
+
+  /**
+   * Adds an object to the mru.
+   */
+  protected void setMRU(Object o) {
+    int index = _mruFileList.indexOf(o);
+
+    if (index == -1) {
+      _mruFileList.add(0, o);
+      setMaxSize(_maxSize);
+    } else {
+      moveToTop(index);
+    }
+  }
+
+  /**
+   * Loads the MRU file list in from a file and stores it in a LinkedList.
+   * If no file exists, a new LinkedList is created.
+   */
+  protected void load() {
+    createConfigurationDirectory();
+    File file = new File(getFilename());
+    if (file.exists()) {
+      try {
+        ObjectInputStream ois = new ObjectInputStream(
+            new FileInputStream(file));
+        _mruFileList = (LinkedList) ois.readObject();
+        ois.close();
+
+        // check that only files and url are in linked list
+        Iterator it = _mruFileList.iterator();
+        while (it.hasNext()) {
+          Object o = it.next();
+          if (!(o instanceof File) && !(o instanceof URL)) {
+            it.remove();
+          }
+        }
+      } catch (Exception e) {
+        _mruFileList = new LinkedList();
+      }
+    } else {
+      _mruFileList = new LinkedList();
+    }
+
+  }
+
+  protected String getFilename() {
+    String home = System.getProperty("user.home");
+    String sep = System.getProperty("file.separator");
+
+    return home + sep + "lf5" + sep + CONFIG_FILE_NAME;
+  }
+
+  /**
+   * Ensures that the MRU list will have a MaxSize.
+   */
+  protected void setMaxSize(int maxSize) {
+    if (maxSize < _mruFileList.size()) {
+      for (int i = 0; i < _mruFileList.size() - maxSize; i++) {
+        _mruFileList.removeLast();
+      }
+    }
+
+    _maxSize = maxSize;
+  }
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
\ No newline at end of file

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties Sat Jun  2 11:40:31 2012
@@ -0,0 +1,31 @@
+# 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.
+
+# For the general syntax of property based configuration files see the
+# documenation of org.apache.log4j.PropertyConfigurator.
+
+# The root category uses the appender called A1. Since no priority is
+# specified, the root category assumes the default priority for root
+# which is DEBUG in log4j. The root category is the only category that
+# has a default priority. All other categories need not be assigned a
+# priority in which case they inherit their priority from the
+# hierarchy.
+
+log4j.rootCategory=, A1
+
+# A1 is set to be a LogMonitorAppender which outputs to a swing
+# logging console. 
+  
+log4j.appender.A1=org.apache.log4j.lf5.LF5Appender

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif?rev=1345492&view=auto
==============================================================================
Binary file - no diff available.

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif?rev=1345492&view=auto
==============================================================================
Binary file - no diff available.

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif?rev=1345492&view=auto
==============================================================================
Binary file - no diff available.

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Added: logging/log4j/branches/log4j12modules/modules/net/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/pom.xml?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/net/pom.xml (added)
+++ logging/log4j/branches/log4j12modules/modules/net/pom.xml Sat Jun  2 11:40:31 2012
@@ -0,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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+      <groupId>org.apache.log4j</groupId>
+      <artifactId>log4j-modules</artifactId>
+      <version>1.4.0-SNAPSHOT</version>
+  </parent>
+  <groupId>org.apache.log4j</groupId>
+  <artifactId>log4j-net</artifactId>
+  <name>Apache Log4j-Net</name>
+  <description>Apache Log4j Network Module</description>
+  <packaging>bundle</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.0.1</version>
+        <extensions>true</extensions>
+        <configuration>
+            <instructions>
+                <Export-Package>org.apache.log4j.net.*</Export-Package>
+                <Import-Package>javax.mail.*;resolution:=optional,
+                                *</Import-Package>
+                <Bundle-DocURL>http://logging.apache.org/log4j</Bundle-DocURL>
+            </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <version>${project.version}</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.mail</groupId>
+      <artifactId>mail</artifactId>
+      <version>1.4.1</version>
+      <optional>true</optional>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

Propchange: logging/log4j/branches/log4j12modules/modules/net/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/JMSAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/JMSAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/JMSSink.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/JMSSink.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SMTPAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SMTPAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SimpleSocketServer.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SimpleSocketServer.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketHubAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketHubAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketNode.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketNode.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketServer.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SocketServer.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SyslogAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/SyslogAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/TelnetAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/TelnetAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/ZeroConfSupport.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/ZeroConfSupport.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/package.html (from r1345481, logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/package.html)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/package.html?p2=logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/package.html&p1=logging/log4j/branches/log4j12modules/src/main/java/org/apache/log4j/net/package.html&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/main/java/org/apache/log4j/net/package.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java (added)
+++ logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java Sat Jun  2 11:40:31 2012
@@ -0,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.log4j.net;
+
+import junit.framework.TestCase;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.TriggeringEventEvaluator;
+import org.apache.log4j.xml.DOMConfigurator;
+
+/**
+ * Tests for SMTPAppender.
+ */
+public class SMTPAppenderTest extends TestCase {
+    public SMTPAppenderTest(final String testName) {
+        super(testName);
+    }
+
+    /**
+     * Reset configuration after every test.
+     */
+  public void tearDown() {
+      LogManager.resetConfiguration();
+  }
+
+    /**
+     * Trivial implementation of TriggeringEventEvaluator.
+     */
+  public static final class MockTriggeringEventEvaluator implements TriggeringEventEvaluator {
+        /**
+         * {@inheritDoc}
+         */
+      public boolean isTriggeringEvent(final LoggingEvent event) {
+          return true;
+      }
+  }
+
+    /**
+     * Tests that triggeringPolicy element will set evaluator.
+     */
+  public void testTrigger() {
+      DOMConfigurator.configure("target/test-classes/input/xml/smtpAppender1.xml");
+      SMTPAppender appender = (SMTPAppender) Logger.getRootLogger().getAppender("A1");
+      TriggeringEventEvaluator evaluator = appender.getEvaluator();
+      assertTrue(evaluator instanceof MockTriggeringEventEvaluator);
+  }
+}

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/ShortSocketServer.java (from r1345481, logging/log4j/branches/log4j12modules/tests/src/java/org/apache/log4j/net/ShortSocketServer.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/ShortSocketServer.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/ShortSocketServer.java&p1=logging/log4j/branches/log4j12modules/tests/src/java/org/apache/log4j/net/ShortSocketServer.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/ShortSocketServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/ShortSocketServer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketAppenderTest.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketAppenderTest.java (added)
+++ logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketAppenderTest.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,93 @@
+/*
+ * 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.log4j.net;
+
+import junit.framework.TestCase;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.xml.DOMConfigurator;
+
+public class SocketAppenderTest extends TestCase {
+
+    /**
+	 *  Create new instance.
+	 */
+    public SocketAppenderTest(final String testName) {
+	    super(testName);
+    }
+
+    /* JUnit's setUp and tearDown */
+
+    protected void setUp() {
+        DOMConfigurator.configure("target/test-classes/input/xml/SocketAppenderTestConfig.xml");
+
+        logger = Logger.getLogger(SocketAppenderTest.class);
+        secondary = (LastOnlyAppender) Logger.getLogger(
+                "org.apache.log4j.net.SocketAppenderTestDummy").getAppender("lastOnly");
+    }
+
+    protected void tearDown() {
+    }
+
+    /* Tests */
+
+    public void testFallbackErrorHandlerWhenStarting() {
+        String msg = "testFallbackErrorHandlerWhenStarting";
+        logger.debug(msg);
+
+        // above debug log will fail and shoul be redirected to secondary appender
+        assertEquals("SocketAppender with FallbackErrorHandler", msg, secondary.getLastMessage());
+    }
+
+    /* Fields */
+
+    private static Logger logger;
+    private static LastOnlyAppender secondary;
+
+    /* Inner classes */
+
+    /**
+     * Inner-class For debugging purposes only Saves last LoggerEvent
+     */
+    static public class LastOnlyAppender extends AppenderSkeleton {
+        protected void append(LoggingEvent event) {
+            this.lastEvent = event;
+        }
+
+        public boolean requiresLayout() {
+            return false;
+        }
+
+        public void close() {
+            this.closed = true;
+        }
+
+        /**
+         * @return last appended LoggingEvent's message
+         */
+        public String getLastMessage() {
+            if (this.lastEvent != null)
+                return this.lastEvent.getMessage().toString();
+            else
+                return "";
+        }
+
+        private LoggingEvent lastEvent;
+    };
+
+}
\ No newline at end of file

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketAppenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketServerTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketServerTestCase.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketServerTestCase.java (added)
+++ logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketServerTestCase.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,408 @@
+/*
+ * 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.log4j.net;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.framework.Test;
+
+import org.apache.log4j.*;
+import org.apache.log4j.util.*;
+
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
+import org.apache.log4j.xml.XLevel;
+
+/**
+   @author  Ceki G&uuml;lc&uuml;
+*/
+public class SocketServerTestCase extends TestCase {
+  
+  static String TEMP = "output/temp";
+  static String FILTERED = "output/filtered";
+
+  // %5p %x [%t] %c %m%n
+  // DEBUG T1 [main] org.apache.log4j.net.SocketAppenderTestCase Message 1
+  static String PAT1 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T1 \\[main]\\ "
+                       + ".* Message \\d{1,2}";
+
+  // DEBUG T2 [main] ? (?:?) Message 1
+  static String PAT2 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T2 \\[main]\\ "
+                       + "\\? \\(\\?:\\?\\) Message \\d{1,2}";
+
+
+  // DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:121) Message 1
+  static String PAT3 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T3 \\[main]\\ "
+                       + "org.apache.log4j.net.SocketServerTestCase "
+                       + "\\(SocketServerTestCase.java:\\d{3}\\) Message \\d{1,2}";
+
+
+  // DEBUG some T4 MDC-TEST4 [main] SocketAppenderTestCase - Message 1   
+  // DEBUG some T4 MDC-TEST4 [main] SocketAppenderTestCase - Message 1 
+  static String PAT4 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some T4 MDC-TEST4 \\[main]\\"
+                       + " (root|SocketServerTestCase) - Message \\d{1,2}";
+
+  static String PAT5 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some5 T5 MDC-TEST5 \\[main]\\"
+                       + " (root|SocketServerTestCase) - Message \\d{1,2}";
+
+  static String PAT6 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some6 T6 client-test6 MDC-TEST6"
+                       + " \\[main]\\ (root|SocketServerTestCase) - Message \\d{1,2}";
+
+  static String PAT7 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some7 T7 client-test7 MDC-TEST7"
+                       + " \\[main]\\ (root|SocketServerTestCase) - Message \\d{1,2}";
+
+  // DEBUG some8 T8 shortSocketServer MDC-TEST7 [main] SocketServerTestCase - Message 1
+  static String PAT8 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some8 T8 shortSocketServer"
+                       + " MDC-TEST8 \\[main]\\ (root|SocketServerTestCase) - Message \\d{1,2}";
+
+
+
+  static String EXCEPTION1 = "java.lang.Exception: Just testing";
+  static String EXCEPTION2 = "\\s*at .*\\(.*\\)";
+  static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)";
+  static String EXCEPTION4 = "\\s*at .*\\(.*Compiled Code\\)";
+  static String EXCEPTION5 = "\\s*at .*\\(.*libgcj.*\\)";
+
+
+  static Logger logger = Logger.getLogger(SocketServerTestCase.class);
+  static public final int PORT = 12345;  
+  static Logger rootLogger = Logger.getRootLogger();
+  SocketAppender socketAppender;
+
+  public SocketServerTestCase(String name) {
+    super(name);
+  }
+
+  public void setUp() {
+    System.out.println("Setting up test case.");
+  }
+  
+  public void tearDown() {
+    System.out.println("Tearing down test case.");
+    socketAppender = null;
+    rootLogger.removeAllAppenders();
+  }
+
+  /**
+   * The pattern on the server side: %5p %x [%t] %c %m%n     
+   *
+   * We are testing NDC functionality across the wire.  
+   */
+  public void test1() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    rootLogger.addAppender(socketAppender);
+    common("T1", "key1", "MDC-TEST1");
+    delay(1);
+    ControlFilter cf = new ControlFilter(new String[]{PAT1, EXCEPTION1, 
+						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+    Transformer.transform(
+      TEMP, FILTERED,
+      new Filter[] { cf, new LineNumberFilter(), 
+          new JunitTestRunnerFilter(),
+          new SunReflectFilter() });
+
+    assertTrue(Compare.compare(FILTERED, "witness/socketServer.1"));
+  }
+
+  /**
+   * The pattern on the server side: %5p %x [%t] %C (%F:%L) %m%n
+   *
+   * We are testing NDC across the wire. Localization is turned off by
+   * default so it is not tested here even if the conversion pattern
+   * uses localization. */
+  public void test2() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    rootLogger.addAppender(socketAppender);
+
+    common("T2", "key2", "MDC-TEST2");
+    delay(1);
+    ControlFilter cf = new ControlFilter(new String[]{PAT2, EXCEPTION1, 
+						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+    Transformer.transform(
+      TEMP, FILTERED,
+      new Filter[] { cf, new LineNumberFilter(), 
+          new JunitTestRunnerFilter(),
+          new SunReflectFilter() });
+
+    assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.2"));
+  }
+
+  /**
+   *  The pattern on the server side: %5p %x [%t] %C (%F:%L) %m%n
+   *  meaning that we are testing NDC and locatization functionality
+   *  across the wire.  */
+  public void test3() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    socketAppender.setLocationInfo(true);
+    rootLogger.addAppender(socketAppender);
+
+    common("T3", "key3", "MDC-TEST3");
+    delay(1);
+    ControlFilter cf = new ControlFilter(new String[]{PAT3, EXCEPTION1, 
+						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+    Transformer.transform(
+      TEMP, FILTERED,
+      new Filter[] { cf, new LineNumberFilter(), 
+          new JunitTestRunnerFilter(),
+          new SunReflectFilter() });
+
+    assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.3"));
+  }
+
+  /**
+   *  The pattern on the server side: %5p %x %X{key1}%X{key4} [%t] %c{1} - %m%n 
+   *  meaning that we are testing NDC, MDC and localization functionality across 
+   *  the wire.  
+  */
+  public void test4() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    socketAppender.setLocationInfo(true);
+    rootLogger.addAppender(socketAppender);
+
+    NDC.push("some");
+    common("T4", "key4", "MDC-TEST4");
+    NDC.pop();
+    delay(1);
+    //
+    //  These tests check MDC operation which
+    //    requires JDK 1.2 or later
+    if(!System.getProperty("java.version").startsWith("1.1.")) {
+    
+        ControlFilter cf = new ControlFilter(new String[]{PAT4, EXCEPTION1, 
+						           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+        Transformer.transform(
+          TEMP, FILTERED,
+          new Filter[] { cf, new LineNumberFilter(), 
+              new JunitTestRunnerFilter(),
+              new SunReflectFilter() });
+
+        assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.4"));
+    }
+  }
+
+  /**
+   * The pattern on the server side: %5p %x %X{key1}%X{key5} [%t] %c{1} - %m%n 
+   *
+   * The test case uses wraps an AsyncAppender around the
+   * SocketAppender. This tests was written specifically for bug
+   * report #9155.
+
+   * Prior to the bug fix the output on the server did not contain the
+   * MDC-TEST5 string because the MDC clone operation (in getMDCCopy
+   * method) operation is performed twice, once from the main thread
+   * which is correct, and a second time from the AsyncAppender's
+   * dispatch thread which is incrorrect.
+
+   */
+  public void test5() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    socketAppender.setLocationInfo(true);
+    AsyncAppender asyncAppender = new AsyncAppender();
+    asyncAppender.setLocationInfo(true);
+    asyncAppender.addAppender(socketAppender);
+    rootLogger.addAppender(asyncAppender);
+
+    NDC.push("some5");
+    common("T5", "key5", "MDC-TEST5");
+    NDC.pop();
+    delay(2);
+    //
+    //  These tests check MDC operation which
+    //    requires JDK 1.2 or later
+    if(!System.getProperty("java.version").startsWith("1.1.")) {
+        ControlFilter cf = new ControlFilter(new String[]{PAT5, EXCEPTION1, 
+						           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+        Transformer.transform(
+          TEMP, FILTERED,
+          new Filter[] { cf, new LineNumberFilter(), 
+              new JunitTestRunnerFilter(),
+              new SunReflectFilter() });
+
+        assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.5"));
+    }
+  }
+
+  /**
+   * The pattern on the server side: %5p %x %X{hostID}${key6} [%t] %c{1} - %m%n 
+   *
+   * This test checks whether client-side MDC overrides the server side.
+   * It uses an AsyncAppender encapsulating a SocketAppender
+   */
+  public void test6() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    socketAppender.setLocationInfo(true);
+    AsyncAppender asyncAppender = new AsyncAppender();
+    asyncAppender.setLocationInfo(true);
+    asyncAppender.addAppender(socketAppender);
+    rootLogger.addAppender(asyncAppender);
+
+    NDC.push("some6");
+    MDC.put("hostID", "client-test6");
+    common("T6", "key6", "MDC-TEST6");
+    NDC.pop();
+    MDC.remove("hostID");
+    delay(2);
+    //
+    //  These tests check MDC operation which
+    //    requires JDK 1.2 or later
+    if(!System.getProperty("java.version").startsWith("1.1.")) {
+        ControlFilter cf = new ControlFilter(new String[]{PAT6, EXCEPTION1, 
+						           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+        Transformer.transform(
+          TEMP, FILTERED,
+          new Filter[] { cf, new LineNumberFilter(), 
+              new JunitTestRunnerFilter(),
+              new SunReflectFilter() });
+
+        assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.6"));
+    }
+  }
+
+  /**
+   * The pattern on the server side: %5p %x %X{hostID}${key7} [%t] %c{1} - %m%n 
+   *
+   * This test checks whether client-side MDC overrides the server side.
+   */
+  public void test7() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    socketAppender.setLocationInfo(true);
+    rootLogger.addAppender(socketAppender);
+
+    NDC.push("some7");
+    MDC.put("hostID", "client-test7");
+    common("T7", "key7", "MDC-TEST7");
+    NDC.pop();
+    MDC.remove("hostID"); 
+    delay(2);
+    //
+    //  These tests check MDC operation which
+    //    requires JDK 1.2 or later
+    if(!System.getProperty("java.version").startsWith("1.1.")) {
+        ControlFilter cf = new ControlFilter(new String[]{PAT7, EXCEPTION1, 
+						           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+        Transformer.transform(
+          TEMP, FILTERED,
+          new Filter[] { cf, new LineNumberFilter(), 
+              new JunitTestRunnerFilter(),
+              new SunReflectFilter() });
+        assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.7"));
+    }
+  }
+
+  /**
+   * The pattern on the server side: %5p %x %X{hostID} ${key8} [%t] %c{1} - %m%n
+   *
+   * This test checks whether server side MDC works.
+   */
+  public void test8() throws Exception {
+    socketAppender = new SocketAppender("localhost", PORT);
+    socketAppender.setLocationInfo(true);
+    rootLogger.addAppender(socketAppender);
+
+    NDC.push("some8");
+
+    //
+    //   The test has relied on the receiving code to
+    //      combine the sent MDC with the receivers MDC
+    //      (which contains a value for hostID).
+    //      The mechanism of how that happens is not clear
+    //      and it does not work with Apache Harmony.
+    //      Unclear if it is a Harmony issue.
+    if (System.getProperty("java.vendor").indexOf("Apache") != -1) {
+        MDC.put("hostID", "shortSocketServer");
+    }
+
+    common("T8", "key8", "MDC-TEST8");
+    NDC.pop();
+    delay(2);
+    //
+    //  These tests check MDC operation which
+    //    requires JDK 1.2 or later
+    if(!System.getProperty("java.version").startsWith("1.1.")) {
+        ControlFilter cf = new ControlFilter(new String[]{PAT8, EXCEPTION1, 
+						           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
+    
+        Transformer.transform(
+          TEMP, FILTERED,
+          new Filter[] { cf, new LineNumberFilter(), 
+              new JunitTestRunnerFilter(),
+              new SunReflectFilter() });
+        assertTrue(Compare.compare(FILTERED, "target/test-classes/witness/socketServer.8"));
+    }
+  }
+
+  static 
+  void common(String dc, String key, Object o) {
+    String oldThreadName = Thread.currentThread().getName();
+    Thread.currentThread().setName("main");
+
+    int i = -1; 
+    NDC.push(dc); 
+    MDC.put(key, o);
+    Logger root = Logger.getRootLogger();
+
+    logger.setLevel(Level.DEBUG);
+    rootLogger.setLevel(Level.DEBUG);
+    
+    logger.log(XLevel.TRACE, "Message " + ++i);
+
+    logger.setLevel(Level.TRACE);
+    rootLogger.setLevel(Level.TRACE);
+    
+    logger.trace("Message " + ++i);
+    root.trace("Message " + ++i);
+    logger.debug("Message " + ++i);
+    root.debug("Message " + ++i);
+    logger.info("Message " + ++i);
+    logger.warn("Message " + ++i);
+    logger.log(XLevel.LETHAL, "Message " + ++i); //5
+    
+    Exception e = new Exception("Just testing");
+    logger.debug("Message " + ++i, e);
+    root.error("Message " + ++i, e);
+    NDC.pop();
+    MDC.remove(key);
+
+    Thread.currentThread().setName(oldThreadName);
+  }
+
+  public void delay(int secs) {
+    try {Thread.sleep(secs*1000);} catch(Exception e) {}
+  }
+
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite();
+    suite.addTest(new SocketServerTestCase("test1"));
+    suite.addTest(new SocketServerTestCase("test2"));
+    suite.addTest(new SocketServerTestCase("test3"));
+    suite.addTest(new SocketServerTestCase("test4"));
+    suite.addTest(new SocketServerTestCase("test5"));
+    suite.addTest(new SocketServerTestCase("test6"));
+    suite.addTest(new SocketServerTestCase("test7"));
+    suite.addTest(new SocketServerTestCase("test8"));
+    return suite;
+  }
+}

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SocketServerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SyslogAppenderTest.java (from r1345481, logging/log4j/branches/log4j12modules/tests/src/java/org/apache/log4j/net/SyslogAppenderTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SyslogAppenderTest.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SyslogAppenderTest.java&p1=logging/log4j/branches/log4j12modules/tests/src/java/org/apache/log4j/net/SyslogAppenderTest.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/SyslogAppenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/TelnetAppenderTest.java (from r1345481, logging/log4j/branches/log4j12modules/tests/src/java/org/apache/log4j/net/TelnetAppenderTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/TelnetAppenderTest.java?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/TelnetAppenderTest.java&p1=logging/log4j/branches/log4j12modules/tests/src/java/org/apache/log4j/net/TelnetAppenderTest.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/java/org/apache/log4j/net/TelnetAppenderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer1.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer1.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer1.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer1.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer1.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer1.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer1.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer2.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer2.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer2.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer2.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer2.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer2.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer2.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer3.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer3.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer3.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer3.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer3.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer3.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer3.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer4.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer4.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer4.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer4.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer4.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer4.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer4.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer5.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer5.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer5.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer5.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer5.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer5.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer5.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer6.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer6.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer6.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer6.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer6.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer6.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer6.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer7.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer7.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer7.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer7.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer7.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer7.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer7.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer8.properties (from r1345481, logging/log4j/branches/log4j12modules/tests/input/socketServer8.properties)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer8.properties?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer8.properties&p1=logging/log4j/branches/log4j12modules/tests/input/socketServer8.properties&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer8.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/socketServer8.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/SocketAppenderTestConfig.xml (from r1345481, logging/log4j/branches/log4j12modules/tests/input/xml/SocketAppenderTestConfig.xml)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/SocketAppenderTestConfig.xml?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/SocketAppenderTestConfig.xml&p1=logging/log4j/branches/log4j12modules/tests/input/xml/SocketAppenderTestConfig.xml&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/SocketAppenderTestConfig.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/smtpAppender1.xml (from r1345481, logging/log4j/branches/log4j12modules/tests/input/xml/smtpAppender1.xml)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/smtpAppender1.xml?p2=logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/smtpAppender1.xml&p1=logging/log4j/branches/log4j12modules/tests/input/xml/smtpAppender1.xml&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/net/src/test/resources/input/xml/smtpAppender1.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message