[ 
https://issues.apache.org/jira/browse/WICKET-4315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13175824#comment-13175824
 ] 

Sven Meier commented on WICKET-4315:
------------------------------------

With your String parameter you're calling a different constructor with a 
default value:

  public StringResourceModel(final String resourceKey, final Component 
component,
                final IModel<?> model, final String defaultValue, final 
Object... parameters)

Cast your parameter to Object and you're testing the correct method:

  StringResourceModel bugModel = new StringResourceModel("simple.bug", page, 
null, (Object)"Already", "fixed");

This is how varargs work in Java.
                
> StringResourceModel skip first parameter in va args parameters, in case if 
> first parameter has string type
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4315
>                 URL: https://issues.apache.org/jira/browse/WICKET-4315
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.1, 1.5.3
>         Environment: not related to env
>            Reporter: Igor Azarny
>              Labels: StringResourceModel, core,, wicket
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> StringResourceModel skip first parameter in va args parameters, in case if 
> first parameter has string type. Works on in case if first parameter non 
> string type. 
> Way to reproduce. 
> 1. locate StringResourceModelTest$TestPage.properties in 
> apache-wicket-1.5.3\src\wicket-core\src\test\java\org\apache\wicket\model
> 2. add following line: simple.bug=Hi i am new bug. {0} {1}
> 3. change StringResourceModelTest#getSimpleResource() 
>       public void getSimpleResource()
>       {
>               StringResourceModel model = new 
> StringResourceModel("simple.text", page, null);
>               Assert.assertEquals("Text should be as expected", "Simple 
> text", model.getString());
>               Assert.assertEquals("Text should be as expected", "Simple 
> text", model.getObject());
>               StringResourceModel thisWorksModel = new 
> StringResourceModel("simple.bug", page, null, new 
> java.math.BigDecimal("100"), "500");
>               Assert.assertEquals("Text should be as expected", "Hi i am new 
> bug. 100 500", thisWorksModel.getObject());
>               //will be failed
>               StringResourceModel bugModel = new 
> StringResourceModel("simple.bug", page, null, "Already", "fixed");
>               Assert.assertEquals("Text should be as expected", "Hi i am new 
> bug. Already fixed", bugModel.getObject());
>       }
> 4. expected result - all tests passed 
> 5. actual result assertion failed - Assert.assertEquals("Text should be as 
> expected", "Hi i am new bug. Already fixed", bugModel.getObject());
> -------------------------------------------------------------------------------
> Test set: org.apache.wicket.model.StringResourceModelTest
> -------------------------------------------------------------------------------
> Tests run: 11, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.974 sec 
> <<< FAILURE!
> getSimpleResource(org.apache.wicket.model.StringResourceModelTest)  Time 
> elapsed: 0.745 sec  <<< FAILURE!
> junit.framework.ComparisonFailure: Text should be as expected expected:<Hi i 
> am new bug. [Already fixed]> but was:<Hi i am new bug. [fixed {1}]>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to