コード例 #1
0
 @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"));
   }
 }
コード例 #2
0
 @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_\\-.]*"));
   }
 }
コード例 #3
0
 @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(),
         is(
             "Duplicate unique value [scm-id] declared for identity constraint \"uniqueSCMId\" of element \"cruise\"."));
   }
 }