use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesRepositoryWithInvalidId.
@Test
public void shouldNotAllowPackagesRepositoryWithInvalidId() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id wth space", "name", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (XsdValidationException e) {
assertThat(e.getMessage(), is("Repo id is invalid. \"id wth space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
}
}
use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesWithInvalidId.
@Test
public void shouldNotAllowPackagesWithInvalidId() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name", repositoryConfiguration, new Packages(new PackageDefinition("id with space", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (XsdValidationException e) {
assertThat(e.getMessage(), is("Package id is invalid. \"id with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
}
}
use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowMultipleRepositoriesWithSameId.
@Test
public void shouldNotAllowMultipleRepositoriesWithSameId() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id-1", "version", "id", "name1", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
PackageRepository anotherPackageRepository = createPackageRepository("plugin-id-2", "version", "id", "name2", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (XsdValidationException e) {
assertThat(e.getMessage(), anyOf(is("Duplicate unique value [id] declared for identity constraint of element \"repositories\"."), is("Duplicate unique value [id] declared for identity constraint \"uniqueRepositoryId\" of element \"repositories\".")));
}
}
use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowMultiplePackagesWithSameId.
@Test
public void shouldNotAllowMultiplePackagesWithSameId() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id-1", "version", "id1", "name1", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
PackageRepository anotherPackageRepository = createPackageRepository("plugin-id-2", "version", "id2", "name2", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two package repositories with same id");
} catch (XsdValidationException e) {
assertThat(e.getMessage(), anyOf(is("Duplicate unique value [id] declared for identity constraint of element \"cruise\"."), is("Duplicate unique value [id] declared for identity constraint \"uniquePackageId\" of element \"cruise\".")));
}
}
use of com.thoughtworks.go.util.XsdValidationException in project gocd by gocd.
the class SCMConfigXmlLoaderTest method shouldThrowXsdValidationWhenSCMNameIsMissing.
@Test
public void shouldThrowXsdValidationWhenSCMNameIsMissing() throws Exception {
String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'><scms>\n" + SCM_WITH_MISSING_NAME + " </scms></cruise>";
try {
xmlLoader.loadConfigHolder(xml);
fail("should have thrown XsdValidationException");
} catch (XsdValidationException e) {
assertThat(e.getMessage(), is("\"Name\" is required for Scm"));
}
}
Aggregations