changeset 1469:fc7e8272a30e

Backported work with author file: Authors made as links in html docs, PR3426 - ITW Docs do not have correct 'AUTHOR' field * netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java: isntanceof replaced by correct interface method * netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/Formatter.java: added getAdressLink and replaceLtGtCharacters methods * netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/HtmlFormatter.java: implemented newmethods. Added dummy antispam protection * netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/ReplacingTextFormatter.java: dummy impl of new methods * tests/netx/unit/net/sourceforge/jnlp/util/docprovider/ReadAutorsTest.java: adapted * AUTHORS: removed invalid space after one lt mark * Makefile: (generate-docs.stamp) added and used (where appropriate) path to src AUTHORS file. * netx/net/sourceforge/jnlp/resources/Messages.properties: added message for case, when no authors file specified on input. * netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java: implemented possibility to include authors file to documentation. * tests/netx/unit/net/sourceforge/jnlp/util/docprovider/ReadAutorsTest.java: tests for generator
author Jiri Vanek <jvanek@redhat.com>
date Fri, 15 Dec 2017 14:53:03 +0100
parents 61be09286bf6
children ad5cd0fa9fbc
files AUTHORS ChangeLog Makefile.am netx/net/sourceforge/jnlp/resources/Messages.properties netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/Formatter.java netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/HtmlFormatter.java netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/ReplacingTextFormatter.java tests/netx/unit/net/sourceforge/jnlp/util/docprovider/ReadAutorsTest.java
diffstat 9 files changed, 338 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Fri Dec 15 14:30:07 2017 +0100
+++ b/AUTHORS	Fri Dec 15 14:53:03 2017 +0100
@@ -11,7 +11,7 @@
 Adam Domurad <adomurad@redhat.com>
 Lukasz Dracz <ldracz@redhat.com>
 Thomas Fitzsimmons <fitzsim@redhat.com>
-Michał Górny < mgorny@gentoo.org >
+Michał Górny <mgorny@gentoo.org>
 Mark Greenwood <mark@dcs.shef.ac.uk>
 Tereza Hlavackova <hlavackova.tereza@gmail.com>
 Peter Hatina <phatina@redhat.com>
@@ -43,6 +43,5 @@
 Man Lung Wong <mwong@redhat.com>
 
 This project also includes code from the following projects:
-
 OpenJDK <http://openjdk.java.net/>
 Netx <http://jnlp.sourceforge.net/netx/>
--- a/ChangeLog	Fri Dec 15 14:30:07 2017 +0100
+++ b/ChangeLog	Fri Dec 15 14:53:03 2017 +0100
@@ -1,3 +1,22 @@
+2017-15-12  Jiri Vanek <jvanek@redhat.com>
+            Tomáš Votava <tomcacolca@gmail.com>
+
+	Authors made as links in html docs, PR3426 - ITW Docs do not have correct 'AUTHOR' field 
+	* netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java: isntanceof replaced by correct interface method
+	* netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/Formatter.java: added getAdressLink and replaceLtGtCharacters methods
+	* netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/HtmlFormatter.java: implemented newmethods. Added dummy antispam protection
+	* netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/ReplacingTextFormatter.java: dummy impl of new methods
+	* tests/netx/unit/net/sourceforge/jnlp/util/docprovider/ReadAutorsTest.java: adapted
+	* AUTHORS: removed invalid space after one lt mark
+	* Makefile: (generate-docs.stamp) added and used (where appropriate)
+	path to src AUTHORS file.
+	* netx/net/sourceforge/jnlp/resources/Messages.properties: added message for
+	case, when no authors file specified on input.
+	* netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java: implemented
+	possibility to include authors file to documentation.
+	* tests/netx/unit/net/sourceforge/jnlp/util/docprovider/ReadAutorsTest.java:
+	tests for generator
+
 2017-15-12  Fridrich Strba  <fridrich.strba@suse.com>
 
 	Set source language version for javadoc generation for jdk9, Get rid of X509Factory class usage, Plugin made work again with jdk9
