@Test public void shouldThrowXsdValidationWhenPackageRepositoryNamesAreDuplicate() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + format(REPO_WITH_NAME, "1", "repo", "") + format(REPO_WITH_NAME, "2", "repo", "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Duplicate unique value [repo] declared for identity constraint of element \"repositories\".", "Duplicate unique value [repo] declared for identity constraint \"uniqueRepositoryName\" of element \"repositories\"." ); }
@Test public void shouldNotAllowEmptyAuthInApproval() throws Exception { assertXsdFailureDuringLoad(STAGE_WITH_EMPTY_AUTH, "The content of element 'authorization' is not complete. One of '{user, role}' is expected."); }
@Test public void shouldThrowExceptionIfBuildPlansExistWithTheSameNameWithinAPipeline() throws Exception { assertXsdFailureDuringLoad(JOBS_WITH_SAME_NAME, "Duplicate unique value [unit] declared for identity constraint of element \"jobs\".", "Duplicate unique value [unit] declared for identity constraint \"uniqueJob\" of element \"jobs\"." ); }
@Test public void shouldNotAllowEmptyRoles() throws Exception { assertXsdFailureDuringLoad(CONFIG_WITH_EMPTY_ROLES, "The content of element 'roles' is not complete. One of '{baseRole}' is expected."); }
@Test public void shouldNotAllowEmptyUser() throws Exception { assertXsdFailureDuringLoad(CONFIG_WITH_EMPTY_USER, "Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_userusersroleType'."); }
@Test public void shouldThrowExceptionIfPipelineDoesNotContainAnyBuildPlans() throws Exception { assertXsdFailureDuringLoad(STAGE_WITH_NO_JOBS, "The content of element 'jobs' is not complete. One of '{job}' is expected."); }
@Test public void shouldThrowXsdValidationWhenPackageNameIsMissing() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_MISSING_NAME, PACKAGE_WITH_MISSING_NAME) + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "\"Name\" is required for Repository"); }
@Test public void shouldThrowXsdValidationWhenPackageIdsAreDuplicate() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO, format("<packages>%s%s</packages>", PACKAGE, PACKAGE)) + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Duplicate unique value [package-id] declared for identity constraint of element \"cruise\".", "Duplicate unique value [package-id] declared for identity constraint \"uniquePackageId\" of element \"cruise\"." ); }
@Test public void shouldThrowXsdValidationWhenPackageRepositoryNameIsMissing() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_MISSING_NAME, "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "\"Name\" is required for Repository"); }
@Test public void shouldThrowXsdValidationWhenPackageRepositoryIdIsInvalid() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_INVALID_ID, "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Repo id is invalid. \"id with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageRepositoryNameIsEmpty() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_EMPTY_NAME, "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Name is invalid. \"\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageRepositoryNameIsInvalid() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_INVALID_NAME, "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Name is invalid. \"name with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageIdIsEmpty() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_EMPTY_ID, PACKAGE_WITH_EMPTY_ID) + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Repo id is invalid. \"\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageRepositoryIdIsEmpty() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_EMPTY_ID, "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Repo id is invalid. \"\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageIdIsInvalid() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_INVALID_ID, PACKAGE_WITH_INVALID_ID) + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Repo id is invalid. \"id with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageNameIsEmpty() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_EMPTY_NAME, PACKAGE_WITH_EMPTY_NAME) + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Name is invalid. \"\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageNameIsInvalid() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO_WITH_INVALID_NAME, PACKAGE_WITH_INVALID_NAME) + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Name is invalid. \"name with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"); }
@Test public void shouldThrowXsdValidationWhenPackageRepositoryIdsAreDuplicate() throws Exception { String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'><repositories>\n" + withPackages(REPO, "") + withPackages(REPO, "") + " </repositories></cruise>"; assertXsdFailureDuringLoad(xml, "Duplicate unique value [repo-id] declared for identity constraint of element \"repositories\".", "Duplicate unique value [repo-id] declared for identity constraint \"uniqueRepositoryId\" of element \"repositories\"." ); }
@Test public void shouldAllowOnlyThreeValuesForLockBehavior() throws Exception { xmlLoader.loadConfigHolder(pipelineWithAttributes("name=\"p1\" lockBehavior=\"" + LOCK_VALUE_LOCK_ON_FAILURE + "\"", CONFIG_SCHEMA_VERSION)); xmlLoader.loadConfigHolder(pipelineWithAttributes("name=\"p2\" lockBehavior=\"" + LOCK_VALUE_UNLOCK_WHEN_FINISHED + "\"", CONFIG_SCHEMA_VERSION)); xmlLoader.loadConfigHolder(pipelineWithAttributes("name=\"p3\" lockBehavior=\"" + LOCK_VALUE_NONE + "\"", CONFIG_SCHEMA_VERSION)); xmlLoader.loadConfigHolder(pipelineWithAttributes("name=\"pipelineWithNoLockBehaviorDefined\"", CONFIG_SCHEMA_VERSION)); assertXsdFailureDuringLoad(pipelineWithAttributes("name=\"pipelineWithWrongLockBehavior\" lockBehavior=\"some-random-value\"", CONFIG_SCHEMA_VERSION), "Value 'some-random-value' is not facet-valid with respect to enumeration '[lockOnFailure, unlockWhenFinished, none]'. It must be a value from the enumeration."); }