Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate tests to JUnit5 #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
<gridsuite-dependencies.version>34</gridsuite-dependencies.version>

<jcraft.version>0.1.55</jcraft.version>
<fake.sftp.server.version>2.0.1</fake.sftp.server.version>
<fake.sftp.server.version>2.0.0</fake.sftp.server.version>
<mock.ftp.server.version>2.7.1</mock.ftp.server.version>
<mockserver.version>5.10.0</mockserver.version>
<mockserver.version>5.15.0</mockserver.version>
<org.json.version>20200518</org.json.version>
<apache.commons.vfs2.version>2.6.0</apache.commons.vfs2.version>
<commons.net.version>3.7</commons.net.version>
Expand Down Expand Up @@ -110,7 +110,7 @@
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>fake-sftp-server-rule</artifactId>
<artifactId>fake-sftp-server-lambda</artifactId>
<version>${fake.sftp.server.version}</version>
</dependency>
<dependency>
Expand All @@ -120,7 +120,7 @@
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-rule</artifactId>
<artifactId>mockserver-junit-jupiter</artifactId>
<version>${mockserver.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -194,18 +194,18 @@

<!-- Test dependencies -->
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>fake-sftp-server-rule</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-config-test</artifactId>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>fake-sftp-server-lambda</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-config-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -215,7 +215,7 @@
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-rule</artifactId>
<artifactId>mockserver-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ private static void handleZipBoundaryContainer(TransferableFile acquiredFile,
fileName = FilenameUtils.getName(entry.getName());

// Check if it is a boundary file
if (!fileName.equals("") &&
if (!fileName.isEmpty() &&
(fileName.matches(CgmesBoundaryUtils.EQBD_FILE_REGEX) ||
fileName.matches(CgmesBoundaryUtils.TPBD_FILE_REGEX))) {
fileName.matches(CgmesBoundaryUtils.TPBD_FILE_REGEX))) {

byte[] boundaryContent = zis.readAllBytes();

Expand All @@ -97,20 +97,25 @@ private static void handleZipBoundaryContainer(TransferableFile acquiredFile,
}

public static void main(String... args) {
final PlatformConfig platformConfig = PlatformConfig.defaultConfig();
final ModuleConfig moduleConfigAcquisitionServer = platformConfig.getOptionalModuleConfig("acquisition-server").orElseThrow(() -> new PowsyblException("Module acquisition-server not found !!"));
final ModuleConfig moduleConfigCgmesBoundaryServer = platformConfig.getOptionalModuleConfig("cgmes-boundary-server").orElseThrow(() -> new PowsyblException("Module cgmes-boundary-server not found !!"));
run(
moduleConfigCgmesBoundaryServer.getStringProperty("url"),
moduleConfigAcquisitionServer.getStringProperty("username"),
moduleConfigAcquisitionServer.getStringProperty("password"),
moduleConfigAcquisitionServer.getStringProperty("url"),
moduleConfigAcquisitionServer.getStringProperty("cgmes-boundary-directory")
);
}

PlatformConfig platformConfig = PlatformConfig.defaultConfig();

ModuleConfig moduleConfigAcquisitionServer = platformConfig.getOptionalModuleConfig("acquisition-server").orElseThrow(() -> new PowsyblException("Module acquisition-server not found !!"));
ModuleConfig moduleConfigCgmesBoundaryServer = platformConfig.getOptionalModuleConfig("cgmes-boundary-server").orElseThrow(() -> new PowsyblException("Module cgmes-boundary-server not found !!"));

final CgmesBoundaryServiceRequester cgmesBoundaryServiceRequester = new CgmesBoundaryServiceRequester(moduleConfigCgmesBoundaryServer.getStringProperty("url"));
public static void run(String cgmesBoundaryServerUrl, String acquisitionServerUrl, String acquisitionServerUsername, String acquisitionServerPassword,
String boundaryDirectory) {
final CgmesBoundaryServiceRequester cgmesBoundaryServiceRequester = new CgmesBoundaryServiceRequester(cgmesBoundaryServerUrl);

try (BoundaryAcquisitionServer boundaryAcquisitionServer = new BoundaryAcquisitionServer(moduleConfigAcquisitionServer.getStringProperty("url"),
moduleConfigAcquisitionServer.getStringProperty("username"),
moduleConfigAcquisitionServer.getStringProperty("password"))) {
try (BoundaryAcquisitionServer boundaryAcquisitionServer = new BoundaryAcquisitionServer(acquisitionServerUrl, acquisitionServerUsername, acquisitionServerPassword)) {
boundaryAcquisitionServer.open();

String boundaryDirectory = moduleConfigAcquisitionServer.getStringProperty("cgmes-boundary-directory");
Map<String, String> filesToAcquire = boundaryAcquisitionServer.listFiles(boundaryDirectory);
LOGGER.info("{} files found on server", filesToAcquire.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public TransferableFile getFile(String fileName, String fileUrl) throws IOExcept
return new TransferableFile(fileName, file.getContent().getByteArray());
}

@Override
public void close() {
fsManager.close();
}
Expand Down
Loading
Loading