--- a/Makefile.am	Fri Dec 15 14:30:07 2017 +0100
+++ b/Makefile.am	Fri Dec 15 14:53:03 2017 +0100
@@ -730,6 +730,7 @@
 	HTML_DOCS_TARGET_DIR="$(DOCS_DIR)/html"  ; \
 	PLAIN_DOCS_TARGET_DIR="$(DOCS_DIR)/plain" ; \
 	MAN_DOCS_TARGET_DIR="$(DOCS_DIR)/man"  ; \
+	AUTHORS_FILE_TARGET="$(TOP_SRC_DIR)/AUTHORS" ; \
 	mkdir "$$HTML_DOCS_TARGET_DIR" ; \
 	mkdir "$$PLAIN_DOCS_TARGET_DIR" ; \
 	mkdir "$$MAN_DOCS_TARGET_DIR" ; \
@@ -745,16 +746,16 @@
 	  export LANG=$$LANG_ID; \
 	  mkdir "$$HTML_DOCS_TARGET_DIR/$$ID" ; \
 	  echo "<li><a href='$$ID/icedtea-web.html'>$$LANG_ID</a></li>"  >> "$$HTML_DOCS_INDEX" ; \
-	  $$TP_COMMAND html "$$HTML_DOCS_TARGET_DIR/$$ID" $$TP_TAIL ; \
+	  $$TP_COMMAND html "$$HTML_DOCS_TARGET_DIR/$$ID" $$TP_TAIL "-authorFile=$$AUTHORS_FILE_TARGET" ; \
 	  mkdir "$$PLAIN_DOCS_TARGET_DIR/$$ID" ; \
-	  $$TP_COMMAND plain "$$PLAIN_DOCS_TARGET_DIR/$$ID" 160 $$TP_TAIL; \
+	  $$TP_COMMAND plain "$$PLAIN_DOCS_TARGET_DIR/$$ID" 160 $$TP_TAIL "-authorFile=$$AUTHORS_FILE_TARGET" ; \
 	  if [ $$ID = "en" ] ; then \
 	    MAN_DESC="$$MAN_DOCS_TARGET_DIR/man1" ; \
 	  else \
 	    MAN_DESC="$$MAN_DOCS_TARGET_DIR/$$ID/man1" ; \
 	  fi ; \
 	  mkdir -p "$$MAN_DESC" ; \
-	  $$TP_COMMAND man $$ENCOD "$$MAN_DESC" $$TP_TAIL ; \
+	  $$TP_COMMAND man $$ENCOD "$$MAN_DESC" $$TP_TAIL "-authorFile=$$AUTHORS_FILE_TARGET" ; \
 	  $$TP_COMMAND htmlIntro "$(NETX_DIR)/net/sourceforge/jnlp/resources/about_$$ID.html" $$TP_TAIL; \
 	done ; \
 	export LANG=$$LANG_BACKUP ; \
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties	Fri Dec 15 14:30:07 2017 +0100
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties	Fri Dec 15 14:53:03 2017 +0100
@@ -30,6 +30,7 @@
 BUTback=Back
 BUTforward=Forward
 BUTreload=Reload
+ITWdocsMissingAuthors=See authors file
 
 HEADLESS_MISSCONFIGURED=Headless check failed. You are forced to run without any graphics. IcedTea-Web can run like this, but your app probably not. This is likely bug in your system.
 
--- a/netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java	Fri Dec 15 14:30:07 2017 +0100
+++ b/netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java	Fri Dec 15 14:53:03 2017 +0100
@@ -33,18 +33,23 @@
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version.
-*/
-
+ */
 package net.sourceforge.jnlp.util.docprovider;
 
