avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon/src/test/org/apache/avalon/framework/configuration/test SAXConfigurationHandlerTestCase.java
Date Mon, 29 Oct 2001 15:46:58 GMT
bloritsch    01/10/29 07:46:58

  Modified:    src/test/org/apache/avalon/framework/configuration/test
                        SAXConfigurationHandlerTestCase.java
  Log:
  debug SAXConfigurationHandler.  It was emitting incorrect SAX events
  
  Revision  Changes    Path
  1.2       +33 -20    jakarta-avalon/src/test/org/apache/avalon/framework/configuration/test/SAXConfigurationHandlerTestCase.java
  
  Index: SAXConfigurationHandlerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/test/org/apache/avalon/framework/configuration/test/SAXConfigurationHandlerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SAXConfigurationHandlerTestCase.java	2001/09/17 11:23:50	1.1
  +++ SAXConfigurationHandlerTestCase.java	2001/10/29 15:46:58	1.2
  @@ -10,6 +10,7 @@
   import java.util.List;
   import junit.framework.TestCase;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.Namespace;
   import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
   import org.xml.sax.Attributes;
   import org.xml.sax.helpers.AttributesImpl;
  @@ -22,7 +23,7 @@
   public final class SAXConfigurationHandlerTestCase extends TestCase
   {
       private SAXConfigurationHandler m_handler;
  -        
  +
       public SAXConfigurationHandlerTestCase()
       {
           this("SAXConfigurationHandler Test Case ");
  @@ -43,40 +44,52 @@
           m_handler = null;
       }
   
  +    /**
  +     * Test the ContentHandler.  The XML created should look like this:
  +     *
  +     * <pre>
  +     *   &lt;rawName attqName="attValue"&gt;
  +     *     &lt;child:localName xmlns:child="namespaceURI"&gt;value&lt;/child:localName&gt;
  +     *   &lt;/rawName&gt;
  +     * </pre>
  +     */
       public void testHandling() throws Exception
       {
  -        final String namespaceURI = "namespaceURI";
  -        final String localName = "localName";
  -        final String rawName = "rawName";
  -        final String value = "value";
  -        final String attUri = "attUri";
  -        final String attLocalName = "attLocalName";
  +        final String rootURI = "";
  +        final String rootlocal = "rawName";
  +        final String rootraw = "rawName";
  +        final String childURI = "namespaceURI";
  +        final String childlocal = "localName";
  +        final String childraw = "child:" + childlocal;
  +        final String childvalue = "value";
           final String attqName = "attqName";
  -        final String attType = "attType";
           final String attValue = "attValue";
  -        final String childfix = "child";
   
           final AttributesImpl attributes  = new AttributesImpl();
  -        attributes.addAttribute(attUri,attLocalName,attqName,
  -                                attType,attValue);
  +        attributes.addAttribute(null,null,attqName,
  +                                "CDATA",attValue);
   
           final AttributesImpl childAttributes  = new AttributesImpl();
  +
           m_handler.startDocument();
  -        m_handler.startElement( namespaceURI, localName, rawName, attributes );
  -        m_handler.startElement( namespaceURI + childfix,  
  -                                localName + childfix,
  -                                rawName + childfix, 
  +        m_handler.startElement( rootURI, rootlocal, rootraw, attributes );
  +        m_handler.startPrefixMapping( "child", childURI );
  +        m_handler.startElement( childURI,
  +                                childlocal,
  +                                childraw,
                                   childAttributes );
   
  -        m_handler.characters( value.toCharArray(), 0, value.length() );
  -        m_handler.endElement( namespaceURI + childfix, localName + childfix, rawName +
childfix );
  -        m_handler.endElement( namespaceURI, localName, rawName);
  +        m_handler.characters( childvalue.toCharArray(), 0, childvalue.length() );
  +        m_handler.endElement( childURI, childlocal, childraw );
  +        m_handler.endPrefixMapping( "child" );
  +        m_handler.endElement( null, null, rootraw);
           m_handler.endDocument();
   
           final Configuration configuration = m_handler.getConfiguration();
           assertEquals( attValue, configuration.getAttribute(attqName));
  -        assertEquals( value, configuration.getChild(rawName+childfix).getValue());
  -        assertEquals( rawName, configuration.getName());
  +        assertEquals( childvalue, configuration.getChild(childlocal).getValue());
  +        assertEquals( Namespace.getNamespace("child", childURI), configuration.getChild(childlocal).getNamespace()
);
  +        assertEquals( rootraw, configuration.getName());
       }
   }
   
  
  
  

--
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