This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch 1.2.X
in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git
The following commit(s) were added to refs/heads/1.2.X by this push:
new bc143870 Fixed checkstyle warnings
bc143870 is described below
commit bc1438706ecb5a5a75d7e0882c06f1dcf6771c05
Author: emmanuel lecharny <[email protected]>
AuthorDate: Mon Jan 6 16:17:22 2025 +0100
Fixed checkstyle warnings
---
core/pom.xml | 3 +-
.../org/apache/ftpserver/ftplet/UserManager.java | 19 +++++----
.../org/apache/ftpserver/ftplet/DataTypeTest.java | 16 +++++++-
.../ftpserver/ftplet/DefaultFtpReplyTest.java | 48 ++++++++++++++++++++--
.../org/apache/ftpserver/ftplet/ExampleFtplet.java | 16 +++++---
.../org/apache/ftpserver/ftplet/StructureTest.java | 13 ++++++
6 files changed, 95 insertions(+), 20 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index 03565825..ed29fa69 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -56,7 +56,8 @@
<instructions>
<Bundle-SymbolicName> ${project.artifactId}</Bundle-SymbolicName>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- <Export-Package> org.apache.ftpserver;version=${project.version},
+ <Export-Package>
+ org.apache.ftpserver;version=${project.version},
org.apache.ftpserver.command;version=${project.version},
org.apache.ftpserver.config.spring;version=${project.version},
org.apache.ftpserver.filesystem.nativefs;version=${project.version},
diff --git
a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/UserManager.java
b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/UserManager.java
index 79809671..7bad157e 100644
--- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/UserManager.java
+++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/UserManager.java
@@ -49,11 +49,10 @@ public interface UserManager {
/**
* Delete the user from the system.
- * @param username The name of the {@link User} to delete
*
+ * @param username The name of the {@link User} to delete
* @throws FtpException when the UserManager can't fulfill the request.
- * @throws UnsupportedOperationException
- * if UserManager in read-only mode
+ * @throws UnsupportedOperationException if UserManager in read-only mode
*/
void delete(String username) throws FtpException;
@@ -62,30 +61,31 @@ public interface UserManager {
*
* @param user the Uset to save
* @throws FtpException when the UserManager can't fulfill the request.
- * @throws UnsupportedOperationException
- * if UserManager in read-only mode
+ * @throws UnsupportedOperationException if UserManager in read-only mode
*/
void save(User user) throws FtpException;
/**
* Check if the user exists.
+ *
* @param username the name of the user to check.
* @return <code>true</code> if the user exist, <code>false</code>
otherwise.
- * @throws FtpException
+ * @throws FtpException If we got an error during the check
*/
boolean doesExist(String username) throws FtpException;
/**
* Authenticate user
+ *
* @param authentication The {@link Authentication} that proves the users
identity
* @return the authenticated account.
- * @throws AuthenticationFailedException
+ * @throws AuthenticationFailedException If the authentication failed
*/
- User authenticate(Authentication authentication)
- throws AuthenticationFailedException;
+ User authenticate(Authentication authentication) throws
AuthenticationFailedException;
/**
* Get admin user name
+ *
* @return the admin user name
* @throws FtpException when the UserManager can't fulfill the request.
*/
@@ -93,6 +93,7 @@ public interface UserManager {
/**
* Check if the user is admin.
+ *
* @param username The name of the {@link User} to check
* @return <code>true</code> if user with this login is administrator
* @throws FtpException when the UserManager can't fulfill the request.
diff --git
a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DataTypeTest.java
b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DataTypeTest.java
index 7e3826ec..ddfa61b3 100644
--- a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DataTypeTest.java
+++ b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DataTypeTest.java
@@ -22,21 +22,36 @@ package org.apache.ftpserver.ftplet;
import junit.framework.TestCase;
/**
+ * A Data type based test
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class DataTypeTest extends TestCase {
+ /**
+ * Default constructor
+ */
+ public DataTypeTest() {
+ }
+ /**
+ * Test Ascii
+ */
public void testParseA() {
assertSame(DataType.ASCII, DataType.parseArgument('A'));
assertSame(DataType.ASCII, DataType.parseArgument('a'));
}
+ /**
+ * Tst Binary
+ */
public void testParseI() {
assertSame(DataType.BINARY, DataType.parseArgument('I'));
assertSame(DataType.BINARY, DataType.parseArgument('i'));
}
+ /**
+ * test unknown type
+ */
public void testParseUnknown() {
try {
DataType.parseArgument('x');
@@ -45,5 +60,4 @@ public class DataTypeTest extends TestCase {
// ignore
}
}
-
}
diff --git
a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpReplyTest.java
b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpReplyTest.java
index 56b5db80..34713bdc 100644
---
a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpReplyTest.java
+++
b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DefaultFtpReplyTest.java
@@ -21,51 +21,76 @@ package org.apache.ftpserver.ftplet;
import junit.framework.TestCase;
-import org.apache.ftpserver.ftplet.DefaultFtpReply;
-
/**
+ * A FTP Reply test
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*
*/
public class DefaultFtpReplyTest extends TestCase {
+ /**
+ * Default constructor
+ */
+ public DefaultFtpReplyTest() {
+ }
+ /**
+ * Test single line
+ */
public void testSingleLineToString() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo bar");
assertEquals("123 foo bar\r\n", response.toString());
}
+ /**
+ * Test single line with trailing Line Feed
+ */
public void testSingleLineWithTrailingLineFeedToString() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo bar\n");
assertEquals("123 foo bar\r\n", response.toString());
}
+ /**
+ * Test lines with CRs/LFs
+ */
public void testCarriageReturnToString() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo \rbar\r\n");
assertEquals("123 foo bar\r\n", response.toString());
}
+ /**
+ * Test line with null text
+ */
public void testNullToString() {
DefaultFtpReply response = new DefaultFtpReply(123, (String) null);
assertEquals("123 \r\n", response.toString());
}
+ /**
+ * Test multiple lines
+ */
public void testMultipleLinesToString() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo\nbar\nbaz");
assertEquals("123-foo\r\nbar\r\n123 baz\r\n", response.toString());
}
+ /**
+ * Test multiple lines with final LF
+ */
public void testMultipleLinesEndWithNewlineToString() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo\nbar\nbaz\n");
assertEquals("123-foo\r\nbar\r\n123 baz\r\n", response.toString());
}
+ /**
+ * Test array of lines
+ */
public void testArrayLinesToString() {
DefaultFtpReply response = new DefaultFtpReply(123, new String[] {
"foo", "bar", "baz" });
@@ -73,40 +98,57 @@ public class DefaultFtpReplyTest extends TestCase {
assertEquals("123-foo\r\nbar\r\n123 baz\r\n", response.toString());
}
+ /**
+ * Test multiple lines starting with LF
+ */
public void testMultipleLinesToString1() {
DefaultFtpReply response = new DefaultFtpReply(123, "\nfoo\nbar\nbaz");
assertEquals("123-\r\nfoo\r\nbar\r\n123 baz\r\n", response.toString());
}
+ /**
+ * Test multiple lines with space at pos 0
+ */
public void testMultipleLinesToStringSpaceFirst() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo\n bar\nbaz");
assertEquals("123-foo\r\n bar\r\n123 baz\r\n", response.toString());
}
+ /**
+ * Test multiple lines with String and numbers
+ */
public void testMultipleLinesToStringThreeNumbers() {
DefaultFtpReply response = new DefaultFtpReply(123,
"foo\n234bar\nbaz");
assertEquals("123-foo\r\n 234bar\r\n123 baz\r\n",
response.toString());
}
+ /**
+ * Test multiple lines with number and strings
+ */
public void testMultipleLinesToStringThreeNumbersOnFirstLine() {
DefaultFtpReply response = new DefaultFtpReply(123,
"234foo\nbar\nbaz");
assertEquals("123-234foo\r\nbar\r\n123 baz\r\n", response.toString());
}
+ /**
+ * Test multiple lines with number at last
+ */
public void testMultipleLinesToStringThreeNumbersOnLastLine() {
DefaultFtpReply response = new DefaultFtpReply(123,
"foo\nbar\n234baz");
assertEquals("123-foo\r\nbar\r\n123 234baz\r\n", response.toString());
}
+ /**
+ * Test multiple lines with mixed numbers/text
+ */
public void testMultipleLinesToStringSingleNumberOnLine() {
DefaultFtpReply response = new DefaultFtpReply(123, "foo\n2bar\nbaz");
assertEquals("123-foo\r\n2bar\r\n123 baz\r\n", response.toString());
}
-
}
diff --git
a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/ExampleFtplet.java
b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/ExampleFtplet.java
index 266a2968..90f75e4a 100644
--- a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/ExampleFtplet.java
+++ b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/ExampleFtplet.java
@@ -22,25 +22,29 @@ package org.apache.ftpserver.ftplet;
import java.io.IOException;
/**
- *
+ * And FtpTel exemple test
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class ExampleFtplet extends DefaultFtplet {
+ /**
+ * Default constructor
+ */
+ public ExampleFtplet() {
+ }
@Override
- public FtpletResult onMkdirEnd(FtpSession session, FtpRequest request)
- throws FtpException, IOException {
+ public FtpletResult onMkdirEnd(FtpSession session, FtpRequest request)
throws FtpException, IOException {
session.write(new DefaultFtpReply(550, "Error!"));
+
return FtpletResult.SKIP;
}
@Override
- public FtpletResult onMkdirStart(FtpSession session, FtpRequest request)
- throws FtpException, IOException {
+ public FtpletResult onMkdirStart(FtpSession session, FtpRequest request)
throws FtpException, IOException {
if (session.isSecure() && session.getDataConnection().isSecure()) {
// all is good
}
+
return null;
}
-
}
diff --git
a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/StructureTest.java
b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/StructureTest.java
index 7c25ea4e..6b1f37a2 100644
--- a/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/StructureTest.java
+++ b/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/StructureTest.java
@@ -22,15 +22,28 @@ package org.apache.ftpserver.ftplet;
import junit.framework.TestCase;
/**
+ * A structure base test
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class StructureTest extends TestCase {
+ /**
+ * Default constructor
+ */
+ public StructureTest() {
+ }
+
+ /**
+ * A File parse test
+ */
public void testParseF() {
assertSame(Structure.FILE, Structure.parseArgument('F'));
assertSame(Structure.FILE, Structure.parseArgument('f'));
}
+ /**
+ * An unknown parse test
+ */
public void testParseUnknown() {
try {
Structure.parseArgument('x');