+import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.Reader;
 import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -63,13 +68,16 @@
 import net.sourceforge.jnlp.util.docprovider.formatters.formatters.ReplacingTextFormatter;
 
 public abstract class TextsProvider {
+    
+    private static File authorFileFromUserInput = null;
 
     private final String encoding;
     private final Formatter formatter;
     private final boolean forceTitles;
     protected final boolean expandVariables;
     private boolean prepared = false;
-
+    private File authorFilePath = null;
+    
     private boolean introduction = true;
     private boolean synopsis = true;
     private boolean description = true;
@@ -184,7 +192,6 @@
             for (Map.Entry<String, Setting<String>> entry : defs) {
                 if (matchSttingsValueWithInfrastrucutreFile(entry.getValue(), f)) {
                     controlledBy = " " + Translator.R("BUTControlledBy", getFormatter().getBold(entry.getKey()));
-                    
                     break;
                 }
             }
@@ -271,13 +278,9 @@
     public String getAuthors() {
         if (forceTitles) {
             return getFormatter().getTitle(ManFormatter.KnownSections.AUTHOR)
-                    + getFormatter().wrapParagraph(
-                            getFormatter().process(Translator.R("ITWTBdebug"))
-                            + getFormatter().getNewLine());
+                    + generateAuthorsSection(authorFilePath);
         } else {
-            return getFormatter().wrapParagraph(
-                    getFormatter().process(Translator.R("ITWTBdebug"))
-                    + getFormatter().getNewLine());
+            return generateAuthorsSection(authorFilePath);
         }
     }
 
@@ -399,7 +402,7 @@
     public static void main(String[] args) throws IOException {
         // Shutdown hook from OutputController was causing hanging build on Windows. It's not used on headless.
         JNLPRuntime.setHeadless(true);
-
+        
         if (args.length == 0) {
             System.out.println(" * IcedTea-Web self documentation tool list of arguments *");
             System.out.println(" * argument version - last parameter of each command, is used when there is no internal versionknown *");
@@ -412,24 +415,38 @@
             System.out.println("man encoding targetDir expand version - will generate man documentation to target dir in desired encoding");
             System.out.println("plain targetDir maxLineWidth expand version - will generate plain text documentation to target dir in desired encoding");
             System.out.println("                                            - maxLineWidth is in <5," + Integer.MAX_VALUE + ">");
+            System.out.println("to generate informations about authors from a file, use argument '-authorFile' with path to AUTHORS file located in icedtea-web."
+                    + "\n eg. -authorFile=/home/user/icedtea-web/AUTHORS");
         } else {
-            ReplacingTextFormatter.backupVersion = args[args.length - 1];
-            boolean expand = Boolean.valueOf(args[args.length - 2]);
-            switch (args[0]) {
+            List<String> argsList = new ArrayList<>();
+            argsList.addAll(Arrays.asList(args));
+            for (String s : argsList) {
+                if (s.startsWith("-authorFile=")) {
+                    authorFileFromUserInput = new File(s.split("=")[1]);
+                    if (!authorFileFromUserInput.exists()) {
+                        throw new RuntimeException(authorFileFromUserInput.getAbsolutePath() + " does not exists");
+                    }
+                    argsList.remove(s);
+                    break;
+                }
+            }
+            ReplacingTextFormatter.backupVersion = argsList.get(argsList.size() - 1);
+            boolean expand = Boolean.valueOf(argsList.get(argsList.size() - 2));
+            switch (argsList.get(0)) {
                 case "all":
                     generateAll(new File(System.getProperty("user.dir")), expand);
                     break;
                 case "html":
-                    generateOnlineHtmlHelp(new File(args[1]), expand);
+                    generateOnlineHtmlHelp(new File(argsList.get(1)), expand);
                     break;
                 case "htmlIntro":
-                    generateItwIntro(new File(args[1]), expand);
+                    generateItwIntro(new File(argsList.get(1)), expand);
                     break;
                 case "man":
-                    generateManText(args[1], new File(args[2]), expand);
+                    generateManText(argsList.get(1), new File(argsList.get(2)), expand);
                     break;
                 case "plain":
-                    generatePlainTextDocs(new File(args[1]), Integer.valueOf(args[2]), expand);
+                    generatePlainTextDocs(new File(argsList.get(1)), Integer.valueOf(argsList.get(2)), expand);
                     break;
                 default:
                     System.out.println("unknown param");
@@ -441,6 +458,7 @@
 
     public static void generateItwIntro(File f, boolean expand) throws IOException {
         IcedTeaWebTextsProvider itw = new IcedTeaWebTextsProvider("utf-8", new HtmlFormatter(false, true, false), false, expand);
+        //!!AUTHORS FILE IS NOT NEEDED IN THIS METHOD, AUTHORS ARE GENERATED SEPARATELY INTO ANOTHER TAB
         itw.setSeeAlso(false);
         itw.writeToFile(f);
     }
@@ -481,15 +499,15 @@
             }
         }
         JavaWsTextsProvider javaws = new JavaWsTextsProvider(encoding, new HtmlFormatter(allowContext, allowLogo, includeXmlHeader), titles, expand);
-        javaws.writeToDir(dir);
         ItwebSettingsTextsProvider itws = new ItwebSettingsTextsProvider(encoding, new HtmlFormatter(allowContext, allowLogo, includeXmlHeader), titles, expand);
-        itws.writeToDir(dir);
         PolicyEditorTextsProvider pe = new PolicyEditorTextsProvider(encoding, new HtmlFormatter(allowContext, allowLogo, includeXmlHeader), titles, expand);
-        pe.writeToDir(dir);
         IcedTeaWebTextsProvider itw = new IcedTeaWebTextsProvider(encoding, new HtmlFormatter(allowContext, allowLogo, includeXmlHeader), titles, expand);
-        itw.writeToDir(dir);
         ItwebPluginTextProvider pl = new ItwebPluginTextProvider(encoding, new HtmlFormatter(allowContext, allowLogo, includeXmlHeader), titles, expand);
-        pl.writeToDir(dir);
+        TextsProvider[] providers = new TextsProvider[]{javaws, itws, pe, itw, pl};
+        for (TextsProvider provider : providers) {
+            provider.setAuthorFilePath(authorFileFromUserInput);
+            provider.writeToDir(dir);
+        }
 
     }
 
@@ -499,15 +517,15 @@
 
     public static void generateManText(String encoding, File dir, boolean titles, boolean expand) throws IOException {
         JavaWsTextsProvider javaws = new JavaWsTextsProvider(encoding, new ManFormatter(), titles, expand);
-        javaws.writeToDir(dir);
         ItwebSettingsTextsProvider itws = new ItwebSettingsTextsProvider(encoding, new ManFormatter(), titles, expand);
-        itws.writeToDir(dir);
         PolicyEditorTextsProvider pe = new PolicyEditorTextsProvider(encoding, new ManFormatter(), titles, expand);
-        pe.writeToDir(dir);
         IcedTeaWebTextsProvider itw = new IcedTeaWebTextsProvider(encoding, new ManFormatter(), titles, expand);
-        itw.writeToDir(dir);
         ItwebPluginTextProvider pl = new ItwebPluginTextProvider(encoding, new ManFormatter(), titles, expand);
-        pl.writeToDir(dir);
+        TextsProvider[] providers = new TextsProvider[]{javaws, itws, pe, itw, pl};
+        for (TextsProvider provider : providers) {
+            provider.setAuthorFilePath(authorFileFromUserInput);
+            provider.writeToDir(dir);
+        }
 
     }
 
@@ -517,15 +535,15 @@
 
     public static void generatePlainTextDocs(String encoding, File dir, String indent, int lineWidth, boolean titles, boolean expand) throws IOException {
         JavaWsTextsProvider javaws = new JavaWsTextsProvider(encoding, new PlainTextFormatter(indent, lineWidth), titles, expand);
-        javaws.writeToDir(dir);
         ItwebSettingsTextsProvider itws = new ItwebSettingsTextsProvider(encoding, new PlainTextFormatter(indent, lineWidth), titles, expand);
-        itws.writeToDir(dir);
         PolicyEditorTextsProvider pe = new PolicyEditorTextsProvider(encoding, new PlainTextFormatter(indent, lineWidth), titles, expand);
-        pe.writeToDir(dir);
         IcedTeaWebTextsProvider itw = new IcedTeaWebTextsProvider(encoding, new PlainTextFormatter(indent, lineWidth), titles, expand);
-        itw.writeToDir(dir);
         ItwebPluginTextProvider pl = new ItwebPluginTextProvider(encoding, new PlainTextFormatter(indent, lineWidth), titles, expand);
-        pl.writeToDir(dir);
+        TextsProvider[] providers = new TextsProvider[]{javaws, itws, pe, itw, pl};
+        for(TextsProvider provider : providers){
+            provider.setAuthorFilePath(authorFileFromUserInput);
+            provider.writeToDir(dir);
+        }
 
     }
 
@@ -671,6 +689,11 @@
         this.authors = authors;
     }
 
+    public void setAuthorFilePath(File authorFilePath) {
+        this.authorFilePath = authorFilePath;
+    }
+    
+
     /**
      * @return the seeAlso
      */
@@ -695,4 +718,49 @@
         return s;
     }
 
