google-code-export / gwt-test-utils

Automatically exported from code.google.com/p/gwt-test-utils
1 stars 0 forks source link

Not work when load label value using Internationalization interface #90

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I wrote a test case to show popup onmouseover event.Some of the labels 
containing on it load from interface that use for Internationalization.
ex :- 

public interface RateViewConstants extends Constants
{
    public static RateViewConstants rateConstants = GWT.create( RateViewConstants.class );

    @Key("rate")
    String getRate();

        @Key("rates.view.ticker.ratePlanCode")
    String getRatePlnCode();
}

On popup panel
Label ratePlanCode = new Label( stringConstants.getRatePlnCode() );
        Label oldRatePlanCode = new Label( stringConstants.getOldRatePlnCode() );
        Label currency = new Label( stringConstants.getcurrency() );

My test failed.It gives following error.

com.octo.gwt.test.exceptions.GwtTestI18NException: No matching property 
"getRatePlnCode" for Constants class 
[it.codegen.tbx.gwt.central.module.tbxconnect.client.view.rate.RateViewConstants
]. Please check the corresponding properties files or use @DefaultStringValue
    at com.octo.gwt.test.internal.i18n.ConstantsInvocationHandler.getCheckedAnnotation(ConstantsInvocationHandler.java:140)
    at com.octo.gwt.test.internal.i18n.ConstantsInvocationHandler.extractDefaultValue(ConstantsInvocationHandler.java:35)
    at com.octo.gwt.test.internal.i18n.LocalizableResourceInvocationHandler.invoke(LocalizableResourceInvocationHandler.java:62)
    at $Proxy26.getRatePlnCode(Unknown Source)
    at it.codegen.tbx.gwt.central.module.tbxconnect.client.view.rate.ticker.RateTypesToolTip.<init>(RateTypesToolTip.java:43)
    at it.codegen.tbx.gwt.central.module.tbxconnect.client.view.rate.ticker.TickerPanel.handleMouseHover(TickerPanel.java:124) 
...............................................

When I heard coded label values like following It works fine.
        Label ratePlanCode = new Label( "AAA" );
    Label oldRatePlanCode = new Label("BBB" );
    Label currency = new Label("CCC" );

Please help me to get rid from this. 

Original issue reported on code.google.com by e06w...@gmail.com on 16 Nov 2011 at 11:29

GoogleCodeExporter commented 9 years ago
I use gwt 2.2 and test-util 0.28.8-SNAPSHOT.

Original comment by e06w...@gmail.com on 16 Nov 2011 at 11:31

GoogleCodeExporter commented 9 years ago
It the the @Key annotation which is not yet supported by gwt-test-utils. I will 
fix this ASAP.

Thanks for this report.

Original comment by gael.laz...@gmail.com on 16 Nov 2011 at 12:03

GoogleCodeExporter commented 9 years ago
Thanks for replying.
After adding @DefaultStringValue under @key I could get rid of that.
ex :-
@Key("rates.view.ticker.ratePlanCode")
@DefaultStringValue("Test String")
String getRatePlnCode();

Original comment by e06w...@gmail.com on 16 Nov 2011 at 12:25

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 11 Dec 2011 at 5:09

GoogleCodeExporter commented 9 years ago
The @Key annotation is now supported by gwt-test-utils.

I've deployed a new 0.28.8-SNAPSHOT with the fix. Could you please give it a 
try and post some feedback here so I could close the issue ?
Thanks !

Original comment by gael.laz...@gmail.com on 11 Dec 2011 at 5:40

GoogleCodeExporter commented 9 years ago
I use 0.36 last version with gwt2.4.0 .
The @Key annotation is not supported yet by gwt-test-utils.

Please ckeck to fix it.
thanks

Original comment by hajer.ak...@gmail.com on 3 Apr 2012 at 7:25

GoogleCodeExporter commented 9 years ago
mmmh this is weird. Checkout the MyConstantsTest 
(http://code.google.com/p/gwt-test-utils/source/browse/src/framework/trunk/gwt-t
est-utils/src/test/java/com/googlecode/gwt/test/i18n/MyConstantsTest.java) 
which works fine : The MyConstants.messageWithKey() 
(http://code.google.com/p/gwt-test-utils/source/browse/src/framework/trunk/gwt-t
est-utils/src/test/java/com/googlecode/gwt/test/i18n/MyConstants.java) uses a 
@Key annotation, and it works very well.

Could you please provide a simple application with a unit test which fails ? 
Thank you very much !

Original comment by gael.laz...@gmail.com on 3 Apr 2012 at 10:04

GoogleCodeExporter commented 9 years ago
I have seen this bug, it appears to be caused by 
ConstantsWithLookupInvocationHandler not escaping periods in 
getAskedMethod(Method,Object[]), thus a request for key "foo.bar" does not 
result in a call to getMethod("foo_bar")

Original comment by rtuc...@gmail.com on 9 May 2012 at 3:13

GoogleCodeExporter commented 9 years ago
Assuming you have a @Key(foot.bar) int foo_bar() method, a call to 
xxx.getInt("foo.bar") should result in a 
java.util.MissingResourceException: Cannot find constant 'foo.bar'; expecting a 
method name : you can only access the value with a getInt("foo_bar") call (I've 
just tested it again).

Original comment by gael.laz...@gmail.com on 19 May 2012 at 1:39