Skip to Content.
Sympa Menu

notify-dpml - r889 - in trunk/main/util: configuration/impl/src/test/net/dpml/configuration/test i18n/src/test/net/dpml/i18n/test

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r889 - in trunk/main/util: configuration/impl/src/test/net/dpml/configuration/test i18n/src/test/net/dpml/i18n/test
  • Date: Mon, 9 Jan 2006 03:44:07 +0100

Author: mcconnell
Date: 2006-01-09 03:43:31 +0100 (Mon, 09 Jan 2006)
New Revision: 889

Modified:

trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationBuilderTestCase.java

trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationSerializerTestCase.java

trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/SAXConfigurationHandlerTestCase.java

trunk/main/util/i18n/src/test/net/dpml/i18n/test/ResourceManagerTestCase.java
Log:
resolve issues in i18n and configuration packages

Modified:
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationBuilderTestCase.java
===================================================================
---
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationBuilderTestCase.java
2006-01-09 02:12:59 UTC (rev 888)
+++
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationBuilderTestCase.java
2006-01-09 02:43:31 UTC (rev 889)
@@ -54,41 +54,42 @@
private File m_fileWithExternalEntity;
private File m_innerXmlFile;
private File m_testDirectory;
- private final String SIMPLE_XML = "<?xml version=\"1.0\" ?>" +
- "<config boolAttr=\"true\" floatAttr=\"1.32\">" + " <elements-a>" +
- " <element name=\"a\"/>" + " </elements-a>" +
- " <elements-b>" + " <element name=\"b\"/> " +
- " </elements-b>" + " <elements-b type=\"type-b\"/>" +
- " <elements-c>" + " true" + " </elements-c>" + "</config>";
- private final String NS_XML = "<?xml version=\"1.0\" ?>" +
"<conf:config" +
- " boolAttr=\"true\" floatAttr=\"1.32\"" +
- " xmlns:conf=\"http://conf.com\"; xmlns:a=\"http://a.com\";
xmlns:b=\"http://b.com\"; xmlns:c=\"http://c.com\"; xmlns:d=\"http://d.com\";
xmlns:e=\"http://e.com\";>" +
- " <a:elements-a>" + " <c:element name=\"a\"/>" +
- " </a:elements-a>" +
- " <elements-b xmlns=\"http://defaultns.com\";>" +
- " <element name=\"b\"/> " + " </elements-b>" +
- " <b:elements-b type=\"type-b\"/>" + " <elements-c>" + " true"
+
- " </elements-c>" + " <d:element>d:element</d:element>" +
- " <e:element>e:element</e:element>" + "</conf:config>";
- private final String spaceTrimmingCheckXML = "<?xml version=\"1.0\" ?>" +
- " <config>" + " <trimmed-item>\n" + " value \n" +
- " </trimmed-item>\n" + " <preserved-item
xml:space='preserve'>\n" +
- " a space&#13; a CR, then a trailing space </preserved-item>\n" +
- " <first-level-item xml:space='preserve'>\n" +
- " <second-level-preserved> whitespace around
</second-level-preserved>\n" +
- " </first-level-item>\n" + " <trimmed-again-item>\n" +
- " value \n" + " </trimmed-again-item>\n" + "</config>";
- private final String mixedContentXML = "<?xml version=\"1.0\" ?>" +
- "<a>a<a/></a>";
- private final String XML_WITH_EXTERNAL_ENTITY = "<?xml version=\"1.0\"
?>" +
- "<!DOCTYPE document" + "[" + "<!ENTITY config SYSTEM \"inner.xml\">"
+
- "]>" + "<config boolAttr=\"true\" floatAttr=\"1.32\">" +
- " &config; " + "</config>";
- private final String INNER_XML = " <elements-a>" +
- " <element name=\"a\"/>" + " </elements-a>" +
- " <elements-b>" + " <element name=\"b\"/> " +
- " </elements-b>" + " <elements-b type=\"type-b\"/>" +
- " <elements-c>" + " true" + " </elements-c>";
+
+ private static final String SIMPLE_XML = "<?xml version=\"1.0\" ?>"
+ + "<config boolAttr=\"true\" floatAttr=\"1.32\">" + " <elements-a>"
+ + " <element name=\"a\"/>" + " </elements-a>"
+ + " <elements-b>" + " <element name=\"b\"/> "
+ + " </elements-b>" + " <elements-b type=\"type-b\"/>"
+ + " <elements-c>" + " true" + " </elements-c>" + "</config>";
+ private static final String NS_XML = "<?xml version=\"1.0\" ?>" +
"<conf:config"
+ + " boolAttr=\"true\" floatAttr=\"1.32\""
+ + " xmlns:conf=\"http://conf.com\"; xmlns:a=\"http://a.com\";
xmlns:b=\"http://b.com\"; xmlns:c=\"http://c.com\"; xmlns:d=\"http://d.com\";
xmlns:e=\"http://e.com\";>"
+ + " <a:elements-a>" + " <c:element name=\"a\"/>"
+ + " </a:elements-a>"
+ + " <elements-b xmlns=\"http://defaultns.com\";>"
+ + " <element name=\"b\"/> " + " </elements-b>"
+ + " <b:elements-b type=\"type-b\"/>" + " <elements-c>" + " true"
+ + " </elements-c>" + " <d:element>d:element</d:element>"
+ + " <e:element>e:element</e:element>" + "</conf:config>";
+ private static final String SPACE_TRIMMING_CHECK_XML = "<?xml
version=\"1.0\" ?>"
+ + " <config>" + " <trimmed-item>\n" + " value \n"
+ + " </trimmed-item>\n" + " <preserved-item
xml:space='preserve'>\n"
+ + " a space&#13; a CR, then a trailing space </preserved-item>\n"
+ + " <first-level-item xml:space='preserve'>\n"
+ + " <second-level-preserved> whitespace around
</second-level-preserved>\n"
+ + " </first-level-item>\n" + " <trimmed-again-item>\n"
+ + " value \n" + " </trimmed-again-item>\n" + "</config>";
+ private static final String MIXED_CONTENT_XML = "<?xml version=\"1.0\"
?>"
+ + "<a>a<a/></a>";
+ private static final String XML_WITH_EXTERNAL_ENTITY = "<?xml
version=\"1.0\" ?>"
+ + "<!DOCTYPE document" + "[" + "<!ENTITY config SYSTEM \"inner.xml\">"
+ + "]>" + "<config boolAttr=\"true\" floatAttr=\"1.32\">"
+ + " &config; " + "</config>";
+ private static final String INNER_XML = " <elements-a>"
+ + " <element name=\"a\"/>" + " </elements-a>"
+ + " <elements-b>" + " <element name=\"b\"/> "
+ + " </elements-b>" + " <elements-b type=\"type-b\"/>"
+ + " <elements-c>" + " true" + " </elements-c>";