+    private String readAuthors(File authors) {
+        try {
+            return readAuthorsImpl(authors);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private String readAuthorsImpl(File authors) throws IOException {
+        return readAuthorsImpl(new InputStreamReader(new FileInputStream(authors), "UTF-8"));
+
+    }
+
+    String readAuthorsImpl(Reader authors) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        boolean areAuthors = false;
+        BufferedReader reader = new BufferedReader(authors);
+        while (true) {
+            String line = reader.readLine();
+            if (line == null) {
+                break;
+            }
+            if (line.trim().isEmpty()) {
+                areAuthors = !areAuthors;
+            }
+            sb.append(getFormatter().process(getFormatter().getAdressLink(line)));
+            if (getFormatter() instanceof HtmlFormatter || areAuthors == false) {
+                sb.append(getFormatter().getNewLine());
+            }
+        }
+        return sb.toString();
+    }
+
+    private String generateAuthorsSection(File filePath) {
+        if (filePath == null) {
+            return getFormatter().wrapParagraph(
+                    getFormatter().process(Translator.R("ITWdocsMissingAuthors"))
+                    + getFormatter().getNewLine());
+        } else {
+            return getFormatter().wrapParagraph(
+                    getFormatter().process(readAuthors(filePath))
+                    + getFormatter().getNewLine());
+        }
+    }
 }
