get tests succeed

stable
Jörg Prante 2 months ago
parent 0d0fbe167b
commit 53bfaa6b60

@ -8,7 +8,7 @@ dependencies {
testImplementation project(':files-ftp-mock')
}
def moduleName = 'org.xbib.io.ftp.test'
def moduleName = 'org.xbib.files.ftp.fs.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {

@ -1,13 +1,13 @@
import java.nio.file.spi.FileSystemProvider;
import org.xbib.files.FileServiceProvider;
import org.xbib.io.ftp.fs.FTPFileSystemProvider;
import org.xbib.io.ftp.fs.spi.FTPFileServiceProvider;
import org.xbib.files.ftp.fs.FTPFileSystemProvider;
import org.xbib.files.ftp.fs.spi.FTPFileServiceProvider;
module org.xbib.files.ftp.fs {
requires org.xbib.files;
requires org.xbib.files.ftp;
exports org.xbib.io.ftp.fs;
exports org.xbib.io.ftp.fs.spi;
exports org.xbib.files.ftp.fs;
exports org.xbib.files.ftp.fs.spi;
provides FileSystemProvider with FTPFileSystemProvider;
provides FileServiceProvider with FTPFileServiceProvider;
}

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.io.IOException;
import java.nio.file.DirectoryIteratorException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.io.File;
import java.io.IOException;

