use of org.mule.maven.client.api.model.RemoteRepository in project mule by mulesoft.
the class MavenConfigTestCase method loadFromFileWithAdditionalRepoFromSystemProperty.
@Description("Loads the configuration from mule-config.json and adds an additional maven repository using system properties")
@Test
public void loadFromFileWithAdditionalRepoFromSystemProperty() throws Exception {
String additionalRepositoryUrl = "http://localhost/host";
testWithSystemProperty("muleRuntimeConfig.maven.repositories.customRepo.url", additionalRepositoryUrl, () -> {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
List<RemoteRepository> mavenRemoteRepositories = mavenConfig.getMavenRemoteRepositories();
assertThat(mavenRemoteRepositories, hasSize(2));
assertThat(mavenRemoteRepositories.get(0).getId(), is("customRepo"));
assertThat(mavenRemoteRepositories.get(0).getUrl(), is(new URL(additionalRepositoryUrl)));
assertThat(mavenRemoteRepositories.get(1).getId(), is("mavenCentral"));
assertThat(mavenRemoteRepositories.get(1).getUrl(), is(new URL(MAVEN_CENTRAL_URL)));
});
}
use of org.mule.maven.client.api.model.RemoteRepository in project mule by mulesoft.
the class MavenConfigTestCase method loadFromFileOnly.
@Description("Test a single file loaded from the classpath and verifies that the mule.conf and mule.properties json are not taken into account.")
@Test
public void loadFromFileOnly() throws MalformedURLException {
GlobalConfigLoader.reset();
MavenConfiguration mavenConfig = getMavenConfig();
List<RemoteRepository> remoteRepositories = mavenConfig.getMavenRemoteRepositories();
assertThat(remoteRepositories, hasSize(1));
RemoteRepository remoteRepository = remoteRepositories.get(0);
assertThat(remoteRepository.getId(), is(MAVEN_CENTRAL_REPO_ID));
assertThat(remoteRepository.getUrl(), is(new URL(MAVEN_CENTRAL_URL)));
assertThat(remoteRepository.getAuthentication().get().getPassword(), is("password"));
assertThat(remoteRepository.getAuthentication().get().getUsername(), is("username"));
}
use of org.mule.maven.client.api.model.RemoteRepository 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.RemoteRepository 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.RemoteRepository 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)));
});
}
Aggregations