diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/RemoteFileTestSupport.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/RemoteFileTestSupport.java index e814955c..ff343ba5 100644 --- a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/RemoteFileTestSupport.java +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/RemoteFileTestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,40 +88,40 @@ public File getTargetLocalDirectory() { *

* While a single server exists for all tests, the directory structure is rebuilt for * each test. - * @throws IOException IO Exception. + * @throws IOException the IO Exception. */ @BeforeEach public void setupFolders() throws IOException { String prefix = prefix(); recursiveDelete(new File(remoteTemporaryFolder.toFile(), prefix + "Source")); - sourceRemoteDirectory = new File(remoteTemporaryFolder.toFile(), prefix + "Source"); - sourceRemoteDirectory.mkdirs(); + this.sourceRemoteDirectory = new File(remoteTemporaryFolder.toFile(), prefix + "Source"); + this.sourceRemoteDirectory.mkdirs(); recursiveDelete(new File(remoteTemporaryFolder.toFile(), prefix + "Target")); - targetRemoteDirectory = new File(remoteTemporaryFolder.toFile(), prefix + "Target"); - targetRemoteDirectory.mkdirs(); + this.targetRemoteDirectory = new File(remoteTemporaryFolder.toFile(), prefix + "Target"); + this.targetRemoteDirectory.mkdirs(); recursiveDelete(new File(localTemporaryFolder.toFile(), "localSource")); - sourceLocalDirectory = new File(localTemporaryFolder.toFile(), "localSource"); - sourceLocalDirectory.mkdirs(); + this.sourceLocalDirectory = new File(localTemporaryFolder.toFile(), "localSource"); + this.sourceLocalDirectory.mkdirs(); recursiveDelete(new File(localTemporaryFolder.toFile(), "localTarget")); - targetLocalDirectory = new File(localTemporaryFolder.toFile(), "localTarget"); - targetLocalDirectory.mkdirs(); - File file = new File(sourceRemoteDirectory, prefix + "Source1.txt"); + this.targetLocalDirectory = new File(localTemporaryFolder.toFile(), "localTarget"); + this.targetLocalDirectory.mkdirs(); + File file = new File(this.sourceRemoteDirectory, prefix + "Source1.txt"); file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); fos.write("source1".getBytes()); fos.close(); - file = new File(sourceRemoteDirectory, prefix + "Source2.txt"); + file = new File(this.sourceRemoteDirectory, prefix + "Source2.txt"); file.createNewFile(); fos = new FileOutputStream(file); fos.write("source2".getBytes()); fos.close(); - file = new File(sourceLocalDirectory, "localSource1.txt"); + file = new File(this.sourceLocalDirectory, "localSource1.txt"); file.createNewFile(); fos = new FileOutputStream(file); fos.write("local1".getBytes()); fos.close(); - file = new File(sourceLocalDirectory, "localSource2.txt"); + file = new File(this.sourceLocalDirectory, "localSource2.txt"); file.createNewFile(); fos = new FileOutputStream(file); fos.write("local2".getBytes()); diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/package-info.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/package-info.java new file mode 100644 index 00000000..85f00b7b --- /dev/null +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/file/remote/package-info.java @@ -0,0 +1,4 @@ +/** + * The remote file protocols testing support. + */ +package org.springframework.cloud.fn.test.support.file.remote; diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/FtpTestSupport.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/FtpTestSupport.java index 65e7b87c..ae641bbe 100644 --- a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/FtpTestSupport.java +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/FtpTestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,6 @@ import org.apache.ftpserver.FtpServer; import org.apache.ftpserver.FtpServerFactory; import org.apache.ftpserver.ftplet.Authentication; -import org.apache.ftpserver.ftplet.AuthenticationFailedException; -import org.apache.ftpserver.ftplet.FtpException; import org.apache.ftpserver.ftplet.User; import org.apache.ftpserver.ftplet.UserManager; import org.apache.ftpserver.listener.ListenerFactory; @@ -62,7 +60,7 @@ public static void createServer() throws Exception { } @AfterAll - public static void stopServer() throws Exception { + public static void stopServer() { server.stop(); System.clearProperty("ftp.factory.port"); System.clearProperty("ftp.localDir"); @@ -86,40 +84,40 @@ private TestUserManager(String homeDirectory) { } @Override - public User getUserByName(String s) throws FtpException { + public User getUserByName(String s) { return this.testUser; } @Override - public String[] getAllUserNames() throws FtpException { + public String[] getAllUserNames() { return new String[] { "TEST_USER" }; } @Override - public void delete(String s) throws FtpException { + public void delete(String s) { } @Override - public void save(User user) throws FtpException { + public void save(User user) { } @Override - public boolean doesExist(String s) throws FtpException { + public boolean doesExist(String s) { return true; } @Override - public User authenticate(Authentication authentication) throws AuthenticationFailedException { + public User authenticate(Authentication authentication) { return this.testUser; } @Override - public String getAdminName() throws FtpException { + public String getAdminName() { return "admin"; } @Override - public boolean isAdmin(String s) throws FtpException { + public boolean isAdmin(String s) { return s.equals("admin"); } diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/package-info.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/package-info.java new file mode 100644 index 00000000..69e1dc8c --- /dev/null +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/ftp/package-info.java @@ -0,0 +1,4 @@ +/** + * The FTP protocol testing support. + */ +package org.springframework.cloud.fn.test.support.ftp; diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/SftpTestSupport.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/SftpTestSupport.java index 2c8b738a..c4fe87bf 100644 --- a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/SftpTestSupport.java +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/SftpTestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.security.PublicKey; import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; +import java.util.Base64; import java.util.Collections; import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; @@ -35,7 +36,6 @@ import org.springframework.cloud.fn.test.support.file.remote.RemoteFileTestSupport; import org.springframework.core.io.ClassPathResource; -import org.springframework.util.Base64Utils; import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; @@ -94,7 +94,7 @@ private static PublicKey decodePublicKey(String key) { while (keyBytes[keyBytes.length - 1] == 0x0a || keyBytes[keyBytes.length - 1] == 0x0d) { keyBytes = Arrays.copyOf(keyBytes, keyBytes.length - 1); } - byte[] decodeBuffer = Base64Utils.decode(keyBytes); + byte[] decodeBuffer = Base64.getDecoder().decode(keyBytes); ByteBuffer bb = ByteBuffer.wrap(decodeBuffer); int len = bb.getInt(); byte[] type = new byte[len]; @@ -110,8 +110,8 @@ private static PublicKey decodePublicKey(String key) { throw new IllegalArgumentException("Only supports RSA"); } } - catch (Exception e) { - throw new IllegalStateException("Failed to determine the test public key", e); + catch (Exception ex) { + throw new IllegalStateException("Failed to determine the test public key", ex); } } diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/package-info.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/package-info.java new file mode 100644 index 00000000..d8bce0ec --- /dev/null +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/sftp/package-info.java @@ -0,0 +1,4 @@ +/** + * The SFTP protocol testing support. + */ +package org.springframework.cloud.fn.test.support.sftp; diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/websocket/package-info.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/websocket/package-info.java new file mode 100644 index 00000000..5fe145d5 --- /dev/null +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/websocket/package-info.java @@ -0,0 +1,4 @@ +/** + * The WebSocket protocol testing support. + */ +package org.springframework.cloud.fn.test.support.websocket; diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/XmppTestContainerSupport.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/XmppTestContainerSupport.java index b3220c26..593a570a 100644 --- a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/XmppTestContainerSupport.java +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/XmppTestContainerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import org.testcontainers.junit.jupiter.Testcontainers; /** + * The contract for Openfire image Testcontainers support. + * * @author Chris Bono */ @Testcontainers(disabledWithoutDocker = true) diff --git a/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/package-info.java b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/package-info.java new file mode 100644 index 00000000..3b938646 --- /dev/null +++ b/common/spring-function-test-support/src/main/java/org/springframework/cloud/fn/test/support/xmpp/package-info.java @@ -0,0 +1,4 @@ +/** + * The XMPP protocol testing support. + */ +package org.springframework.cloud.fn.test.support.xmpp;