Search in sources :

Example 6 with MavenConfiguration

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));
    });
}
Also used : MavenConfiguration(org.mule.maven.client.api.model.MavenConfiguration) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 7 with MavenConfiguration

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)));
    });
}
Also used : MavenConfiguration(org.mule.maven.client.api.model.MavenConfiguration) HashMap(java.util.HashMap) RemoteRepository(org.mule.maven.client.api.model.RemoteRepository) URL(java.net.URL) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 8 with MavenConfiguration

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)));
    });
}
Also used : MavenConfiguration(org.mule.maven.client.api.model.MavenConfiguration) RemoteRepository(org.mule.maven.client.api.model.RemoteRepository) URL(java.net.URL) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 9 with MavenConfiguration

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)));
    });
}
Also used : MavenConfiguration(org.mule.maven.client.api.model.MavenConfiguration) HashMap(java.util.HashMap) RemoteRepository(org.mule.maven.client.api.model.RemoteRepository) URL(java.net.URL) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 10 with MavenConfiguration

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));
    });
}
Also used : MavenConfiguration(org.mule.maven.client.api.model.MavenConfiguration) HashMap(java.util.HashMap) RemoteRepository(org.mule.maven.client.api.model.RemoteRepository) File(java.io.File) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)10 Description (io.qameta.allure.Description)7 URL (java.net.URL)7 Test (org.junit.Test)7 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)7 File (java.io.File)3 HashMap (java.util.HashMap)3 ConfigObject (com.typesafe.config.ConfigObject)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Map (java.util.Map)1 Properties (java.util.Properties)1 MavenClientProvider (org.mule.maven.client.api.MavenClientProvider)1 SettingsSupplierFactory (org.mule.maven.client.api.SettingsSupplierFactory)1 Authentication (org.mule.maven.client.api.model.Authentication)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 RuntimeGlobalConfigException (org.mule.runtime.globalconfig.api.exception.RuntimeGlobalConfigException)1 AetherClassPathClassifier (org.mule.test.runner.api.AetherClassPathClassifier)1 ArtifactClassificationTypeResolver (org.mule.test.runner.api.ArtifactClassificationTypeResolver)1 ArtifactIsolatedClassLoaderBuilder (org.mule.test.runner.api.ArtifactIsolatedClassLoaderBuilder)1