You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ludwig Magnusson (JIRA)" <ji...@apache.org> on 2012/09/19 22:09:09 UTC

[jira] [Created] (CONFIGURATION-507) Add toString() method in AbstractConfiguration

Ludwig Magnusson created CONFIGURATION-507:
----------------------------------------------

             Summary: Add toString() method in AbstractConfiguration
                 Key: CONFIGURATION-507
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-507
             Project: Commons Configuration
          Issue Type: Wish
            Reporter: Ludwig Magnusson
            Priority: Minor


Would it be possible to add a toString() method in AbstractConfiguration that prints the mappings of the configuration for debugging purposes?

Is there a reason why this has not been done?
I am willing to supply a patch if this is greenlit.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CONFIGURATION-507) Add toString() method in AbstractConfiguration

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459879#comment-13459879 ] 

Oliver Heger commented on CONFIGURATION-507:
--------------------------------------------

{{ConfigurationUtils}} already provides some methods for dumping out a {{Configuration}} object or for converting it to a string. But I agree that a {{toString()}} implementation in {{AbstractConfiguration}} would be convenient. The method could delegate to {{ConfigurationUtils}}.

A patch is welcome!
                
> Add toString() method in AbstractConfiguration
> ----------------------------------------------
>
>                 Key: CONFIGURATION-507
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-507
>             Project: Commons Configuration
>          Issue Type: Wish
>            Reporter: Ludwig Magnusson
>            Priority: Minor
>
> Would it be possible to add a toString() method in AbstractConfiguration that prints the mappings of the configuration for debugging purposes?
> Is there a reason why this has not been done?
> I am willing to supply a patch if this is greenlit.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CONFIGURATION-507) Add toString() method in AbstractConfiguration

Posted by "Ludwig Magnusson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461361#comment-13461361 ] 

Ludwig Magnusson commented on CONFIGURATION-507:
------------------------------------------------

This turned out to be less trivial than I first thougt. I added the method as you suggested but a lot of tests start to fail. I get 3 failures and 28 errors.

One if the test failures says:

junit.framework.AssertionFailedError: mockNamingEnumeration: Unexpected call: close()
Expected one of:
hasMore() [called]
next() [called]
hasMore() [called]
close() [called]

Which seems to indicate that something is wrong with the iterator returned from getKeys() which is used in to string.
This is also strange however because I added this test method in TestAbstractConfiguration:

    @Test
    public void notSameIterators()
    {
        Configuration configuration = getConfiguration();
        assertNotSame(configuration.getKeys(), configuration.getKeys());
    }

And all tests pass. 
To me this is a sign that the iterator returned from getKeys() is independent of any prior call to that method, which it should be.
I have a hard time understanding what could be wrong.

                
> Add toString() method in AbstractConfiguration
> ----------------------------------------------
>
>                 Key: CONFIGURATION-507
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-507
>             Project: Commons Configuration
>          Issue Type: Wish
>            Reporter: Ludwig Magnusson
>            Priority: Minor
>
> Would it be possible to add a toString() method in AbstractConfiguration that prints the mappings of the configuration for debugging purposes?
> Is there a reason why this has not been done?
> I am willing to supply a patch if this is greenlit.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CONFIGURATION-507) Add toString() method in AbstractConfiguration

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461450#comment-13461450 ] 

Oliver Heger commented on CONFIGURATION-507:
--------------------------------------------

Oops, I did not expect such problems.

Could it be the case that in the tests that fail the toString() method of a Configuration object is invoked, e.g. as part of an exception error message or something like that? Now the method does more than expected, and some tests may need a specific setup for an invocation of getKeys().

For instance, the test failure you listed seems to stem from a test for JNDIConfiguration (at least I assume because of _mockNamingEnumeration_). This test class uses mock objects for the JNDI context. If in one of these test cases toString() is called, unexpected methods on mock objects will be invoked.
                
> Add toString() method in AbstractConfiguration
> ----------------------------------------------
>
>                 Key: CONFIGURATION-507
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-507
>             Project: Commons Configuration
>          Issue Type: Wish
>            Reporter: Ludwig Magnusson
>            Priority: Minor
>
> Would it be possible to add a toString() method in AbstractConfiguration that prints the mappings of the configuration for debugging purposes?
> Is there a reason why this has not been done?
> I am willing to supply a patch if this is greenlit.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira