Fix Checkstyle violations for spring-function-test-support

This commit is contained in:
Artem Bilan
2024-01-04 16:37:18 -05:00
parent 38f0ca077c
commit bf35cee6fc
9 changed files with 52 additions and 32 deletions

View File

@@ -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 abstract class RemoteFileTestSupport {
* <p>
* 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());

View File

@@ -0,0 +1,4 @@
/**
* The remote file protocols testing support.
*/
package org.springframework.cloud.fn.test.support.file.remote;

View File

@@ -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 java.util.Arrays;
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 class FtpTestSupport extends RemoteFileTestSupport {
}
@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 @@ public class FtpTestSupport extends RemoteFileTestSupport {
}
@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");
}

View File

@@ -0,0 +1,4 @@
/**
* The FTP protocol testing support.
*/
package org.springframework.cloud.fn.test.support.ftp;

View File

@@ -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.KeyFactory;
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.junit.jupiter.api.BeforeAll;
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 @@ public class SftpTestSupport extends RemoteFileTestSupport {
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 @@ public class SftpTestSupport extends RemoteFileTestSupport {
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);
}
}

View File

@@ -0,0 +1,4 @@
/**
* The SFTP protocol testing support.
*/
package org.springframework.cloud.fn.test.support.sftp;

View File

@@ -0,0 +1,4 @@
/**
* The WebSocket protocol testing support.
*/
package org.springframework.cloud.fn.test.support.websocket;

View File

@@ -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.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Testcontainers;
/**
* The contract for Openfire image Testcontainers support.
*
* @author Chris Bono
*/
@Testcontainers(disabledWithoutDocker = true)

View File

@@ -0,0 +1,4 @@
/**
* The XMPP protocol testing support.
*/
package org.springframework.cloud.fn.test.support.xmpp;