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

Igor Vaynberg commented on WICKET-2269:
---------------------------------------

an example of which part?

> A small change would allow WicketTesting attributeModifiers
> -----------------------------------------------------------
>
>                 Key: WICKET-2269
>                 URL: https://issues.apache.org/jira/browse/WICKET-2269
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.4-RC2
>            Reporter: Martin Makundi
>            Assignee: Igor Vaynberg
>   Original Estimate: 5h
>  Remaining Estimate: 5h
>
> The workaround is as follows, because AttributeModifier.getReplaceModel 
> -method is protected. This operation should somehow be supported in 
> WicketTester:
> Workaround: 
>   private final static Method getReplaceModelMethod;
>   static {
>     try {
>       getReplaceModelMethod = 
> AttributeModifier.class.getDeclaredMethod("getReplaceModel");
>       getReplaceModelMethod.setAccessible(true);
>     } catch (Exception e) {
>       e.printStackTrace();
>       throw new RuntimeException(e);
>     }
>   }
>   public void assertAttribute(String message, String expected, Component 
> component, String attribute) {
>     AttributeModifier behavior = getAttributeModifier(component, attribute);
>     if (behavior != null) {
>       try {
>         IModel<?> model = (IModel<?>) getReplaceModelMethod.invoke(behavior);
>         assertEquals(message, expected, model.getObject().toString());
>         return;
>       } catch (Exception e) {
>         throw new RuntimeException(e);
>       }
>     }
>     
>     fail("Attribute not found.");
>   }
> Usage example:
>     assertAttribute("3", tableFooterCellWebMarkupComponent, 
> WebPageConstants.COLSPAN);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to