+
--- a/netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/Formatter.java	Fri Dec 15 14:30:07 2017 +0100
+++ b/netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/Formatter.java	Fri Dec 15 14:53:03 2017 +0100
@@ -74,5 +74,9 @@
     public String getTail();
 
     public String getFileSuffix();
+    
+    public String getAdressLink(String s);
+    
+    public String replaceLtGtCharacters(String s);
 
 }
--- a/netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/HtmlFormatter.java	Fri Dec 15 14:30:07 2017 +0100
+++ b/netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/HtmlFormatter.java	Fri Dec 15 14:53:03 2017 +0100
@@ -33,8 +33,7 @@
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version.
-*/
-
+ */
 package net.sourceforge.jnlp.util.docprovider.formatters.formatters;
 
 import java.util.Date;
@@ -43,14 +42,15 @@
 import java.util.TreeMap;
 import net.sourceforge.jnlp.runtime.JNLPRuntime;
 
-
 public class HtmlFormatter extends ReplacingTextFormatter {
 
     private final Map<String, String> content = new TreeMap<>();
     private final boolean allowContext;
     private final boolean allowLogo;
     private final boolean includeXmlHeader;
-    public  static final String SUFFIX = "html";
+    private final String lT = "&#60";
+    private final String gT = "&#62";
+    public static final String SUFFIX = "html";
 
     @Override
     public String process(String s) {
@@ -58,7 +58,6 @@
         return s;
     }
 
-    
     public HtmlFormatter(boolean allowContext, boolean allowLogo, boolean includeXmlHeader) {
         this.allowContext = allowContext;
         this.allowLogo = allowLogo;
@@ -146,7 +145,7 @@
 
     @Override
     public String getFileSuffix() {
-        return "."+SUFFIX;
+        return "." + SUFFIX;
     }
 
     @Override
@@ -182,4 +181,30 @@
         return "<li><b>" + key + " </b> - " + process(value) + "</li>";
     }
 
+    @Override
+    public String getAdressLink(String s) {
+        String emailDelBracket = s.replaceAll(".*<", "");
+        String adress = emailDelBracket.replaceAll(">.*", "");
+        if (s.contains("@")) {
+            String name = s.replaceAll("<.*", "").trim();
+            return "<a href=\"mailto:" + antiSpam(adress) + "\" target=\"_top\">" + name + "</a>";
+        } else {
+            return s.replaceAll("<.*>", "<a href=\"" + adress + "\">" + adress + "</a>");
+        }
+    }
+
+    @Override
+    public String replaceLtGtCharacters(String s) {
+        String replaceLt = s.replaceAll("<", lT);
+        String replaceLtGt = replaceLt.replaceAll(">", gT);
+        return replaceLtGt;
+    }
+
+    private static String antiSpam(String adress) {
+        StringBuilder sb = new StringBuilder();
+        for (int x = 0; x < adress.length(); x++) {
+            sb.append(adress.charAt(x)).append(" ");
+        }
+        return sb.toString().trim();
+    }
 }
