You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2022/08/23 16:16:43 UTC

[commons-net] branch master updated: Simplify by using actual class names

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new b398b4c5 Simplify by using actual class names
b398b4c5 is described below

commit b398b4c58c003b014966dc8e523ca61ba2c0cce8
Author: Sebb <se...@apache.org>
AuthorDate: Tue Aug 23 17:16:37 2022 +0100

    Simplify by using actual class names
---
 .../java/org/apache/commons/net/examples/Main.java |  1 -
 .../commons/net/examples/examples.properties       | 59 +++++++++++-----------
 .../org/apache/commons/net/examples/MainTest.java  |  6 +--
 3 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/examples/Main.java b/src/main/java/org/apache/commons/net/examples/Main.java
index 27308bf0..4e2fe92a 100644
--- a/src/main/java/org/apache/commons/net/examples/Main.java
+++ b/src/main/java/org/apache/commons/net/examples/Main.java
@@ -89,7 +89,6 @@ public class Main {
         if (fullName == null) {
             fullName = shortName;
         }
-        fullName = fullName.replace('/', '.');
         try {
             final Class<?> clazz = Class.forName(fullName);
             final Method m = clazz.getDeclaredMethod("main", args.getClass());
diff --git a/src/main/resources/org/apache/commons/net/examples/examples.properties b/src/main/resources/org/apache/commons/net/examples/examples.properties
index a77c8279..f295937e 100644
--- a/src/main/resources/org/apache/commons/net/examples/examples.properties
+++ b/src/main/resources/org/apache/commons/net/examples/examples.properties
@@ -18,35 +18,34 @@
 ##   limitations under the License.
 
 # List of aliases for example class names.
-# Note that the "/" separators are converted to "."
 
 #  alias                  full class name
-SubnetUtilsExample        org/apache/commons/net/examples/cidr/SubnetUtilsExample
-FTPClientExample          org/apache/commons/net/examples/ftp/FTPClientExample
-ServerToServerFTP         org/apache/commons/net/examples/ftp/ServerToServerFTP
-TFTPExample               org/apache/commons/net/examples/ftp/TFTPExample
-IMAPExportMbox            org/apache/commons/net/examples/mail/IMAPExportMbox
-IMAPImportMbox            org/apache/commons/net/examples/mail/IMAPImportMbox
-IMAPMail                  org/apache/commons/net/examples/mail/IMAPMail
-POP3ExportMbox            org/apache/commons/net/examples/mail/POP3ExportMbox
-POP3Mail                  org/apache/commons/net/examples/mail/POP3Mail
-SMTPMail                  org/apache/commons/net/examples/mail/SMTPMail
-ArticleReader             org/apache/commons/net/examples/nntp/ArticleReader
-ExtendedNNTPOps           org/apache/commons/net/examples/nntp/ExtendedNNTPOps
-ListNewsgroups            org/apache/commons/net/examples/nntp/ListNewsgroups
-MessageThreading          org/apache/commons/net/examples/nntp/MessageThreading
-PostMessage               org/apache/commons/net/examples/nntp/PostMessage
-NTPClient                 org/apache/commons/net/examples/ntp/NTPClient
-SimpleNTPServer           org/apache/commons/net/examples/ntp/SimpleNTPServer
-TimeClient                org/apache/commons/net/examples/ntp/TimeClient
-TelnetClientExample       org/apache/commons/net/examples/telnet/TelnetClientExample
-WeatherTelnet             org/apache/commons/net/examples/telnet/WeatherTelnet
-chargen                   org/apache/commons/net/examples/unix/chargen
-daytime                   org/apache/commons/net/examples/unix/daytime
-echo                      org/apache/commons/net/examples/unix/echo
-finger                    org/apache/commons/net/examples/unix/finger
-fwhois                    org/apache/commons/net/examples/unix/fwhois
-rdate                     org/apache/commons/net/examples/unix/rdate
-rexec                     org/apache/commons/net/examples/unix/rexec
-rlogin                    org/apache/commons/net/examples/unix/rlogin
-rshell                    org/apache/commons/net/examples/unix/rshell
+SubnetUtilsExample        org.apache.commons.net.examples.cidr.SubnetUtilsExample
+FTPClientExample          org.apache.commons.net.examples.ftp.FTPClientExample
+ServerToServerFTP         org.apache.commons.net.examples.ftp.ServerToServerFTP
+TFTPExample               org.apache.commons.net.examples.ftp.TFTPExample
+IMAPExportMbox            org.apache.commons.net.examples.mail.IMAPExportMbox
+IMAPImportMbox            org.apache.commons.net.examples.mail.IMAPImportMbox
+IMAPMail                  org.apache.commons.net.examples.mail.IMAPMail
+POP3ExportMbox            org.apache.commons.net.examples.mail.POP3ExportMbox
+POP3Mail                  org.apache.commons.net.examples.mail.POP3Mail
+SMTPMail                  org.apache.commons.net.examples.mail.SMTPMail
+ArticleReader             org.apache.commons.net.examples.nntp.ArticleReader
+ExtendedNNTPOps           org.apache.commons.net.examples.nntp.ExtendedNNTPOps
+ListNewsgroups            org.apache.commons.net.examples.nntp.ListNewsgroups
+MessageThreading          org.apache.commons.net.examples.nntp.MessageThreading
+PostMessage               org.apache.commons.net.examples.nntp.PostMessage
+NTPClient                 org.apache.commons.net.examples.ntp.NTPClient
+SimpleNTPServer           org.apache.commons.net.examples.ntp.SimpleNTPServer
+TimeClient                org.apache.commons.net.examples.ntp.TimeClient
+TelnetClientExample       org.apache.commons.net.examples.telnet.TelnetClientExample
+WeatherTelnet             org.apache.commons.net.examples.telnet.WeatherTelnet
+chargen                   org.apache.commons.net.examples.unix.chargen
+daytime                   org.apache.commons.net.examples.unix.daytime
+echo                      org.apache.commons.net.examples.unix.echo
+finger                    org.apache.commons.net.examples.unix.finger
+fwhois                    org.apache.commons.net.examples.unix.fwhois
+rdate                     org.apache.commons.net.examples.unix.rdate
+rexec                     org.apache.commons.net.examples.unix.rexec
+rlogin                    org.apache.commons.net.examples.unix.rlogin
+rshell                    org.apache.commons.net.examples.unix.rshell
diff --git a/src/test/java/org/apache/commons/net/examples/MainTest.java b/src/test/java/org/apache/commons/net/examples/MainTest.java
index f2e95343..ca27fed9 100644
--- a/src/test/java/org/apache/commons/net/examples/MainTest.java
+++ b/src/test/java/org/apache/commons/net/examples/MainTest.java
@@ -35,7 +35,6 @@ public class MainTest {
 
     private static boolean hasMainMethod(String name) {
         name = name.replace(".class", "");
-        name = name.replace(File.separatorChar, '.');
         try {
             final Class<?> clazz = Class.forName(name, false, MainTest.class.getClassLoader());
             clazz.getMethod("main", String[].class);
@@ -52,15 +51,16 @@ public class MainTest {
     }
 
     private static void processFileName(String name, final Properties p) {
+        name = name.replace(File.separatorChar, '.');
         if (!name.endsWith(".class")
                 || name.contains("$") // subclasses
-                || name.endsWith("examples"+ File.separator + "Main.class")  // the initial class, don't want to add that
+                || name.endsWith("examples.Main.class")  // the initial class, don't want to add that
                 || !hasMainMethod(name)
                 ) {
             return;
         }
         name = name.replace(".class", "");
-        final int lastSep = name.lastIndexOf('/');
+        final int lastSep = name.lastIndexOf('.');
         final String alias = name.substring(lastSep+1);
         if (p.containsKey(alias)) {
             System.out.printf("Duplicate alias: %-25s %s %s %n",alias,name,p.getProperty(alias));