use of org.mule.maven.client.api.model.MavenConfiguration in project mule by mulesoft.
the class MavenConfigTestCase method loadFromFileWithOverrideFromSystemPropertyOfSimpleValue.
@Description("Loads the configuration from mule-config.json and overrides the maven repository location using a system property")
@Test
public void loadFromFileWithOverrideFromSystemPropertyOfSimpleValue() throws Exception {
String repoLocation = temporaryFolder.getRoot().getAbsolutePath();
testWithSystemProperty("muleRuntimeConfig.maven.repositoryLocation", repoLocation, () -> {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
String configuredRepoLocation = mavenConfig.getLocalMavenRepositoryLocation().getAbsolutePath();
assertThat(configuredRepoLocation, is(repoLocation));
});
}
use of org.mule.maven.client.api.model.MavenConfiguration in project mule by mulesoft.
the class MavenConfigTestCase method loadFromFileWithAdditionalRepoFromSystemPropertyInOrder.
@Description("Loads the configuration from mule-config.json and adds an additional maven repository using system properties with order for remote repositories")
@Test
public void loadFromFileWithAdditionalRepoFromSystemPropertyInOrder() throws Exception {
String additionalRepositoryUrl = "http://localhost/host";
Map<String, String> systemProperties = new HashMap<>();
systemProperties.put("muleRuntimeConfig.maven.repositories.firstCustomRepo.url", additionalRepositoryUrl);
systemProperties.put("muleRuntimeConfig.maven.repositories.firstCustomRepo.position", "1");
systemProperties.put("muleRuntimeConfig.maven.repositories.secondCustomRepo.url", additionalRepositoryUrl);
systemProperties.put("muleRuntimeConfig.maven.repositories.secondCustomRepo.position", "2");
testWithSystemProperties(systemProperties, () -> {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
List<RemoteRepository> mavenRemoteRepositories = mavenConfig.getMavenRemoteRepositories();
assertThat(mavenRemoteRepositories, hasSize(3));
assertThat(mavenRemoteRepositories.get(0).getId(), is("firstCustomRepo"));
assertThat(mavenRemoteRepositories.get(0).getUrl(), is(new URL(additionalRepositoryUrl)));
assertThat(mavenRemoteRepositories.get(1).getId(), is("secondCustomRepo"));
assertThat(mavenRemoteRepositories.get(1).getUrl(), is(new URL(additionalRepositoryUrl)));
assertThat(mavenRemoteRepositories.get(2).getId(), is("mavenCentral"));
assertThat(mavenRemoteRepositories.get(2).getUrl(), is(new URL(MAVEN_CENTRAL_URL)));
});
}
use of org.mule.maven.client.api.model.MavenConfiguration in project mule by mulesoft.
the class MavenConfigTestCase method loadFromFileWithOverrideFromSystemPropertyOfComplexValue.
@Description("Loads the configuration from mule-config.json and overrides a single attribute of a complex value")
@Test
public void loadFromFileWithOverrideFromSystemPropertyOfComplexValue() throws Exception {
String mavenCentralOverriddenUrl = "http://localhost/host";
testWithSystemProperty("muleRuntimeConfig.maven.repositories.mavenCentral.url", mavenCentralOverriddenUrl, () -> {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
List<RemoteRepository> mavenRemoteRepositories = mavenConfig.getMavenRemoteRepositories();
assertThat(mavenRemoteRepositories, hasSize(1));
assertThat(mavenRemoteRepositories.get(0).getId(), is("mavenCentral"));
assertThat(mavenRemoteRepositories.get(0).getUrl(), is(new URL(mavenCentralOverriddenUrl)));
});
}
use of org.mule.maven.client.api.model.MavenConfiguration in project mule by mulesoft.
the class MavenConfigTestCase method loadFromFileWithAdditionalRepoFromSystemPropertyInOrderSamePosition.
@Description("Loads the configuration from mule-config.json and adds an additional maven repository using system properties with order for remote repositories with same position")
@Test
public void loadFromFileWithAdditionalRepoFromSystemPropertyInOrderSamePosition() throws Exception {
String additionalRepositoryUrl = "http://localhost/host";
Map<String, String> systemProperties = new HashMap<>();
systemProperties.put("muleRuntimeConfig.maven.repositories.firstCustomRepo.url", additionalRepositoryUrl);
systemProperties.put("muleRuntimeConfig.maven.repositories.firstCustomRepo.position", "1");
systemProperties.put("muleRuntimeConfig.maven.repositories.secondCustomRepo.url", additionalRepositoryUrl);
systemProperties.put("muleRuntimeConfig.maven.repositories.secondCustomRepo.position", "1");
testWithSystemProperties(systemProperties, () -> {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
List<RemoteRepository> mavenRemoteRepositories = mavenConfig.getMavenRemoteRepositories();
assertThat(mavenRemoteRepositories, hasSize(3));
assertThat(mavenRemoteRepositories.get(0).getId(), either(is("firstCustomRepo")).or(is("secondCustomRepo")));
assertThat(mavenRemoteRepositories.get(0).getUrl(), is(new URL(additionalRepositoryUrl)));
assertThat(mavenRemoteRepositories.get(1).getId(), either(is("firstCustomRepo")).or(is("secondCustomRepo")));
assertThat(mavenRemoteRepositories.get(1).getUrl(), is(new URL(additionalRepositoryUrl)));
assertThat(mavenRemoteRepositories.get(2).getId(), is("mavenCentral"));
assertThat(mavenRemoteRepositories.get(2).getUrl(), is(new URL(MAVEN_CENTRAL_URL)));
});
}
use of org.mule.maven.client.api.model.MavenConfiguration in project mule by mulesoft.
the class MavenConfigTestCase method loadSettings.
@Description("Loads the global and user settings from system properties")
@Test
public void loadSettings() throws Exception {
File userSettings = temporaryFolder.newFile();
File globalSettings = temporaryFolder.newFile();
Map<String, String> properties = new HashMap<>();
properties.put("muleRuntimeConfig.maven.userSettingsLocation", userSettings.getAbsolutePath());
properties.put("muleRuntimeConfig.maven.globalSettingsLocation", globalSettings.getAbsolutePath());
testWithSystemProperties(properties, () -> {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
List<RemoteRepository> mavenRemoteRepositories = mavenConfig.getMavenRemoteRepositories();
assertThat(mavenRemoteRepositories, hasSize(1));
assertThat(mavenRemoteRepositories.get(0).getId(), is("mavenCentral"));
assertThat(mavenConfig.getGlobalSettingsLocation().isPresent(), is(true));
assertThat(mavenConfig.getGlobalSettingsLocation().get(), is(globalSettings));
assertThat(mavenConfig.getUserSettingsLocation().isPresent(), is(true));
assertThat(mavenConfig.getUserSettingsLocation().get(), is(userSettings));
});
}
Aggregations