--- a/netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/ReplacingTextFormatter.java	Fri Dec 15 14:30:07 2017 +0100
+++ b/netx/net/sourceforge/jnlp/util/docprovider/formatters/formatters/ReplacingTextFormatter.java	Fri Dec 15 14:53:03 2017 +0100
@@ -99,8 +99,16 @@
         return sb.toString();
     }
     
+    @Override
+    public String getAdressLink(String s) {
+        return s;
+    }
     
-    
+    @Override
+    public String replaceLtGtCharacters(String s) {
+        return s;
+    }
+ 
     
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/docprovider/ReadAutorsTest.java	Fri Dec 15 14:53:03 2017 +0100
@@ -0,0 +1,168 @@
+/* ReadAutorsTest.java
+   Copyright (C) 2017 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+package net.sourceforge.jnlp.util.docprovider;
+
+import java.io.IOException;
+import java.io.StringReader;
+import net.sourceforge.jnlp.util.docprovider.formatters.formatters.HtmlFormatter;
+import net.sourceforge.jnlp.util.docprovider.formatters.formatters.ManFormatter;
+import net.sourceforge.jnlp.util.docprovider.formatters.formatters.PlainTextFormatter;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class ReadAutorsTest {
+    
+    public static final String NEWLINE = System.getProperty("line.separator");
+    public static final String HTMLNEWLINE = "<BR/>";
+    public static final String MANNEWLINE = ".br";
+    private static final String ANTISPAM_EMAIL="t e s t @ t e s t . t e s t";
+    
+    public static final String TESTTEXT = "NAME SURNAME <test@test.test>" + NEWLINE + "<><><>";
+    public static final String BRACKETSTESTREPLACED = "NAME SURNAME &#60test@test.test&#62" + NEWLINE + "&#60&#62&#60&#62&#60&#62";
+    public static final String BRACKETSTESTREPLACEDHTML = "<a href=\"mailto:"+ANTISPAM_EMAIL+"\"" + " target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE + "<a href=\"\"></a>" + HTMLNEWLINE + NEWLINE;
+    public static final String BRACKETSTESTREPLACEDMAN = "NAME SURNAME <test@test.test>" + NEWLINE + MANNEWLINE + NEWLINE + "<><><>" + NEWLINE + MANNEWLINE + NEWLINE;
+    public static final String BRACKETSTESTREPLACEDPLAIN = TESTTEXT + NEWLINE;
+    
+    public static final String FILESTREAM = "This is autor list." + NEWLINE + "This is random text." + NEWLINE
+            + NEWLINE
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + NEWLINE 
+            + "This is list with links" + NEWLINE
+            + "OpenJDK <http://openjdk.java.net/>" + NEWLINE
+            + "OpenJDK <http://openjdk.java.net/>" + NEWLINE;
+    public static final String FILESTREAMHTML = "This is autor list." + HTMLNEWLINE + NEWLINE + "This is random text." + HTMLNEWLINE + NEWLINE
+            + HTMLNEWLINE + NEWLINE
+            + "<a href=\"mailto:"+ANTISPAM_EMAIL+"\" target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE
+            + "<a href=\"mailto:"+ANTISPAM_EMAIL+"\" target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE
+            + "<a href=\"mailto:"+ANTISPAM_EMAIL+"\" target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE
+            + "<a href=\"mailto:"+ANTISPAM_EMAIL+"\" target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE
+            + "<a href=\"mailto:"+ANTISPAM_EMAIL+"\" target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE
+            + "<a href=\"mailto:"+ANTISPAM_EMAIL+"\" target=\"_top\">NAME SURNAME</a>" + HTMLNEWLINE + NEWLINE
+            + HTMLNEWLINE + NEWLINE
+            + "This is list with links" + HTMLNEWLINE + NEWLINE
+            + "OpenJDK <a href=\"http://openjdk.java.net/\">http://openjdk.java.net/</a>" + HTMLNEWLINE + NEWLINE
+            + "OpenJDK <a href=\"http://openjdk.java.net/\">http://openjdk.java.net/</a>" + HTMLNEWLINE + NEWLINE;
+    public static final String FILESTREAMPLAIN = "This is autor list." + NEWLINE + "This is random text." + NEWLINE
+            + "NAME SURNAME <test@test.test>"
+            + "NAME SURNAME <test@test.test>"
+            + "NAME SURNAME <test@test.test>"
+            + "NAME SURNAME <test@test.test>"
+            + "NAME SURNAME <test@test.test>"
+            + "NAME SURNAME <test@test.test>" + NEWLINE
+            + "This is list with links" + NEWLINE
+            + "OpenJDK <http://openjdk.java.net/>" + NEWLINE
+            + "OpenJDK <http://openjdk.java.net/>" + NEWLINE;
+
+    @Test
+    public void replaceBracketsWithEntitiesHtml() throws IOException {
+        TextsProvider tp = new TextsProvider("utf-8", new HtmlFormatter(), true, true) {
+            @Override
+            public String getId() {
+                return "test1";
+            }
+        };
+        String output = tp.readAuthorsImpl(new StringReader(TESTTEXT));
+        assertEquals(BRACKETSTESTREPLACEDHTML, output);
+    }
+
+    @Test
+    public void replaceBracketsWithEntitiesMan() throws IOException {
+        TextsProvider tp = new TextsProvider("utf-8", new ManFormatter(), true, true) {
+            @Override
+            public String getId() {
+                return "test2";
+            }
+        };
+        String output = tp.readAuthorsImpl(new StringReader(TESTTEXT));
+        assertEquals(BRACKETSTESTREPLACEDMAN, output);
+    }
+
+    @Test
+    public void replaceBracketsWithEntitiesPlain() throws IOException {
+        TextsProvider tp = new TextsProvider("utf-8", new PlainTextFormatter(), true, true) {
+            @Override
+            public String getId() {
+                return "test3";
+            }
+        };
+        String output = tp.readAuthorsImpl(new StringReader(TESTTEXT));
+        assertEquals(BRACKETSTESTREPLACEDPLAIN, output);
+    }
+
+    @Test
+    public void newLineTestHtml() throws IOException {
+        TextsProvider tp = new TextsProvider("utf-8", new HtmlFormatter(), true, true) {
+            @Override
+            public String getId() {
+                return "test4";
+            }
+        };
+        String output = tp.readAuthorsImpl(new StringReader(FILESTREAM));
+        assertEquals(FILESTREAMHTML, output);
+
+    }
+    
+    @Test
+    public void newLineTestPlainText() throws IOException {
+        TextsProvider tp = new TextsProvider("utf-8", new PlainTextFormatter(), true, true) {
+            @Override
+            public String getId() {
+                return "test5";
+            }
+        };
+        String output = tp.readAuthorsImpl(new StringReader(FILESTREAM));
+        assertEquals(FILESTREAMPLAIN, output);
+    }
+    
+    @Test
+    public void replaceLtGtTest() throws IOException {
+        TextsProvider tp = new TextsProvider("utf-8", new HtmlFormatter(), true, true) {
+            @Override
+            public String getId() {
+                return "test6";
+            }
+        };
+        String output = tp.getFormatter().replaceLtGtCharacters(TESTTEXT);
+        assertEquals(BRACKETSTESTREPLACED, output);
+    }
+}