/**
* Creates a new DefaultConfigurationBuilderTestCase object.
@@ -101,7 +102,7 @@
/**
* Creates a new DefaultConfigurationBuilderTestCase object.
*
- * @param name DOCUMENT ME!
+ * @param name the testcase name
*/
public DefaultConfigurationBuilderTestCase( final String name )
{
@@ -120,6 +121,7 @@
* These assertions apply when the default builder is used to create a
* Configuration from <code>simpleXML</code>, ie namespace
* support is disabled.
+ * @exception ConfigurationException if an error occurs
*/
private void simpleAssertions( Configuration conf )
throws ConfigurationException
@@ -131,8 +133,8 @@
try
{
conf.getValue( );
- fail( "Should throw a ConfigurationException, as this element" +
- "contains child elements, not a value" );
+ fail( "Should throw a ConfigurationException, as this element"
+ + "contains child elements, not a value" );
}
catch( ConfigurationException e )
{
@@ -184,6 +186,8 @@
* These assertions apply when the default builder is used to create a
* Configuration from <code>nsXML</code>, ie namespace support is
disabled,
* but the XML uses namespaces.
+ * @param conf the configuration instance
+ * @exception ConfigurationException if an error occurs
*/
private void simpleAssertionsNS( Configuration conf )
throws ConfigurationException
@@ -195,8 +199,8 @@
try
{
conf.getValue( );
- fail( "Should throw a ConfigurationException, as this element" +
- "contains child elements, not a value" );
+ fail( "Should throw a ConfigurationException, as this element"
+ + "contains child elements, not a value" );
}
catch( ConfigurationException e )
{
@@ -255,6 +259,8 @@
* These assertions apply when the namespace-enabled builder is used to
* create a Configuration from <code>nsXML</code>, ie namespace support
is
* enabled, and the XML uses namespaces.
+ * @param conf the configuration instance
+ * @exception ConfigurationException if an error occurs
*/
private void nsAssertions( Configuration conf )
throws ConfigurationException
@@ -266,8 +272,8 @@
try
{
conf.getValue( );
- fail( "Should throw a ConfigurationException, as this element" +
- "contains child elements, not a value" );
+ fail( "Should throw a ConfigurationException, as this element"
+ + "contains child elements, not a value" );
}
catch( ConfigurationException e )
{
@@ -338,9 +344,9 @@
}

/**
- * DOCUMENT ME!
+ * Testcase setup.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
protected void setUp( ) throws Exception
{
@@ -364,9 +370,9 @@
}

/**
- * DOCUMENT ME!
+ * Testcase teardown.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
protected void tearDown( ) throws Exception
{
@@ -375,11 +381,11 @@
}

/**
- * DOCUMENT ME!
+ * Test build of configuration from filename.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
- public void testBuildFromFileName( ) throws Exception
+ public void testBuildFromFileName() throws Exception
{
m_builder = new DefaultConfigurationBuilder( );
m_nsBuilder = new DefaultConfigurationBuilder( true ); // switch on
namespace support
@@ -397,11 +403,11 @@
}

/**
- * DOCUMENT ME!
+ * Test build of configuration from file.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
- public void testBuildFromFile( ) throws Exception
+ public void testBuildFromFile() throws Exception
{
m_builder = new DefaultConfigurationBuilder( );
m_nsBuilder = new DefaultConfigurationBuilder( true ); // switch on
namespace support
@@ -415,9 +421,9 @@
}

/**
- * DOCUMENT ME!
+ * Test build of configuration.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
public void testBuild( ) throws Exception
{
@@ -435,11 +441,12 @@
/**
* Checks that whitespace is normally stripped but preserved if
* space preserving processing instructions are present.
+ * @throws Exception if an error occurs
*/
public void testSpaceTrimming( ) throws Exception
{
DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder( );
- InputStream in = new ByteArrayInputStream(
spaceTrimmingCheckXML.getBytes( ) );
+ InputStream in = new ByteArrayInputStream(
SPACE_TRIMMING_CHECK_XML.getBytes( ) );
Configuration conf = builder.build( in );
assertEquals( "Value is trimmed by default", "value",
conf.getChild( "trimmed-item" ).getValue( ) );
@@ -455,14 +462,14 @@
}

/**
- * DOCUMENT ME!
+ * Test mixed content detection.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
public void testMixedContentDetection( ) throws Exception
{
DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder( );
- InputStream in = new ByteArrayInputStream( mixedContentXML.getBytes(
) );
+ InputStream in = new ByteArrayInputStream(
MIXED_CONTENT_XML.getBytes( ) );

try
{
@@ -475,9 +482,9 @@
}

/**
- * DOCUMENT ME!
+ * Test external entity.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
public void testExternalEntity( ) throws Exception
{
@@ -500,21 +507,20 @@
class MyEntityResolver implements EntityResolver
{
/**
- * DOCUMENT ME!
+ * Entity resolver mock object.
*
- * @param publicId DOCUMENT ME!
- * @param systemId DOCUMENT ME!
+ * @param publicId the public id
+ * @param systemId the system id
*
- * @return DOCUMENT ME!
+ * @return the input source
*
- * @throws SAXException DOCUMENT ME!
- * @throws IOException DOCUMENT ME!
+ * @throws SAXException if a sax error occurs
+ * @throws IOException if an io error occurs
*/
public InputSource resolveEntity( String publicId, String systemId )
throws SAXException, IOException
{
Reader reader = new FileReader( m_innerXmlFile );
-
return new InputSource( reader );
}
}

Modified:
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationSerializerTestCase.java
===================================================================
---
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationSerializerTestCase.java
2006-01-09 02:12:59 UTC (rev 888)
+++
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/DefaultConfigurationSerializerTestCase.java
2006-01-09 02:43:31 UTC (rev 889)
@@ -30,8 +30,8 @@
*/
public final class DefaultConfigurationSerializerTestCase extends TestCase
{
- private File testDirectory;
- private File testDirectory2;
+ private File m_testDirectory;
+ private File m_testDirectory2;

/**
* Creates a new DefaultConfigurationSerializerTestCase object.
@@ -52,24 +52,24 @@
}

/**
- * DOCUMENT ME!
+ * Testcase setup.
*/
- public void setUp( )
+ public void setUp()
{
File basedir = getWorkDir( );
- testDirectory = ( new File( basedir, "io" ) ).getAbsoluteFile( );
- testDirectory2 = new File( basedir,
+ m_testDirectory = ( new File( basedir, "io" ) ).getAbsoluteFile( );
+ m_testDirectory2 = new File( basedir,
"DefaultConfigurationSerializerTestCase" ).getAbsoluteFile(
);

- if( !testDirectory.exists( ) )
+ if( !m_testDirectory.exists( ) )
{
- testDirectory.mkdirs( );
+ m_testDirectory.mkdirs( );
}

- assertTrue( !testDirectory2.exists( ) );
+ assertTrue( !m_testDirectory2.exists( ) );
}

- private File getWorkDir( )
+ private File getWorkDir()
{
String path = System.getProperty( "project.test.dir" );

@@ -90,13 +90,14 @@
/**
* Checks that the <code>serializeToFile</code> method closes the output
stream
* when it is done.
+ * @throws Exception if an error occurs
*/
- public void testSerializeToFile( ) throws Exception
+ public void testSerializeToFile() throws Exception
{
DefaultConfiguration config = new DefaultConfiguration( "root", "" );
config.setAttribute( "attribute", "value" );

- File file = new File( testDirectory,
+ File file = new File( m_testDirectory,
"DefaultConfigurationSerializerTestCase.xml" );

DefaultConfigurationSerializer serializer = new
DefaultConfigurationSerializer( );
@@ -105,8 +106,8 @@
//
// This will not work if the serializeToFile method keeps the stream
open.
//
- assertTrue( testDirectory.renameTo( testDirectory2 ) );
- assertTrue( testDirectory2.renameTo( testDirectory ) );
+ assertTrue( m_testDirectory.renameTo( m_testDirectory2 ) );
+ assertTrue( m_testDirectory2.renameTo( m_testDirectory ) );

file.delete( );
}

Modified:
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/SAXConfigurationHandlerTestCase.java
===================================================================
---
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/SAXConfigurationHandlerTestCase.java
2006-01-09 02:12:59 UTC (rev 888)
+++
trunk/main/util/configuration/impl/src/test/net/dpml/configuration/test/SAXConfigurationHandlerTestCase.java
2006-01-09 02:43:31 UTC (rev 889)
@@ -42,7 +42,7 @@
/**
* Creates a new SAXConfigurationHandlerTestCase object.
*
- * @param name DOCUMENT ME!
+ * @param name testcase name
*/
public SAXConfigurationHandlerTestCase( final String name )
{
@@ -58,6 +58,7 @@
* &lt;emptyElement/&gt;
* &lt;/rawName&gt;
* </pre>
+ * @throws Exception if an error occurs
*/
public void testDefaultHandling( ) throws Exception
{
@@ -108,13 +109,13 @@
}

/**
- * DOCUMENT ME!
+ * Test namespace handling.
*
- * @throws Exception DOCUMENT ME!
+ * @throws Exception if an error occurs
*/
- public void testNamespaceHandling( ) throws Exception
+ public void testNamespaceHandling() throws Exception
{
- SAXConfigurationHandler handler = new
NamespacedSAXConfigurationHandler( );
+ SAXConfigurationHandler handler = new
NamespacedSAXConfigurationHandler();

final String rootURI = "";
final String rootlocal = "rawName";
@@ -126,30 +127,30 @@
final String attqName = "attqName";
final String attValue = "attValue";

- final AttributesImpl attributes = new AttributesImpl( );
+ final AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute( "", attqName, attqName, "CDATA", attValue );

final AttributesImpl childAttributes = new AttributesImpl( );
childAttributes.addAttribute( "", "child", "xmlns:child", "CDATA",
childURI );

- handler.startDocument( );
+ handler.startDocument();
handler.startPrefixMapping( "child", childURI );
handler.startElement( rootURI, rootlocal, rootraw, attributes );
handler.startElement( childURI, childlocal, childraw,
childAttributes );

- handler.characters( childvalue.toCharArray( ), 0,
childvalue.length( ) );
+ handler.characters( childvalue.toCharArray(), 0, childvalue.length(
) );
handler.endElement( childURI, childlocal, childraw );
handler.endElement( null, null, rootraw );
handler.endPrefixMapping( "child" );
- handler.endDocument( );
+ handler.endDocument();

- final Configuration configuration = handler.getConfiguration( );
+ final Configuration configuration = handler.getConfiguration();
assertEquals( attValue, configuration.getAttribute( attqName ) );
assertEquals( childvalue,
- configuration.getChild( childlocal ).getValue( ) );
+ configuration.getChild( childlocal ).getValue() );
assertEquals( childURI,
- configuration.getChild( childlocal ).getNamespace( ) );
- assertEquals( rootraw, configuration.getName( ) );
+ configuration.getChild( childlocal ).getNamespace() );
+ assertEquals( rootraw, configuration.getName() );
}
}

Modified:
trunk/main/util/i18n/src/test/net/dpml/i18n/test/ResourceManagerTestCase.java
===================================================================
---
trunk/main/util/i18n/src/test/net/dpml/i18n/test/ResourceManagerTestCase.java
2006-01-09 02:12:59 UTC (rev 888)
+++
trunk/main/util/i18n/src/test/net/dpml/i18n/test/ResourceManagerTestCase.java
2006-01-09 02:43:31 UTC (rev 889)
@@ -33,11 +33,9 @@
public class ResourceManagerTestCase
extends TestCase
{
- public ResourceManagerTestCase( final String name )
- {
- super( name );
- }
-
+ /**
+ * Test class resources.
+ */
public void testClassResources()
{
try
@@ -53,6 +51,9 @@
}
}

+ /**
+ * Test package resources.
+ */
public void testPackageResources()
{
try




  • r889 - in trunk/main/util: configuration/impl/src/test/net/dpml/configuration/test i18n/src/test/net/dpml/i18n/test, mcconnell at BerliOS, 01/08/2006

Archive powered by MHonArc 2.6.24.

Top of Page