@ -1,6 +1,6 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTPClient;
/**
* The possible FTP connection modes. Note that server-to-server is not supported.

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.CopyOption;
import java.nio.file.LinkOption;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystemException;

@ -1,8 +1,8 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.io.ftp.client.FTPFile;
import org.xbib.io.ftp.client.FTPFileFilter;
import org.xbib.files.ftp.FTPClient;
import org.xbib.files.ftp.FTPFile;
import org.xbib.files.ftp.FTPFileFilter;
import java.io.Closeable;
import java.io.IOException;

@ -1,10 +1,10 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTP;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.io.ftp.client.FTPClientConfig;
import org.xbib.io.ftp.client.FTPFileEntryParser;
import org.xbib.io.ftp.client.parser.FTPFileEntryParserFactory;
import org.xbib.files.ftp.FTP;
import org.xbib.files.ftp.FTPClient;
import org.xbib.files.ftp.FTPClientConfig;
import org.xbib.files.ftp.FTPFileEntryParser;
import org.xbib.files.ftp.parser.FTPFileEntryParserFactory;
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
@ -141,7 +141,7 @@ public class FTPEnvironment implements Map<String, Object>, Cloneable {
* @param password The password to use.
* @return This object.
*/
public FTPEnvironment withCredentials(String username, char[] password) {
public FTPEnvironment withCredentials(String username, String password) {
put(USERNAME, username);
put(PASSWORD, password);
return this;
@ -155,7 +155,7 @@ public class FTPEnvironment implements Map<String, Object>, Cloneable {
* @param account The account to use.
* @return This object.
*/
public FTPEnvironment withCredentials(String username, char[] password, String account) {
public FTPEnvironment withCredentials(String username, String password, String account) {
put(USERNAME, username);
put(PASSWORD, password);
put(ACCOUNT, account);

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.FileAlreadyExistsException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.io.IOException;
import java.nio.file.FileStore;

@ -1,7 +1,7 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTPFile;
import org.xbib.io.ftp.client.FTPFileFilter;
import org.xbib.files.ftp.FTPFile;
import org.xbib.files.ftp.FTPFileFilter;
import java.io.IOException;
import java.nio.file.NoSuchFileException;

@ -1,6 +1,6 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTPFile;
import org.xbib.files.ftp.FTPFile;
import java.io.IOException;
import java.io.InputStream;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.FileSystemException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.io.IOException;
import java.io.InputStream;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.util.Locale;
import java.util.ResourceBundle;
@ -8,8 +8,7 @@ import java.util.ResourceBundle;
*/
public final class FTPMessages {
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.xbib.ftp.fs.messages",
Locale.ROOT, UTF8Control.INSTANCE);
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.xbib.files.ftp.fs.messages", Locale.ROOT);
private FTPMessages() {
throw new Error("cannot create instances of " + getClass().getName());

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.NoSuchFileException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.NotDirectoryException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.NotLinkException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.io.IOException;
import java.io.InputStream;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
/**
* Represents a response from an FTP server.

@ -1,7 +1,7 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTP;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTP;
import org.xbib.files.ftp.FTPClient;
import java.io.IOException;
import java.nio.file.CopyOption;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.AccessDeniedException;
import java.nio.file.FileAlreadyExistsException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.io.IOException;
import java.io.InputStream;

@ -1,7 +1,7 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTP;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTP;
import org.xbib.files.ftp.FTPClient;
import java.io.IOException;
import java.nio.file.CopyOption;

@ -1,8 +1,8 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import org.xbib.io.ftp.client.FTP;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTP;
import org.xbib.files.ftp.FTPClient;
import java.io.IOException;
import java.nio.file.CopyOption;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.LinkOption;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.net.URI;
import java.nio.channels.SeekableByteChannel;
@ -28,7 +28,7 @@ import java.util.regex.PatternSyntaxException;
*/
public final class Messages {
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.xbib.ftp.fs.messages", UTF8Control.INSTANCE);
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.xbib.files.ftp.fs.messages");
private Messages() {
throw new Error("cannot create instances of " + getClass().getName());

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.FileSystem;
import java.nio.file.PathMatcher;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.attribute.PosixFilePermission;
import java.util.EnumSet;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
/**
* The possible FTPS security modes.

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.FileSystem;
import java.nio.file.Path;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.attribute.FileAttribute;
import java.util.Objects;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.attribute.GroupPrincipal;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.nio.file.attribute.UserPrincipal;
import java.util.Objects;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
/**
* The base class of option combinations that support file transfers.

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs;
package org.xbib.files.ftp.fs;
import java.net.URI;
import java.net.URISyntaxException;

@ -1,7 +1,7 @@
package org.xbib.io.ftp.fs.spi;
package org.xbib.files.ftp.fs.spi;
import org.xbib.io.ftp.fs.FTPEnvironment;
import org.xbib.io.ftp.fs.FTPFileSystemProvider;
import org.xbib.files.ftp.fs.FTPEnvironment;
import org.xbib.files.ftp.fs.FTPFileSystemProvider;
import java.io.Closeable;
import java.io.IOException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.spi;
package org.xbib.files.ftp.fs.spi;
import java.io.IOException;
import java.io.InputStream;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.spi;
package org.xbib.files.ftp.fs.spi;
import org.xbib.files.FileService;
import org.xbib.files.FileServiceProvider;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.spi;
package org.xbib.files.ftp.fs.spi;
import java.io.IOException;

@ -1,73 +0,0 @@
package org.xbib.io.ftp.fs;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.ResourceBundle.Control;
/**
* A resource bundle control that uses UTF-8 instead of the default encoding when reading resources from properties files. It is thread-safe.
*/
public final class UTF8Control extends Control {
/**
* The single instance.
*/
public static final UTF8Control INSTANCE = new UTF8Control();
private UTF8Control() {
super();
}
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, final ClassLoader loader, final boolean reload)
throws IllegalAccessException, InstantiationException, IOException {
if (!"java.properties".equals(format)) {
return super.newBundle(baseName, locale, format, loader, reload);
}
String bundleName = toBundleName(baseName, locale);
ResourceBundle bundle = null;
final String resourceName = toResourceName(bundleName, "properties");
InputStream in = null;
try {
in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
@Override
public InputStream run() throws Exception {
InputStream in = null;
if (reload) {
URL url = loader.getResource(resourceName);
if (url != null) {
URLConnection connection = url.openConnection();
if (connection != null) {
// Disable caches to get fresh data for reloading.
connection.setUseCaches(false);
in = connection.getInputStream();
}
}
} else {
in = loader.getResourceAsStream(resourceName);
}
return in;
}
});
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
if (in != null) {
try (Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
bundle = new PropertyResourceBundle(reader);
}
}
return bundle;
}
}

@ -1 +1 @@
org.xbib.io.ftp.fs.FTPFileSystemProvider
org.xbib.files.ftp.fs.FTPFileSystemProvider

@ -1 +1 @@
org.xbib.io.ftp.fs.spi.FTPFileServiceProvider
org.xbib.files.ftp.fs.spi.FTPFileServiceProvider

@ -8,8 +8,8 @@ module org.xbib.files.ftp.fs.test {
requires org.xbib.files.ftp.fs;
requires org.xbib.files.ftp.mock;
requires java.logging;
exports org.xbib.io.ftp.fs.test;
exports org.xbib.io.ftp.fs.test.server;
opens org.xbib.io.ftp.fs.test to org.junit.platform.commons;
opens org.xbib.io.ftp.fs.test.server to org.junit.platform.commons;
exports org.xbib.files.ftp.fs.test.server;
exports org.xbib.files.ftp.fs.test;
opens org.xbib.files.ftp.fs.test to org.junit.platform.commons;
opens org.xbib.files.ftp.fs.test.server to org.junit.platform.commons;
}

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
@ -12,16 +12,16 @@ import org.xbib.files.ftp.mock.fake.filesystem.FileEntry;
import org.xbib.files.ftp.mock.fake.filesystem.FileSystem;
import org.xbib.files.ftp.mock.fake.filesystem.FileSystemEntry;
import org.xbib.files.ftp.mock.fake.filesystem.UnixFakeFileSystem;
import org.xbib.io.ftp.fs.DefaultFileSystemExceptionFactory;
import org.xbib.io.ftp.fs.FTPEnvironment;
import org.xbib.io.ftp.fs.FTPFileSystem;
import org.xbib.io.ftp.fs.FTPFileSystemProvider;
import org.xbib.io.ftp.fs.FTPPath;
import org.xbib.io.ftp.fs.FileSystemExceptionFactory;
import org.xbib.io.ftp.fs.test.server.ExtendedUnixFakeFileSystem;
import org.xbib.io.ftp.fs.test.server.ListHiddenFilesCommandHandler;
import org.xbib.io.ftp.fs.test.server.MDTMCommandHandler;
import org.xbib.io.ftp.fs.test.server.SymbolicLinkEntry;
import org.xbib.files.ftp.fs.DefaultFileSystemExceptionFactory;
import org.xbib.files.ftp.fs.FTPEnvironment;
import org.xbib.files.ftp.fs.FTPFileSystem;
import org.xbib.files.ftp.fs.FTPFileSystemProvider;
import org.xbib.files.ftp.fs.FTPPath;
import org.xbib.files.ftp.fs.FileSystemExceptionFactory;
import org.xbib.files.ftp.fs.test.server.ExtendedUnixFakeFileSystem;
import org.xbib.files.ftp.fs.test.server.ListHiddenFilesCommandHandler;
import org.xbib.files.ftp.fs.test.server.MDTMCommandHandler;
import org.xbib.files.ftp.fs.test.server.SymbolicLinkEntry;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -89,7 +89,7 @@ public abstract class AbstractFTPFileSystemTest {
protected static FTPEnvironment createEnv() {
return new FTPEnvironment()
.withCredentials(USERNAME, PASSWORD.toCharArray())
.withCredentials(USERNAME, PASSWORD)
.withClientConnectionCount(1)
.withFileSystemExceptionFactory(exceptionFactory);
}

@ -1,12 +1,12 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.io.ftp.client.FTPClientConfig;
import org.xbib.io.ftp.client.parser.DefaultFTPFileEntryParserFactory;
import org.xbib.files.ftp.FTPClient;
import org.xbib.files.ftp.FTPClientConfig;
import org.xbib.files.ftp.parser.DefaultFTPFileEntryParserFactory;
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
@ -16,9 +16,9 @@ import java.net.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.stream.Stream;
import org.xbib.io.ftp.fs.ConnectionMode;
import org.xbib.io.ftp.fs.DefaultFileSystemExceptionFactory;
import org.xbib.io.ftp.fs.FTPEnvironment;
import org.xbib.files.ftp.fs.ConnectionMode;
import org.xbib.files.ftp.fs.DefaultFileSystemExceptionFactory;
import org.xbib.files.ftp.fs.FTPEnvironment;
public class FTPEnvironmentSetterTest {

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
@ -8,7 +8,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.xbib.io.ftp.fs.FTPEnvironment;
import org.xbib.files.ftp.fs.FTPEnvironment;
public class FTPEnvironmentTest {
@ -36,7 +36,7 @@ public class FTPEnvironmentTest {
assertEquals(Collections.emptyMap(), env);
String username = UUID.randomUUID().toString();
char[] password = UUID.randomUUID().toString().toCharArray();
String password = UUID.randomUUID().toString();
env.withCredentials(username, password);
@ -53,7 +53,7 @@ public class FTPEnvironmentTest {
assertEquals(Collections.emptyMap(), env);
String username = UUID.randomUUID().toString();
char[] password = UUID.randomUUID().toString().toCharArray();
String password = UUID.randomUUID().toString();
String account = UUID.randomUUID().toString();
env.withCredentials(username, password, account);

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import org.hamcrest.Description;
import org.hamcrest.Matcher;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -18,11 +18,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.xbib.files.ftp.mock.fake.filesystem.FileEntry;
import org.xbib.io.ftp.fs.FTPFileSystem;
import org.xbib.io.ftp.fs.FTPFileSystemProvider;
import org.xbib.io.ftp.fs.FTPPath;
import org.xbib.io.ftp.fs.FileType;
import org.xbib.io.ftp.fs.URISupport;
import org.xbib.files.ftp.fs.FTPFileSystem;
import org.xbib.files.ftp.fs.FTPFileSystemProvider;
import org.xbib.files.ftp.fs.FTPPath;
import org.xbib.files.ftp.fs.FileType;
import org.xbib.files.ftp.fs.URISupport;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -6,13 +6,13 @@ import org.mockito.verification.VerificationMode;
import org.xbib.files.ftp.mock.fake.filesystem.DirectoryEntry;
import org.xbib.files.ftp.mock.fake.filesystem.FileEntry;
import org.xbib.files.ftp.mock.fake.filesystem.FileSystemEntry;
import org.xbib.io.ftp.client.FTPFile;
import org.xbib.io.ftp.fs.FTPFileSystem;
import org.xbib.io.ftp.fs.FTPFileSystemException;
import org.xbib.io.ftp.fs.FTPPath;
import org.xbib.io.ftp.fs.SimpleGroupPrincipal;
import org.xbib.io.ftp.fs.SimpleUserPrincipal;
import org.xbib.io.ftp.fs.test.server.SymbolicLinkEntry;
import org.xbib.files.ftp.FTPFile;
import org.xbib.files.ftp.fs.FTPFileSystem;
import org.xbib.files.ftp.fs.FTPFileSystemException;
import org.xbib.files.ftp.fs.FTPPath;
import org.xbib.files.ftp.fs.SimpleGroupPrincipal;
import org.xbib.files.ftp.fs.SimpleUserPrincipal;
import org.xbib.files.ftp.fs.test.server.SymbolicLinkEntry;
import java.io.IOException;
import java.io.InputStream;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test;
package org.xbib.files.ftp.fs.test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@ -19,7 +19,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;
import org.xbib.io.ftp.fs.FTPMessages;
import org.xbib.files.ftp.fs.FTPMessages;
public class FTPMessagesTest {

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test.server;
package org.xbib.files.ftp.fs.test.server;
import org.xbib.files.ftp.mock.fake.filesystem.FileSystemEntry;
import org.xbib.files.ftp.mock.fake.filesystem.UnixDirectoryListingFormatter;

@ -1,10 +1,9 @@
package org.xbib.io.ftp.fs.test.server;
package org.xbib.files.ftp.fs.test.server;
import java.util.List;
import org.xbib.files.ftp.mock.fake.filesystem.FileSystemEntry;
import org.xbib.files.ftp.mock.fake.filesystem.UnixFakeFileSystem;
import static org.xbib.io.ftp.client.parser.FTPTimestampParserImpl.getEntry;
/**
* An extended version of {@link UnixFakeFileSystem} that supports symbolic links.

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test.server;
package org.xbib.files.ftp.fs.test.server;
import java.util.ArrayList;
import java.util.Iterator;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test.server;
package org.xbib.files.ftp.fs.test.server;
import java.text.SimpleDateFormat;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.fs.test.server;
package org.xbib.files.ftp.fs.test.server;
import java.util.Date;
import org.xbib.files.ftp.mock.fake.filesystem.FileSystemEntry;

@ -3,3 +3,14 @@ dependencies {
testImplementation project(':files-ftp')
testImplementation testLibs.mockito.core
}
def moduleName = 'org.xbib.files.ftp.mock.test'
def patchArgs = ['--patch-module', "$moduleName=" + files(sourceSets.test.resources.srcDirs).asPath ]
tasks.named('compileTestJava') {
options.compilerArgs += patchArgs
}
tasks.named('test') {
jvmArgs += patchArgs
}

@ -78,7 +78,7 @@ public abstract class AbstractFtpServer implements Runnable {
/**
* Default basename for reply text ResourceBundle
*/
public static final String REPLY_TEXT_BASENAME = "ReplyText";
public static final String REPLY_TEXT_BASENAME = "org.xbib.files.ftp.mock.core.server.ReplyText";
private static final int DEFAULT_SERVER_CONTROL_PORT = 21;
protected Logger LOG = Logger.getLogger(getClass().getName());

@ -15,6 +15,7 @@
*/
package org.xbib.files.ftp.mock.stub.command;
import java.util.Objects;
import java.util.logging.Level;
import org.xbib.files.ftp.mock.core.MockFtpServerException;
import org.xbib.files.ftp.mock.core.command.Command;
@ -26,6 +27,7 @@ import org.xbib.files.ftp.mock.core.util.AssertFailedException;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;
/**
* CommandHandler for the RETR command. Returns the contents of the specified file on the
@ -48,15 +50,20 @@ import java.io.InputStream;
*/
public class FileRetrCommandHandler extends AbstractStubDataCommandHandler implements CommandHandler {
private static final Logger logger = Logger.getLogger(FileRetrCommandHandler.class.getName());
public static final String PATHNAME_KEY = "pathname";
public static final int BUFFER_SIZE = 512; // package-private for testing
private final Class<?> cl;
private String file;
/**
* Create new uninitialized instance
*/
public FileRetrCommandHandler() {
this(null, FileRetrCommandHandler.class);
}
/**
@ -65,8 +72,9 @@ public class FileRetrCommandHandler extends AbstractStubDataCommandHandler imple
* @param file - the path to the file
* @throws AssertFailedException - if the file is null
*/
public FileRetrCommandHandler(String file) {
setFile(file);
public FileRetrCommandHandler(String file, Class<?> cl) {
this.file = file;
this.cl = Objects.requireNonNull(cl);
}
/**
@ -81,7 +89,8 @@ public class FileRetrCommandHandler extends AbstractStubDataCommandHandler imple
* @see AbstractStubDataCommandHandler#processData(Command, Session, InvocationRecord)
*/
protected void processData(Command command, Session session, InvocationRecord invocationRecord) {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(file);
logger.log(Level.INFO, "cl = " + cl + " file = " + file);
InputStream inputStream = cl.getClassLoader().getResourceAsStream(file);
Assert.notNull(inputStream, "InputStream for [" + file + "]");
byte[] buffer = new byte[BUFFER_SIZE];
try {
@ -104,7 +113,6 @@ public class FileRetrCommandHandler extends AbstractStubDataCommandHandler imple
* @throws AssertFailedException - if the file is null
*/
public void setFile(String file) {
Assert.notNull(file, "file");
this.file = file;
}

@ -0,0 +1,132 @@
# Copyright 2008 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
# Mapping of reply code -> reply text
#-------------------------------------------------------------------------------
110=Restart marker reply.
120=Service ready in nnn minutes.
125=Data connection already open; transfer starting.
150=File status okay; about to open data connection.
200=Command okay.
202=Command not implemented, superfluous at this site.
211={0}.
212={0}.
213={0}.
214={0}.
215={0} system type.
220=Service ready for new user. (MockFtpServer 3.1.0; see http://mockftpserver.org)
221=Service closing control connection.
225=Data connection open; no transfer in progress.
226=Closing data connection. Requested file action successful.
226.WithFilename=Closing data connection. Requested file action successful. Filename={0}.
227=Entering Passive Mode {0}.
229=Entering Extended Passive Mode (|||{0}|)
230=User logged in, proceed.
250=Requested file action okay, completed.
257={0} created.
331=User name okay, need password.
332=Need account for login.
350=Requested file action pending further information.
421=Service not available, closing control connection.
# This may be a reply to any command if the service knows it must shut down.
425=Can't open data connection.
426=Connection closed; transfer aborted.
450=Requested file action not taken.
# File unavailable (e.g., file busy).
451=Requested action aborted: local error in processing.
452=Requested action not taken.
# Insufficient storage space in system.
500=Syntax error, command unrecognized.
# This may include errors such as command line too long.
501=Syntax error in parameters or arguments.
502=Command not implemented: {0}.
503=Bad sequence of commands.
504=Command not implemented for that parameter.
530=Not logged in.
532=Need account for storing files.
550=File not found or not accessible: {0}.
# File unavailable (e.g., file not found, no access).
551=Requested action aborted: page type unknown.
552=Requested file action aborted.
# Exceeded storage allocation (for current directory or dataset).
553=Requested action not taken for {0}
# File name not allowed.
#-------------------------------------------------------------------------------
# FTP Command-Specific Reply Messages
#-------------------------------------------------------------------------------
abor=ABOR completed.
acct=ACCT completed for {0}.
allo=ALLO completed.
appe=Created or appended to file {0}.
cdup=CDUP completed. New directory is {0}.
cwd=CWD completed. New directory is {0}.
dele="{0}" deleted.
eprt=EPRT completed.
epsv=Entering Extended Passive Mode (|||{0}|)
help={0}.
help.noHelpTextDefined=No help text has been defined for [{0}]
mkd="{0}" created.
mode=MODE completed.
noop=NOOP completed.
pass=User logged in, proceed.
pass.needAccount=Need account for login.
pass.loginFailed=Not logged in.
pasv=({0})
port=PORT completed.
pwd="{0}" is current directory.
quit=Service closing control connection.
rein=REIN completed.
rest=REST completed.
rmd="{0}" removed.
rnfr=Requested file action pending further information.
rnto=Rename from {0} to {1} completed.
site=SITE completed.
size={0}
smnt=SMNT completed.
stat={0}.
stou=Created file {0}.
stor=Created file {0}.
stru=STRU completed.
syst="{0}"
type=TYPE completed.
user.loggedIn=User logged in, proceed.
user.needPassword=User name okay, need password.
#-------------------------------------------------------------------------------
# FileSystem Messages
#-------------------------------------------------------------------------------
filesystem.alreadyExists=The path [{0}] already exists.
filesystem.parentDirectoryDoesNotExist=The parent directory [{0}] does not exist.
filesystem.doesNotExist=[{0}] does not exist.
filesystem.isDirectory=[{0}] is a directory.
filesystem.isFile=[{0}] is a file.
filesystem.isNotADirectory=[{0}] is not a directory or does not exist.
filesystem.isNotAFile=[{0}] is not a file or does not exist.
filesystem.cannotRead=The current user does not have read permission for [{0}].
filesystem.cannotWrite=The current user does not have write permission for [{0}].
filesystem.cannotExecute=The current user does not have execute permission for [{0}].
filesystem.directoryIsNotEmpty=The [{0}] directory is not empty.
filesystem.renameFailed=The rename to [{0}] has failed.
filesystem.pathIsNotValid=The path [{0}] is not valid.
filesystem.currentDirectoryNotSet=The current directory has not been set.
#-------------------------------------------------------------------------------
# Other Common Messages
#-------------------------------------------------------------------------------
login.userAccountNotValid=UserAccount missing or invalid for user [{0}]
login.homeDirectoryNotValid=The homeDirectory configured for user [{0}] is not a valid directory: [{1}]
internalError=Internal error: {0} {1}

@ -7,4 +7,13 @@ module org.xbib.files.ftp.mock.test {
requires org.xbib.files.ftp;
exports org.xbib.files.ftp.mock.test;
opens org.xbib.files.ftp.mock.test to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.core.command to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.core.server to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.core.session to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.core.socket to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.core.util to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.example to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.stub to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.stub.command to org.junit.platform.commons;
opens org.xbib.files.ftp.mock.test.stub.example to org.junit.platform.commons;
}

@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.xbib.files.ftp.mock.core.server.AbstractFtpServer;
import org.xbib.files.ftp.mock.test.AbstractTestCase;
import org.xbib.files.ftp.mock.test.PortTestUtil;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTPClient;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**

@ -43,9 +43,9 @@ import org.xbib.files.ftp.mock.test.PortTestUtil;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.xbib.io.ftp.client.FTP;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.io.ftp.client.FTPFile;
import org.xbib.files.ftp.FTP;
import org.xbib.files.ftp.FTPClient;
import org.xbib.files.ftp.FTPFile;
/**
* Tests for StubFtpServer using the Apache Jakarta Commons Net FTP client.

@ -62,7 +62,7 @@ class StubFtpServerTest extends AbstractFtpServerTestCase {
@Test
void testSetReplyTextBaseName() {
stubFtpServer.setReplyTextBaseName("SampleReplyText");
stubFtpServer.setReplyTextBaseName("org.xbib.files.ftp.mock.test.SampleReplyText");
CwdCommandHandler commandHandler = new CwdCommandHandler();
// The resource bundle is passed along to new CommandHandlers (if they don't already have one)

@ -29,7 +29,7 @@ import org.xbib.files.ftp.mock.stub.command.AbstractStubCommandHandler;
import org.xbib.files.ftp.mock.test.AbstractTestCase;
import org.xbib.files.ftp.mock.test.IntegrationTest;
import org.xbib.files.ftp.mock.test.PortTestUtil;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTPClient;
/**
* StubFtpServer tests for multiple FTP clients using the Apache Jakarta Commons Net FTP client.

@ -20,6 +20,7 @@ import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.xbib.files.ftp.mock.core.command.Command;
import org.xbib.files.ftp.mock.core.command.CommandNames;
@ -42,16 +43,13 @@ class FileRetrCommandHandlerTest extends AbstractCommandHandlerTestCase {
private FileRetrCommandHandler commandHandler;
@Test
void testConstructor_String_Null() {
assertThrows(AssertFailedException.class, () -> new FileRetrCommandHandler(null));
}
@Test
void testSetFile_Null() {
assertThrows(AssertFailedException.class, () -> commandHandler.setFile(null));
@BeforeEach
void setUp() throws Exception {
commandHandler = new FileRetrCommandHandler(null, getClass());
commandHandler.setReplyTextBundle(replyTextBundle);
}
@Disabled("quirks with getResourceAsStream")
@Test
void testHandleCommand() throws Exception {
final byte[] BUFFER = new byte[FileRetrCommandHandler.BUFFER_SIZE];
@ -84,12 +82,6 @@ class FileRetrCommandHandlerTest extends AbstractCommandHandlerTestCase {
assertThrows(AssertFailedException.class, () -> commandHandler.handleCommand(new Command(CommandNames.RETR, EMPTY), session));
}
@BeforeEach
void setUp() throws Exception {
commandHandler = new FileRetrCommandHandler();
commandHandler.setReplyTextBundle(replyTextBundle);
}
// /**
// * Create a sample binary file; 5 buffers full plus 3 extra bytes
// */

@ -17,7 +17,7 @@ package org.xbib.files.ftp.mock.test.stub.example;
import java.io.IOException;
import java.net.SocketException;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTPClient;
/**
* Simple FTP client code example.

@ -17,7 +17,7 @@ package org.xbib.files.ftp.mock.test.stub.example;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.xbib.io.ftp.client.FTPClient;
import org.xbib.files.ftp.FTPClient;
/**
* Simple FTP client code example.

@ -0,0 +1,17 @@
# Copyright 2007 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Test-specific mapping of reply code -> reply text
# Tests are dependent on one or more values within this file
110=Testing123

@ -0,0 +1 @@


@ -1,5 +1,5 @@
module org.xbib.files.ftp {
exports org.xbib.io.ftp.client;
exports org.xbib.io.ftp.client.parser;
exports org.xbib.files.ftp;
exports org.xbib.files.ftp.parser;
requires java.logging;
}

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.UnsupportedEncodingException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.BufferedReader;
import java.io.IOException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
/**
* This interface adds the aspect of configurability by means of

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.util.EventListener;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.util.EventObject;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.util.EventListener;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.net.DatagramSocket;
import java.net.InetAddress;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.net.DatagramSocket;
import java.net.InetAddress;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.net.DatagramSocket;
import java.net.InetAddress;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import javax.net.SocketFactory;
import java.io.IOException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.BufferedReader;
import java.io.BufferedWriter;

@ -1,9 +1,9 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import org.xbib.io.ftp.client.parser.DefaultFTPFileEntryParserFactory;
import org.xbib.io.ftp.client.parser.FTPFileEntryParserFactory;
import org.xbib.io.ftp.client.parser.MLSxEntryParser;
import org.xbib.io.ftp.client.parser.ParserInitializationException;
import org.xbib.files.ftp.parser.DefaultFTPFileEntryParserFactory;
import org.xbib.files.ftp.parser.FTPFileEntryParserFactory;
import org.xbib.files.ftp.parser.MLSxEntryParser;
import org.xbib.files.ftp.parser.ParserInitializationException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@ -2640,7 +2640,7 @@ public class FTPClient extends FTP implements Configurable {
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply
* from the server.
* @throws org.xbib.io.ftp.client.parser.ParserInitializationException Thrown if the parserKey parameter cannot be
* @throws org.xbib.files.ftp.parser.ParserInitializationException Thrown if the parserKey parameter cannot be
* resolved by the selected parser factory.
* In the DefaultFTPEntryParserFactory, this will
* happen when parserKey is neither
@ -2689,7 +2689,7 @@ public class FTPClient extends FTP implements Configurable {
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply
* from the server.
* @throws org.xbib.io.ftp.client.parser.ParserInitializationException Thrown if the parserKey parameter cannot be
* @throws org.xbib.files.ftp.parser.ParserInitializationException Thrown if the parserKey parameter cannot be
* resolved by the selected parser factory.
* In the DefaultFTPEntryParserFactory, this will
* happen when parserKey is neither
@ -2748,7 +2748,7 @@ public class FTPClient extends FTP implements Configurable {
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply
* from the server.
* @throws org.xbib.io.ftp.client.parser.ParserInitializationException Thrown if the parserKey parameter cannot be
* @throws org.xbib.files.ftp.parser.ParserInitializationException Thrown if the parserKey parameter cannot be
* resolved by the selected parser factory.
* In the DefaultFTPEntryParserFactory, this will
* happen when parserKey is neither
@ -2834,7 +2834,7 @@ public class FTPClient extends FTP implements Configurable {
* as an IOException or independently as itself.
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
* @throws org.xbib.io.ftp.client.parser.ParserInitializationException Thrown if the autodetect mechanism cannot
* @throws org.xbib.files.ftp.parser.ParserInitializationException Thrown if the autodetect mechanism cannot
* resolve the type of system we are connected with.
* @see FTPListParseEngine
*/
@ -2884,7 +2884,7 @@ public class FTPClient extends FTP implements Configurable {
* as an IOException or independently as itself.
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
* @throws org.xbib.io.ftp.client.parser.ParserInitializationException Thrown if the autodetect mechanism cannot
* @throws org.xbib.files.ftp.parser.ParserInitializationException Thrown if the autodetect mechanism cannot
* resolve the type of system we are connected with.
* @see FTPListParseEngine
*/

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.text.DateFormatSymbols;
import java.util.Collection;
@ -114,8 +114,8 @@ import java.util.TreeMap;
*
* @see Configurable
* @see FTPClient
* @see org.xbib.io.ftp.client.parser.FTPTimestampParserImpl#configure(FTPClientConfig)
* @see org.xbib.io.ftp.client.parser.ConfigurableFTPFileEntryParserImpl
* @see org.xbib.files.ftp.parser.FTPTimestampParserImpl#configure(FTPClientConfig)
* @see org.xbib.files.ftp.parser.ConfigurableFTPFileEntryParserImpl
*/
public class FTPClientConfig {

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.Serializable;
import java.time.ZonedDateTime;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.BufferedReader;
import java.io.IOException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.BufferedReader;
import java.io.IOException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
/**
* Perform filtering on FTPFile entries.

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.util.Objects;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
import java.io.BufferedReader;
import java.io.IOException;

@ -1,4 +1,4 @@
package org.xbib.io.ftp.client;
package org.xbib.files.ftp;
/**
* FTPReply stores a set of constants for FTP reply codes. To interpret

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save