Search in sources :

Example 6 with XsdValidationException

use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.

the class SCMConfigXmlLoaderTest method shouldThrowXsdValidationWhenSCMNameIsEmpty.

@Test
public void shouldThrowXsdValidationWhenSCMNameIsEmpty() throws Exception {
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'><scms>\n" + SCM_WITH_EMPTY_NAME + " </scms></cruise>";
    try {
        xmlLoader.loadConfigHolder(xml);
        fail("should have thrown XsdValidationException");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), is("Name is invalid. \"\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 7 with XsdValidationException

use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.

the class SCMConfigXmlLoaderTest method shouldThrowXsdValidationWhenSCMIdIsEmpty.

@Test
public void shouldThrowXsdValidationWhenSCMIdIsEmpty() throws Exception {
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'><scms>\n" + SCM_WITH_EMPTY_ID + " </scms></cruise>";
    try {
        xmlLoader.loadConfigHolder(xml);
        fail("should have thrown XsdValidationException");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), is("Scm id is invalid. \"\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 8 with XsdValidationException

use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.

the class SCMConfigXmlLoaderTest method shouldThrowXsdValidationWhenSCMIdIsInvalid.

@Test
public void shouldThrowXsdValidationWhenSCMIdIsInvalid() throws Exception {
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'><scms>\n" + SCM_WITH_INVALID_ID + " </scms></cruise>";
    try {
        xmlLoader.loadConfigHolder(xml);
        fail("should have thrown XsdValidationException");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), is("Scm id is invalid. \"id with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 9 with XsdValidationException

use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.

the class SCMConfigXmlLoaderTest method shouldThrowXsdValidationWhenSCMNameIsInvalid.

@Test
public void shouldThrowXsdValidationWhenSCMNameIsInvalid() throws Exception {
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'><scms>\n" + SCM_WITH_INVALID_NAME + " </scms></cruise>";
    try {
        xmlLoader.loadConfigHolder(xml);
        fail("should have thrown XsdValidationException");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), is("Name is invalid. \"name with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 10 with XsdValidationException

use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.

the class SCMConfigXmlLoaderTest method shouldThrowXsdValidationWhenSCMIdsAreDuplicate.

@Test
public void shouldThrowXsdValidationWhenSCMIdsAreDuplicate() throws Exception {
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'><scms>\n" + VALID_SCM + VALID_SCM + " </scms></cruise>";
    try {
        xmlLoader.loadConfigHolder(xml);
        fail("should have thrown XsdValidationException");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), anyOf(is("Duplicate unique value [scm-id] declared for identity constraint of element \"cruise\"."), is("Duplicate unique value [scm-id] declared for identity constraint \"uniqueSCMId\" of element \"cruise\".")));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Aggregations

XsdValidationException (com.thoughtworks.go.util.XsdValidationException)13 Test (org.junit.jupiter.api.Test)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)7 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)5 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)4 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)4 Packages (com.thoughtworks.go.domain.packagerepository.Packages)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Timeout (org.junit.jupiter.api.Timeout)1