Skip to content

Commit

Permalink
Merge pull request #744 from spyrkob/issue_710
Browse files Browse the repository at this point in the history
[#704] Use jackson-dataformat-yaml WildFly module in the feature pack
  • Loading branch information
spyrkob authored Aug 2, 2024
2 parents 4db5940 + 19b62ff commit e963879
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 2,294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<artifact name="${org.jboss.galleon:galleon-common-api}"/>
<artifact name="${org.jboss.galleon:galleon-maven-universe}"/>
<artifact name="${info.picocli:picocli}"/>
<artifact name="${com.fasterxml.jackson.dataformat:jackson-dataformat-yaml}"/>
<artifact name="${com.networknt:json-schema-validator}"/>
<artifact name="${org.apache.commons:commons-text}"/>
<artifact name="${org.apache.maven:maven-artifact}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<artifact name="${com.fasterxml.jackson.core:jackson-core}"/>
<artifact name="${com.fasterxml.jackson.core:jackson-annotations}"/>
<artifact name="${com.fasterxml.jackson.core:jackson-databind}"/>
<artifact name="${com.fasterxml.jackson.dataformat:jackson-dataformat-yaml}"/>
<artifact name="${org.yaml:snakeyaml}"/>
<artifact name="${org.jboss:staxmapper}"/>
<artifact name="${org.slf4j:slf4j-api}"/>
Expand Down
11 changes: 0 additions & 11 deletions dist/wildfly-galleon-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,6 @@
</exclusions>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<module name="com.fasterxml.jackson.core.jackson-core" export="true"/>
<module name="com.fasterxml.jackson.core.jackson-annotations" export="true"/>
<module name="com.fasterxml.jackson.core.jackson-databind" export="true"/>
<module name="com.fasterxml.jackson.dataformat.jackson-dataformat-yaml" export="true"/>
<module name="javax.inject.api" export="true"/>
<module name="org.jboss.logging" export="true"/>
<module name="org.jboss.logmanager" export="true" services="export"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.wildfly.channel.Channel;
import org.wildfly.channel.ChannelManifest;
import org.wildfly.channel.ChannelManifestCoordinate;
import org.wildfly.channel.ChannelManifestMapper;
import org.wildfly.channel.Repository;
import org.wildfly.channel.Stream;
import org.wildfly.prospero.actions.InstallationHistoryAction;
import org.wildfly.prospero.api.SavedState;
import org.wildfly.prospero.cli.CliMessages;
import org.wildfly.prospero.cli.ReturnCodes;
import org.wildfly.prospero.cli.commands.CliConstants;
import org.wildfly.prospero.it.ExecutionUtils;
import org.wildfly.prospero.it.utils.TestProperties;
import org.wildfly.prospero.test.MetadataTestUtils;

import java.io.File;
Expand All @@ -46,6 +50,7 @@
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -61,6 +66,7 @@ public class FeaturesAddTest {
private static final String DS_ARTIFACT_ID = "postgresql";
protected static final String DS_VERSION = "42.7.3";
protected static final Path MODULE_PATH = Path.of("modules", DS_GROUP_ID.replace('.', '/'), "jdbc");
private Path wfChannelsFile;


@Before
Expand All @@ -74,6 +80,16 @@ public void setUp() throws IOException {
properties.getProperty("prospero.test.datasources-feature-pack.artifactId"));

profileName = properties.getProperty("prospero.test.server.profile");

wfChannelsFile = tempDir.newFile("wf-channel.yaml").toPath();
final List<Repository> repositories = MetadataTestUtils.defaultRemoteRepositories().stream()
.map(r->new Repository(r.getId(), r.getUrl())).collect(Collectors.toList());

final Channel wfChannel = new Channel("test-channel", "", null, repositories,
new ChannelManifestCoordinate(TestProperties.WF_CHANNEL_GROUP_ID, TestProperties.WF_CHANNEL_ARTIFACT_ID,
TestProperties.WF_CHANNEL_VERSION),
null, Channel.NoStreamStrategy.NONE);
MetadataTestUtils.writeChannels(wfChannelsFile, List.of(wfChannel));
}

@Test
Expand Down Expand Up @@ -164,9 +180,9 @@ public void datasourcesFeaturePackRequiresLayers() throws Exception {
public void installWildflyGalleonPackOverWildflyEEGalleonPack_ReplacesWildflyGalleonPack() throws Exception {
Assume.assumeTrue(profileName.equals("wildfly"));
System.out.println("Installing wildfly EE");
final Path channelsFile = MetadataTestUtils.prepareChannel("manifests/wildfly-30.0.0.Final-manifest.yaml");

ExecutionUtils.prosperoExecution(CliConstants.Commands.INSTALL,
CliConstants.CHANNELS, channelsFile.toString(),
CliConstants.CHANNELS, wfChannelsFile.toString(),
CliConstants.FPL, "org.wildfly:wildfly-ee-galleon-pack",
CliConstants.DIR, targetDir.getAbsolutePath())
.withTimeLimit(10, TimeUnit.MINUTES)
Expand Down Expand Up @@ -210,7 +226,6 @@ public void installWildflyGalleonPackOverWildflyEEGalleonPack_ReplacesWildflyGal

private void installWildfly() throws Exception {
System.out.println("Installing wildfly");
final Path channelsFile = MetadataTestUtils.prepareChannel("manifests/wildfly-30.0.0.Final-manifest.yaml");
final List<String> args = new ArrayList<>(List.of(
CliConstants.Commands.INSTALL,
CliConstants.ACCEPT_AGREEMENTS,
Expand All @@ -219,7 +234,7 @@ private void installWildfly() throws Exception {

if (profileName.equals("wildfly")) {
args.add(CliConstants.CHANNELS);
args.add(channelsFile.toString());
args.add(wfChannelsFile.toString());
}
ExecutionUtils.prosperoExecution(args.toArray(new String[]{}))
.withTimeLimit(10, TimeUnit.MINUTES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@

package org.wildfly.prospero.it.featurepacks;

import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.deployment.DeployRequest;
import org.eclipse.aether.repository.RemoteRepository;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand All @@ -35,12 +29,11 @@
import org.wildfly.channel.ChannelManifestMapper;
import org.wildfly.channel.ChannelMapper;
import org.wildfly.channel.Stream;
import org.wildfly.prospero.api.MavenOptions;
import org.wildfly.prospero.cli.DistributionInfo;
import org.wildfly.prospero.cli.ReturnCodes;
import org.wildfly.prospero.cli.commands.CliConstants;
import org.wildfly.prospero.it.ExecutionUtils;
import org.wildfly.prospero.wfchannel.MavenSessionManager;
import org.wildfly.prospero.it.utils.TestProperties;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
Expand All @@ -56,7 +49,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
Expand All @@ -66,33 +58,16 @@
public class WildflyFpTest {

protected static final String PROSPERO_MANIFEST_LOCATION = "manifests/prospero-manifest.yaml";
private static String testChannelGroupId;
private static String testChannelArtifactId;
private static String testRepoUrls;
@Rule
public TemporaryFolder tempDir = new TemporaryFolder();

private Path targetDir;

private Path localRepo;

private XPath xpath = XPathFactory.newInstance().newXPath();

@BeforeClass
public static void setUpClass() throws Exception {
// read the settings from pom properties
final Properties properties = new Properties();
properties.load(WildflyFpTest.class.getClassLoader().getResourceAsStream("properties-from-pom.properties"));
testChannelGroupId = properties.getProperty("prospero.test.base.channel.groupId");
testChannelArtifactId = properties.getProperty("prospero.test.base.channel.artifactId");
testRepoUrls = properties.getProperty("prospero.test.base.repositories");
}

@Before
public void setUp() throws Exception {
targetDir = tempDir.newFolder().toPath();
localRepo = tempDir.newFolder().toPath();
deployWildflyManifest();
}

@Test
Expand Down Expand Up @@ -137,14 +112,13 @@ private void prepareWflyAndProsperoChannels(Path channelsFile) throws IOExceptio

// create channels
Channel.Builder cb1 = new Channel.Builder()
.setManifestCoordinate(new ChannelManifestCoordinate(testChannelGroupId, testChannelArtifactId))
.addRepository("local-repo", localRepo.toUri().toString());
.setManifestCoordinate(new ChannelManifestCoordinate(TestProperties.WF_CHANNEL_GROUP_ID,
TestProperties.WF_CHANNEL_ARTIFACT_ID, TestProperties.WF_CHANNEL_VERSION));
Channel.Builder cb2 = new Channel.Builder()
.setManifestUrl(this.getClass().getClassLoader().getResource(PROSPERO_MANIFEST_LOCATION));

final String[] urls = testRepoUrls.split(",");
for (int i = 0; i < urls.length; i++) {
String url = urls[i];
for (int i = 0; i < TestProperties.TEST_REPO_URLS.size(); i++) {
String url = TestProperties.TEST_REPO_URLS.get(i);
cb1.addRepository("test-repo-" + i, url);
cb2.addRepository("test-repo-" + i, url);
}
Expand All @@ -153,20 +127,6 @@ private void prepareWflyAndProsperoChannels(Path channelsFile) throws IOExceptio
Files.writeString(channelsFile, ChannelMapper.toYaml(cb1.build(), cb2.build()));
}

private void deployWildflyManifest() throws Exception {
final MavenSessionManager mavenSessionManager = new MavenSessionManager(MavenOptions.OFFLINE_NO_CACHE);
final RepositorySystem system = mavenSessionManager.newRepositorySystem();
final DefaultRepositorySystemSession session = mavenSessionManager.newRepositorySystemSession(system);

final File wfManifest = new File(this.getClass().getClassLoader().getResource("manifests/wildfly-30.0.0.Final-manifest.yaml").toURI());

final DeployRequest deployRequest = new DeployRequest();
deployRequest.setRepository(new RemoteRepository.Builder("local-repo", "default", localRepo.toUri().toString()).build());
deployRequest.addArtifact(new DefaultArtifact(testChannelGroupId, testChannelArtifactId,
"manifest", "yaml", "1.0.0.Final", null, wfManifest));
system.deploy(session, deployRequest);
}

private Document readDocument(File xmlFile) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2022 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wildfly.prospero.it.utils;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
* Gives access to build properties defined in pom
*/
public class TestProperties {
static {
try {
final Properties properties = new Properties();
properties.load(TestProperties.class.getClassLoader().getResourceAsStream("properties-from-pom.properties"));
WF_CHANNEL_GROUP_ID = properties.getProperty("prospero.test.base.channel.groupId");
WF_CHANNEL_ARTIFACT_ID = properties.getProperty("prospero.test.base.channel.artifactId");
WF_CHANNEL_VERSION = properties.getProperty("prospero.test.base.channel.version");
final String testRepoUrls = properties.getProperty("prospero.test.base.repositories");
TEST_REPO_URLS = Arrays.asList(testRepoUrls.split(","));
} catch (IOException e) {
throw new RuntimeException("Unable to read properties file", e);
}
}

public static final String WF_CHANNEL_GROUP_ID;
public static final String WF_CHANNEL_ARTIFACT_ID;
public static final String WF_CHANNEL_VERSION;
public static final List<String> TEST_REPO_URLS;
}
Loading

0 comments on commit e963879

Please sign in to comment.