Browse Source

Fix HdfsStorageOperatorTest NPE (#16178)

dev
Wenjun Ruan 6 months ago committed by GitHub
parent
commit
6644abd5f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/test/java/org/apache/dolphinscheduler/plugin/storage/hdfs/LocalStorageOperatorTest.java

8
dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/test/java/org/apache/dolphinscheduler/plugin/storage/hdfs/LocalStorageOperatorTest.java

@ -27,9 +27,6 @@ import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator; import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.nio.file.FileAlreadyExistsException; import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -45,8 +42,8 @@ class LocalStorageOperatorTest {
private StorageOperator storageOperator; private StorageOperator storageOperator;
private static final String resourceBaseDir = StringUtils private static final String resourceBaseDir =
.substringBeforeLast(FileUtils.getClassPathAbsolutePath(LocalStorageOperatorTest.class), File.separator); Paths.get(LocalStorageOperatorTest.class.getResource("/").getFile(), "localStorage").toString();
private static final String tenantCode = "default"; private static final String tenantCode = "default";
private static final String baseDir = private static final String baseDir =
Paths.get(resourceBaseDir, tenantCode, Constants.RESOURCE_TYPE_FILE).toString(); Paths.get(resourceBaseDir, tenantCode, Constants.RESOURCE_TYPE_FILE).toString();
@ -54,6 +51,7 @@ class LocalStorageOperatorTest {
@SneakyThrows @SneakyThrows
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Files.createDirectories(Paths.get(resourceBaseDir));
System.setProperty(Constants.RESOURCE_UPLOAD_PATH, resourceBaseDir); System.setProperty(Constants.RESOURCE_UPLOAD_PATH, resourceBaseDir);
LocalStorageOperatorFactory localStorageOperatorFactory = new LocalStorageOperatorFactory(); LocalStorageOperatorFactory localStorageOperatorFactory = new LocalStorageOperatorFactory();

Loading…
Cancel
Save