forked from OpenLiberty/liberty-tools-intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test to support multiple projects
- Loading branch information
1 parent
75d3bf7
commit bc79157
Showing
10 changed files
with
310 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
src/test/java/io/openliberty/tools/intellij/it/MavenMPMultipleProjectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 IBM Corporation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.tools.intellij.it; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
/** | ||
* Tests Liberty Tools actions using a single module MicroProfile Gradle project with space in directory and name. | ||
*/ | ||
public class MavenMPMultipleProjectTest extends SingleModMPProjectTestCommon { | ||
|
||
/** | ||
* Single module Microprofile project name. | ||
*/ | ||
private static final String SM_MP_PROJECT_NAME = "singleModMavenMP"; | ||
|
||
private static final String MAVEN_MULTIPLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "multiple-project", "singleModMavenMP").toAbsolutePath().toString(); | ||
|
||
private static final String MULTIPLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "multiple-project").toAbsolutePath().toString(); | ||
private static final String MULTIPLE_PROJECTS_PATH_PARENT = Paths.get("src", "test", "resources", "projects").toAbsolutePath().toString(); | ||
|
||
private static final String GRADLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "gradle", "singleModGradleMP").toAbsolutePath().toString(); | ||
|
||
private static final String MAVEN_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "maven", "singleModMavenMP").toAbsolutePath().toString(); | ||
|
||
private static final String GRADLE_MULTIPLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "multiple-project", "singleModGradleMP").toAbsolutePath().toString(); | ||
|
||
/** | ||
* The paths to the integration test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. | ||
*/ | ||
private final Path pathToITReport34 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "failsafe-report.html"); | ||
private final Path pathToITReport35 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "failsafe.html"); | ||
|
||
/** | ||
* The paths to the unit test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. | ||
*/ | ||
private final Path pathToUTReport34 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); | ||
private final Path pathToUTReport35 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "surefire.html"); | ||
|
||
|
||
|
||
/** | ||
* Prepares the environment for test execution. | ||
*/ | ||
@BeforeAll | ||
public static void setup() { | ||
try { | ||
File theDir = new File(MULTIPLE_PROJECTS_PATH); | ||
System.out.println("---------------"+theDir); | ||
if (theDir.exists()){ | ||
TestUtils.deleteDirectory(theDir); | ||
System.out.println("---------------Inside If loop--------------"); | ||
} | ||
theDir.mkdirs(); | ||
System.out.println("---------------"+theDir); | ||
|
||
// Copy the directory to allow renaming. | ||
TestUtils.copyDirectory(GRADLE_PROJECTS_PATH, GRADLE_MULTIPLE_PROJECTS_PATH); | ||
TestUtils.copyDirectory(MAVEN_PROJECTS_PATH, MAVEN_MULTIPLE_PROJECTS_PATH); | ||
|
||
// Prepare the environment with the new project path and name | ||
prepareEnv(MULTIPLE_PROJECTS_PATH_PARENT, SM_MP_PROJECT_NAME, true); | ||
|
||
} catch (IOException e) { | ||
System.err.println("Setup failed: " + e.getMessage()); | ||
e.printStackTrace(); | ||
Assertions.fail("Test setup failed due to an IOException: " + e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Cleanup includes deleting the created project path. | ||
*/ | ||
@AfterAll | ||
public static void cleanup() { | ||
try { | ||
closeProjectView(); | ||
} finally { | ||
deleteDirectoryIfExists(MULTIPLE_PROJECTS_PATH); | ||
} | ||
} | ||
|
||
MavenMPMultipleProjectTest() { | ||
// set the new locations for the test, not the original locations | ||
setProjectsDirPath(MULTIPLE_PROJECTS_PATH); | ||
setTestReportPath(Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "build", "reports", "tests", "test", "index.html")); | ||
setSmMPProjectName(SM_MP_PROJECT_NAME); | ||
setBuildCategory(BuildType.MAVEN_TYPE); | ||
setSmMpProjPort(9080); | ||
setSmMpProjResURI("api/resource"); | ||
setSmMPProjOutput("Hello! Welcome to Open Liberty"); | ||
setWLPInstallPath(Paths.get("target", "liberty").toString()); | ||
setBuildFileName("pom.xml"); | ||
setBuildFileOpenCommand("Liberty: View pom.xml"); | ||
setStartParams("-DhotTests=true"); | ||
setStartParamsDebugPort("-DdebugPort=9876"); | ||
setProjectTypeIsMultiple(true); | ||
} | ||
|
||
/** | ||
* Deletes test reports. | ||
*/ | ||
@Override | ||
public void deleteTestReports() { | ||
boolean itReportDeleted = TestUtils.deleteFile(pathToITReport34); | ||
Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport34 + " was not be deleted."); | ||
itReportDeleted = TestUtils.deleteFile(pathToITReport35); | ||
Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport35 + " was not be deleted."); | ||
|
||
boolean utReportDeleted = TestUtils.deleteFile(pathToUTReport34); | ||
Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport34 + " was not be deleted."); | ||
utReportDeleted = TestUtils.deleteFile(pathToUTReport35); | ||
Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport35 + " was not be deleted."); | ||
} | ||
|
||
/** | ||
* Validates that test reports were generated. | ||
*/ | ||
@Override | ||
public void validateTestReportsExist() { | ||
TestUtils.validateTestReportExists(pathToITReport34, pathToITReport35); | ||
TestUtils.validateTestReportExists(pathToUTReport34, pathToUTReport35); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.