Skip to content

Commit 61080da

Browse files
1311: fixed tests
1 parent 1b9c9ed commit 61080da

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

fluss-filesystems/fluss-fs-abfs/src/test/java/org/apache/fluss/fs/abfs/AbfsFileSystemBehaviorITCase.java

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,46 +42,33 @@ class AbfsFileSystemBehaviorITCase extends FileSystemBehaviorTestSuite {
4242
public static final String ABFS_FS_PATH = "abfs://[email protected]/test";
4343

4444
private static MockAuthServer mockGSServer;
45-
private static FileSystem fileSystem;
4645

4746
@BeforeAll
48-
static void setup() throws IOException {
47+
static void setup() {
4948
mockGSServer = MockAuthServer.create();
50-
fileSystem = createFileSystem();
49+
final Configuration configuration = new Configuration();
50+
configuration.setString(CONFIG_PREFIX + ".oauth2.client.id", CLIENT_ID);
51+
configuration.setString(CONFIG_PREFIX + ".oauth2.client.secret", CLIENT_SECRET);
52+
configuration.setString(CONFIG_PREFIX + ".oauth2.client.endpoint", ENDPOINT_KEY);
53+
configuration.setString(CONFIG_PREFIX + ".key", AZURE_ACCOUNT_KEY);
54+
FileSystem.initialize(configuration, null);
5155
}
5256

53-
void testPathAndScheme() throws Exception {}
54-
5557
@Override
56-
protected FileSystem getFileSystem() {
57-
return fileSystem;
58+
protected FileSystem getFileSystem() throws IOException {
59+
return getBasePath().getFileSystem();
5860
}
5961

6062
@Override
61-
protected FsPath getBasePath() {
62-
return new FsPath(ABFS_FS_PATH);
63-
}
64-
65-
private static FileSystem createFileSystem() throws IOException {
66-
AbfsFileSystemPlugin abfsFileSystemPlugin = new AbfsFileSystemPlugin();
67-
Configuration configuration = new Configuration();
68-
configuration.setString(CONFIG_PREFIX + ".oauth2.id", CLIENT_ID);
69-
configuration.setString(CONFIG_PREFIX + ".oauth2.secret", CLIENT_SECRET);
70-
configuration.setString(CONFIG_PREFIX + ".oauth2.endpoint", ENDPOINT_KEY);
71-
configuration.setString(CONFIG_PREFIX + ".key", AZURE_ACCOUNT_KEY);
72-
73-
FileSystem fileSystem =
74-
abfsFileSystemPlugin.create(
75-
URI.create("abfs://[email protected]/test"), configuration);
76-
77-
applyMockStorage(fileSystem);
78-
79-
return fileSystem;
63+
protected FsPath getBasePath() throws IOException {
64+
FsPath fsPath = new FsPath(ABFS_FS_PATH);
65+
applyMockStorage(fsPath.getFileSystem());
66+
return fsPath;
8067
}
8168

8269
private static void applyMockStorage(FileSystem fileSystem) throws IOException {
8370
try {
84-
MemoryFileSystem memoryFileSystem = new MemoryFileSystem();
71+
MemoryFileSystem memoryFileSystem = new MemoryFileSystem(URI.create(ABFS_FS_PATH));
8572
FieldUtils.writeField(fileSystem, "fs", memoryFileSystem, true);
8673
} catch (IllegalAccessException e) {
8774
throw new RuntimeException(e);

fluss-filesystems/fluss-fs-abfs/src/test/java/org/apache/fluss/fs/abfs/MemoryFileSystem.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,23 @@
4141
/** Util file system abstraction. */
4242
public class MemoryFileSystem extends FileSystem {
4343

44+
private final URI uri;
4445
private final Map<Path, byte[]> files = MapUtils.newConcurrentHashMap();
4546
private final Set<Path> directories =
4647
Collections.newSetFromMap(MapUtils.newConcurrentHashMap());
4748

49+
public MemoryFileSystem(URI uri) {
50+
this.uri = uri;
51+
}
52+
4853
@Override
4954
public boolean exists(Path f) throws IOException {
5055
return files.containsKey(f) || directories.contains(f);
5156
}
5257

5358
@Override
5459
public URI getUri() {
55-
throw new UnsupportedOperationException();
60+
return uri;
5661
}
5762

5863
@Override

0 commit comments

Comments
 (0)