-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #159: devon4j migration improved/fixed * #160: switched from OpenJDK to AdoptOpenJDK * #161: fixed mvn invocation and exit code * #162: propagate exit code * #152: fix if installed software is reused (proper exit code so post installation quirks/enhancements are only once) * #157: reuse local maven repo for integration tests to avoid waste * #159: #157: improved integration test, create archetype and also test migration * #18: archetype catalog should come with most recent archetype, updated and verify via test
- Loading branch information
Showing
16 changed files
with
290 additions
and
66 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
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
107 changes: 107 additions & 0 deletions
107
configurator/src/test/java/com/devonfw/tools/ide/migrator/MigrationsTest.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,107 @@ | ||
package com.devonfw.tools.ide.migrator; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.Test; | ||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Element; | ||
import org.w3c.dom.NodeList; | ||
import org.xml.sax.SAXException; | ||
|
||
import com.devonfw.tools.ide.migrator.file.FileMigration; | ||
import com.devonfw.tools.ide.migrator.file.XmlFileMigration; | ||
import com.devonfw.tools.ide.migrator.version.VersionIdentifier; | ||
import com.devonfw.tools.ide.migrator.xml.MavenPropertyReplacement; | ||
import com.devonfw.tools.ide.migrator.xml.XmlMigration; | ||
|
||
/** | ||
* Test of {@link Migrations}. | ||
*/ | ||
public class MigrationsTest extends Assertions { | ||
|
||
/** | ||
* Test of {@link Migrations#devon4j()}. | ||
* | ||
* @throws Exception on error. | ||
*/ | ||
@Test | ||
public void testMigrations() throws Exception { | ||
|
||
MigrationImpl devon4j = Migrations.devon4j(); | ||
List<VersionIdentifier> oasp4jVersions = Arrays.asList(VersionIdentifier.ofOasp4j("2.6.0"), | ||
VersionIdentifier.ofOasp4j("2.6.1"), VersionIdentifier.ofOasp4j("3.0.0")); | ||
List<VersionIdentifier> versions = new ArrayList<>(oasp4jVersions); | ||
List<String> devon4jVersions = determineDevon4jVersions(); | ||
assertThat(devon4jVersions.size()).isGreaterThan(3); | ||
String latestDevon4jVersion = devon4jVersions.get(devon4jVersions.size() - 1); | ||
Path archetypeCatalog = Paths.get("../settings/src/main/settings/eclipse/archetype-catalog.xml"); | ||
List<String> archetypeCatalogLines = Files.readAllLines(archetypeCatalog, StandardCharsets.UTF_8); | ||
assertThat(archetypeCatalogLines).contains(" <version>" + latestDevon4jVersion + "</version>"); | ||
for (String devon4jVersion : devon4jVersions) { | ||
versions.add(VersionIdentifier.ofDevon4j(devon4jVersion)); | ||
} | ||
MigrationStep step; | ||
VersionIdentifier current = null; | ||
int versionIndexMax = versions.size() - 1; | ||
for (int versionIndex = 0; versionIndex <= versionIndexMax; versionIndex++) { | ||
current = versions.get(versionIndex); | ||
step = devon4j.get(current); | ||
if (versionIndex < versionIndexMax) { | ||
assertThat(step).isNotNull(); | ||
} | ||
if (step != null) { | ||
assertThat(step.getFrom()).isEqualTo(current); | ||
assertThat(step.getTo()).isEqualTo(versions.get(versionIndex + 1)); | ||
List<FileMigration> fileMigrations = ((MigrationStepImpl) step).getFileMigrations(); | ||
assertThat(fileMigrations).isNotEmpty(); | ||
FileMigration versionUpgrade = fileMigrations.get(0); | ||
assertThat(versionUpgrade.getNamePattern()).isSameAs(XmlFileMigration.POM_XML_PATTERN); | ||
assertThat(versionUpgrade).isInstanceOf(XmlFileMigration.class); | ||
List<XmlMigration> versionMigrations = ((XmlFileMigration) versionUpgrade).getMigrations(); | ||
assertThat(versionMigrations).isNotEmpty(); | ||
XmlMigration xmlMigration = versionMigrations.get(0); | ||
assertThat(xmlMigration).isInstanceOf(MavenPropertyReplacement.class); | ||
MavenPropertyReplacement mavenPropertyReplacement = (MavenPropertyReplacement) xmlMigration; | ||
if (step.getFrom().getArtifactId().equals("devon4j")) { | ||
assertThat(mavenPropertyReplacement.getPropertyName()).isEqualTo("devon4j.version"); | ||
} else { | ||
assertThat(mavenPropertyReplacement.getPropertyName()).isEqualTo("oasp4j.version"); | ||
} | ||
assertThat(mavenPropertyReplacement.getNewValue()).isEqualTo(step.getTo().getVersion()); | ||
} | ||
} | ||
} | ||
|
||
private List<String> determineDevon4jVersions() | ||
throws IOException, MalformedURLException, SAXException, ParserConfigurationException { | ||
|
||
List<String> versions = new ArrayList<>(); | ||
String url = "https://repo1.maven.org/maven2/com/devonfw/java/modules/devon4j-basic/maven-metadata.xml"; | ||
InputStream in = new URL(url).openStream(); | ||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); | ||
NodeList versionElementList = doc.getElementsByTagName("version"); | ||
for (int i = 0; i < versionElementList.getLength(); i++) { | ||
Element element = (Element) versionElementList.item(i); | ||
String version = element.getTextContent().trim(); | ||
if (!version.contains("-alpha") && !version.contains("-beta")) { | ||
versions.add(version); | ||
} | ||
} | ||
return versions; | ||
} | ||
|
||
} |
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.