avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/configuration/src/test/org/apache/excalibur/configuration/validation/test JarvConfigurationValidatorFactoryTestCase.java invalid.rng valid.rng
Date Wed, 13 Nov 2002 03:25:14 GMT
proyal      2002/11/12 19:25:14

  Added:       configuration/src/test/org/apache/excalibur/configuration/validation/test
                        JarvConfigurationValidatorFactoryTestCase.java
                        invalid.rng valid.rng
  Log:
  Testcases for the JARV ValidatorFactory
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/configuration/src/test/org/apache/excalibur/configuration/validation/test/JarvConfigurationValidatorFactoryTestCase.java
  
  Index: JarvConfigurationValidatorFactoryTestCase.java
  ===================================================================
  package org.apache.excalibur.configuration.validation.test;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  import org.apache.avalon.framework.logger.ConsoleLogger;
  import org.apache.excalibur.configuration.validation.ConfigurationValidator;
  import org.apache.excalibur.configuration.validation.JarvConfigurationValidatorFactory;
  import org.apache.excalibur.configuration.validation.ValidationResult;
  
  import junit.framework.TestCase;
  
  /**
   *
   * @author <a href="proyal@pace2020.com">peter royal</a>
   */
  public class JarvConfigurationValidatorFactoryTestCase extends TestCase
  {
      private JarvConfigurationValidatorFactory m_factory;
      private DefaultConfiguration m_configuration;
  
      public JarvConfigurationValidatorFactoryTestCase()
      {
          this( "JarvConfigurationValidatorFactoryTestCase" );
      }
  
      public JarvConfigurationValidatorFactoryTestCase( String s )
      {
          super( s );
      }
  
      public void setUp() throws Exception
      {
          m_configuration = new DefaultConfiguration( "a", "b" );
          m_configuration.setAttribute( "test", "test" );
          m_configuration.setValue( "test" );
  
          m_factory = new JarvConfigurationValidatorFactory();
          m_factory.enableLogging( new ConsoleLogger() );
          m_factory.configure( createConfiguration() );
          m_factory.initialize();
      }
  
      private Configuration createConfiguration() throws Exception
      {
          final DefaultConfiguration c = new DefaultConfiguration( "validator", "0" );
          final DefaultConfiguration child = new DefaultConfiguration( "schema-language",
"1" );
  
          c.setAttribute( "schema-type", "relax-ng" );
          child.setValue( "http://relaxng.org/ns/structure/1.0" );
  
          c.addChild( child );
  
          c.makeReadOnly();
  
          return c;
      }
  
      public void tearDowm()
      {
          m_configuration = null;
      }
  
      public void testValidConfiguration()
          throws Exception
      {
          final ConfigurationValidator validator =
              m_factory.createValidator(
                  "relax-ng",
                  this.getClass().getResourceAsStream( "valid.rng" ) );
  
          final ValidationResult result = validator.isValid( m_configuration );
  
          System.out.println( "(bad) testValidConfiguration.warning: " + result.getWarnings()
);
          System.out.println( "(bad) testValidConfiguration.errors: " + result.getErrors()
);
  
          assertEquals( "failure!!", true, result.isValid() );
      }
  
      public void testInvalidConfiguration()
          throws Exception
      {
          final ConfigurationValidator validator =
              m_factory.createValidator(
                  "relax-ng",
                  this.getClass().getResourceAsStream( "invalid.rng" ) );
  
          final ValidationResult result = validator.isValid( m_configuration );
  
          System.out.println( "(expected) testInvalidConfiguration.warning: " + result.getWarnings()
);
          System.out.println( "(expected) testInvalidConfiguration.errors: " + result.getErrors()
);
  
          assertEquals( false, result.isValid() );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/configuration/src/test/org/apache/excalibur/configuration/validation/test/invalid.rng
  
  Index: invalid.rng
  ===================================================================
  <?xml version="1.0"?>
  <element
      name="blah"
      xmlns="http://relaxng.org/ns/structure/1.0"
      datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  >
      <empty/>
  </element>
  
  
  
  1.1                  jakarta-avalon-excalibur/configuration/src/test/org/apache/excalibur/configuration/validation/test/valid.rng
  
  Index: valid.rng
  ===================================================================
  <?xml version="1.0"?>
  <element
      name="root"
      xmlns="http://relaxng.org/ns/structure/1.0"
      datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  >
      <attribute name="test"/>
      <text/>
  </element>
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message