Search in sources :

Example 1 with RemoteRepository

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)));
    });
}
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 2 with RemoteRepository

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"));
}
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 3 with RemoteRepository

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)));
    });
}
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 4 with RemoteRepository

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)));
    });
}
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 5 with RemoteRepository

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)));
    });
}
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)

Aggregations

Description (io.qameta.allure.Description)6 Test (org.junit.Test)6 MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)6 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)6 URL (java.net.URL)5 HashMap (java.util.HashMap)3 File (java.io.File)1