Skip to content
Permalink
Browse files
Drop unnecessary JKS setup
Only show trace and commands when debugging
  • Loading branch information
sebbASF committed Aug 1, 2021
1 parent 9d90317 commit 45eba96562b341c16ed177ae722b9b6665df04aa
Showing 5 changed files with 18 additions and 12 deletions.
11 pom.xml
@@ -70,6 +70,9 @@ Supported protocols include: Echo, Finger, FTP, NNTP, NTP, POP3(S), SMTP(S), Tel
<commons.jacoco.version>0.8.7</commons.jacoco.version>
<commons.japicmp.version>0.15.3</commons.japicmp.version>
<commons.surefire.version>3.0.0-M5</commons.surefire.version>
<!-- for debugging FTPSClientTest -->
<commons.net.trace_calls>false</commons.net.trace_calls>
<commons.net.add_listener>false</commons.net.add_listener>
</properties>

<scm>
@@ -185,6 +188,10 @@ Supported protocols include: Echo, Finger, FTP, NNTP, NTP, POP3(S), SMTP(S), Tel
<exclude>**/*FunctionalTest.java</exclude>
<exclude>**/POP3*Test.java</exclude>
</excludes>
<environmentVariables>
<TRACE_CALLS>${commons.net.trace_calls}</TRACE_CALLS>
<ADD_LISTENER>${commons.net.add_listener}</ADD_LISTENER>
</environmentVariables>
</configuration>
</plugin>

@@ -427,6 +434,10 @@ Supported protocols include: Echo, Finger, FTP, NNTP, NTP, POP3(S), SMTP(S), Tel
<profiles>
<profile>
<id>slf4j-simple</id>
<properties>
<commons.net.trace_calls>true</commons.net.trace_calls>
<commons.net.add_listener>true</commons.net.add_listener>
</properties>
<dependencies>
<!-- adds logging for MINA ftpserver as used by FTPSClientTest -->
<dependency>
@@ -31,8 +31,6 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.net.PrintCommandListener;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
@@ -71,10 +69,7 @@ public class FTPSClientTest {

private static final String USER_PROPS_RES = "org/apache/commons/net/ftpsserver/users.properties";

// TEMPORARY hack to see if old JKS works
private static final String SERVER_JKS_RES_JRE_8 = "org/apache/commons/net/ftpsserver/ftpserver-old.jks";

private static final String SERVER_JKS_RES_JRE_16 = "org/apache/commons/net/ftpsserver/ftpserver-old.jks";
private static final String SERVER_JKS_RES = "org/apache/commons/net/ftpsserver/ftpserver.jks";

private static final boolean IMPLICIT = false;

@@ -88,10 +83,12 @@ private static String getTestHomeDirectory() {
}

private static final long TEST_TIMEOUT = 10000; // individual test timeout
private static final boolean TRACE_CALLS = Boolean.parseBoolean(System.getenv("TRACE_CALLS"));
private static final boolean ADD_LISTENER = Boolean.parseBoolean(System.getenv("ADD_LISTENER"));

private static final long startTime = System.nanoTime();
private static void trace(String msg) {
System.err.println(msg + " " + (System.nanoTime() - startTime));
if (TRACE_CALLS) System.err.println(msg + " " + (System.nanoTime() - startTime));
}

@BeforeClass
@@ -128,11 +125,9 @@ private synchronized static void setUpClass(final boolean implicit) throws FtpEx
factory.setPort(SocketPort);

// define SSL configuration
final URL serverJksResource = SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_16)
? ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES_JRE_16)
: ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES_JRE_8);
final URL serverJksResource = ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES);
Assert.assertNotNull(SERVER_JKS_RES, serverJksResource);
System.out.println("Loading " + serverJksResource);
Assert.assertNotNull(SERVER_JKS_RES_JRE_8, serverJksResource);
final SslConfigurationFactory sllConfigFactory = new SslConfigurationFactory();
final File keyStoreFile = FileUtils.toFile(serverJksResource);
Assert.assertTrue(keyStoreFile.toString(), keyStoreFile.exists());
@@ -173,7 +168,7 @@ private void assertClientCode(final FTPSClient client) {
private FTPSClient loginClient() throws SocketException, IOException {
trace(">>loginClient");
final FTPSClient client = new FTPSClient(IMPLICIT);
client.addProtocolCommandListener(new PrintCommandListener(System.err));
if (ADD_LISTENER) client.addProtocolCommandListener(new PrintCommandListener(System.err));
//
client.setControlKeepAliveReplyTimeout(null);
assertEquals(0, client.getControlKeepAliveReplyTimeoutDuration().getSeconds());
Binary file not shown.
Binary file not shown.

0 comments on commit 45eba96

Please sign in to comment.